Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
Hi, According to the RFC 793 (TCP) the timeout factor in the TCP ping can be adjusted with the help of ‘timeout’ parameter with OPEN and SEND calls. The format ...
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    9

    TCP Timeout

    Hi,

    According to the RFC 793 (TCP) the timeout factor in the TCP ping can be adjusted with the help of ‘timeout’ parameter with OPEN and SEND calls.

    The format of these calls are as follows.

    OPEN (local port, foreign socket, active/passive [, timeout] [, precedence]
    [, security/compartment] [, options]) -> local connection name

    SEND (local connection name, buffer address, byte
    count, PUSH flag, URGENT flag [, timeout])

    I want to know how can I use it in my application.
    I am preparing a utility which will dows the TCP ping.

    If someone can provode any sample code... It will be heartly welcomed.

    Regards
    Vishal

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Quote Originally Posted by vishal-askqns View Post
    Hi,

    According to the RFC 793 (TCP) the timeout factor in the TCP ping can be adjusted with the help of ‘timeout’ parameter with OPEN and SEND calls.

    The format of these calls are as follows.

    OPEN (local port, foreign socket, active/passive [, timeout] [, precedence]
    [, security/compartment] [, options]) -> local connection name

    SEND (local connection name, buffer address, byte
    count, PUSH flag, URGENT flag [, timeout])

    I want to know how can I use it in my application.
    I am preparing a utility which will dows the TCP ping.

    If someone can provode any sample code... It will be heartly welcomed.

    Regards
    Vishal
    In a C or C++ program, you would use the timeout in the select() or pselect() call. There is no timeout settings on open(), socket(), or send() functions in the C APIs. Are you familiar with C programming in general, and TCP/IP programming in C in particular? If not, then you have a pretty big learning curve to get up.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    You can also do this sort of stuff with various scripting languages such as Perl and Python, or you can use something like Java. You would need to read the reference docs for those languages to determine how to accomplish your goal with regard to a "ping" clone.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  4. #4
    Just Joined!
    Join Date
    May 2009
    Posts
    4

    Help on TCP IP Time Wait state!

    Hi All!

    In a tcp connection its a four way teardown. My question is when there is fin sent by the client for termination and client goes down abruptly. Now again a new connection is initiated from the same port but server now would have got a fin earlier for the same port and now getting syn packet for the same port. My question is will the server accept this and establish connection or it will not and discard this syn packet ?.

    Thanks
    Balaji

  5. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Quote Originally Posted by kbalaji12 View Post
    Hi All!

    In a tcp connection its a four way teardown. My question is when there is fin sent by the client for termination and client goes down abruptly. Now again a new connection is initiated from the same port but server now would have got a fin earlier for the same port and now getting syn packet for the same port. My question is will the server accept this and establish connection or it will not and discard this syn packet ?.

    Thanks
    Balaji
    I suppose the answer would have to be "it depends". If it is accepting connections on that port, then it depends upon whether it has the resources to handle another connection. The other one may still be "live" in its eyes - that is something for the programmer to decide. So, if it can handle another connection, then it will accept the request and open the session socket, otherwise it will reject it.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #6
    Just Joined!
    Join Date
    May 2009
    Posts
    4
    Quote Originally Posted by Rubberman View Post
    I suppose the answer would have to be "it depends". If it is accepting connections on that port, then it depends upon whether it has the resources to handle another connection. The other one may still be "live" in its eyes - that is something for the programmer to decide. So, if it can handle another connection, then it will accept the request and open the session socket, otherwise it will reject it.
    So, even if the server is still in FIN_WAIT2. Since there is a syn packet for connection from the same port accepting the connection/rejecting is in the sole discretion of programmer rt ?. So standard doesn't say anything on that ?

  7. #7
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,695
    No, the same port cannot be used. If the server closes down a TCP connection, the port goes into TCP_WAIT state. This is a pre-defined timeout that has to expire before the port is used again.

    The "defacto" standard for the timeout is 240 sec. On high traffic machines that burn through many ports, this is commonly reduced to make ports available more quickly.

  8. #8
    Just Joined!
    Join Date
    May 2009
    Posts
    4
    Quote Originally Posted by HROAdmin26 View Post
    No, the same port cannot be used. If the server closes down a TCP connection, the port goes into TCP_WAIT state. This is a pre-defined timeout that has to expire before the port is used again.

    The "defacto" standard for the timeout is 240 sec. On high traffic machines that burn through many ports, this is commonly reduced to make ports available more quickly.
    Accept that the port cann't be used but I can generate a similar packet and push it across rt?. So just want to understand what would be the behaviour if received so ? is it undetermined ?

  9. #9
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    It depends upon the server. The accept() function will take any number of connection requests on a port. If the server isn't using accept(), but some other method to accept (sic) incoming connections, then that's another story. The server typically uses accept() on a port to get connection requests, which returns a session socket, forks off a sub-process or thread to handle the session, and goes back to accepting more connections. By programmer specifications, I refer to the listen() function, which tells the TCP/IP stack how many active connections can be handled, or if it has received the connection socket, it can terminate it if necessary because of exhausted resources.

    As for what the "standard" says, I'd have to reference my White Book for the RFC on that. No time right now. Do you have the DDN White Book? If so, let me know where it gets explicit about how a server handles connections. The protocols are pretty flexible in that regard, I think, as long as the state transitions are clear.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  10. #10
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Quote Originally Posted by HROAdmin26 View Post
    No, the same port cannot be used. If the server closes down a TCP connection, the port goes into TCP_WAIT state. This is a pre-defined timeout that has to expire before the port is used again.

    The "defacto" standard for the timeout is 240 sec. On high traffic machines that burn through many ports, this is commonly reduced to make ports available more quickly.
    This is for session ports, not for the port that is accepting connections. There is some misunderstanding here, I think. You are correct. The same connection port cannot be used until it is cleared/terminated. Servers typically use accept() for TCP stream connections, which returns a socket bound to another port, and it can receive any number of connection requests, with a backlog set by listen(). However, the server will not likely reuse a port that has a partially terminated connection. At least that has been my experience.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...