In: Computer Science
Actually, when connection termination is required in TCP a FIN packet is sent. Normally,
the user will send a FIN and wait till its own FIN is acknowledged and then deletes the
connection.
So far, a connection termination make use of four-way handshake protocol. When a node
wishes to stop its half of the connection, it transmits a FIN packet while the other node
acknowledges with an ACK. Certainly, simultaneous connection termination is possible,
when both the TCP nodes transmit FIN packet simultaneously.
Connection termination requires a pair of FIN and ACK segments from each TCP
endpoint. When the section that sent the initial FIN has responded with the final ACK, it
waits for a timeout before closing the connection, during which the local ports are
unavailable for new connections.
Initiator node was the first one to send the first FIN, before the receiver node, thereby
making the initiator node to go into TIMEWAIT state.