This might be a general TCP question.
Can I receive TCP SYN
packet on an ESTABLISHED
connection OR a connection in TIME-WAIT
state?
Is this possible?
This might be a general TCP question.
Can I receive TCP SYN
packet on an ESTABLISHED
connection OR a connection in TIME-WAIT
state?
Is this possible?
A SYN
received on an ESTABLISHED
TCP connection should not be happening. It could be a delayed packet, which it would be safe to silently drop.
It is possible to end up with the server in ESTABLISHED
state and client in CLOSED
state if the connection is lost and is timed out on the client and not on the server, or if the client is restarted. Attempting to open a new connection in this scenario would cause a SYN
packet to be received in ESTABLISHED
state. The desired outcome is that the old connection is closed and a new is opened.
The way this desired outcome is achieved is as follows:
SYN
to create a new connection.ACK
for the ESTABLISHED
connection.ACK
with a RST
packet causing the ESTABLISHED
connection to go away.SYN
packet to create a new connection.A SYN
packet received in TIME_WAIT
state can happen after the server has closed the connection, and the client opens a new connection with same port numbers. This will cause a new connection to be opened.
Neither...SYN
is only used when the connection is first set up (the three-way handshake) or when the packet is destroyed.
Basically:
SYN (I want to start a connection) -> ACK/SYN (OK, I want to start a connection too) -> ACK (acknowledged connection, ready for data)
Conversation flows with ACK
packets sent by both hosts indicated they recieved each others packets.
At the end, FIN
is sent to the server and TIME_WAIT
is set on the socket. When the server responds with a FIN
packet, the socket is released.