ryuu
ryuu

Reputation: 57

TCP TIME_WAIT State

Assume that I got a server runs a daytime service.

Then I use telnet to connect this daytime server, the server send time data and close the connection, now, since the server is the active close side which is supposed to enter TIME_WAIT state.

So why can I do telnet to the daytime service immediately after the last telnet while the server should be still in TIME_WAIT state ?

Upvotes: 2

Views: 2827

Answers (2)

paxdiablo
paxdiablo

Reputation: 881463

The states belong to a session. A session is a 5-tuple consisting of the source IP/port, destination IP/port and transport type (such as TCP or UDP). If the limitation was just based on the server side properties, that would pretty much make the internet unusable (think of only one search being allowed on Google every four minutes or so).

So, provided you don't use the same 5-tuple, you can start a new session immediately. In other words, even though you may connect from the same source IP to the same destination IP and port, your source port will almost certainly be different.

Hence it will be a different session, one that won't be in the the wait state.

Most clients will typically use zero as the port number when creating a session, which is an indication to the communications stack that it should assign an arbitrary/random/available port for the session.

Upvotes: 1

user207421
user207421

Reputation: 310911

The server isn't in TIME_WAIT state. The prior connection between the source/destination IP:port is in TIME_WAIT state, which means you can't reuse that tuple. But the client will always use a new outbound port by default, so a new tuple. So you can connect immediately.

Otherwise TCP/IP, the Internet, this site, etc., wouldn't work at all.

Upvotes: 0

Related Questions