Four-Way Handshake
It is a method used by TCP to CLOSE a connection
Steps
active host, passive host
Active Host | State | Passive Host | State |
---|---|---|---|
1. Send FIN | FIN_WAIT_1 | ||
2. Send ACK | CLOSE_WAIT | ||
3. Wait for Server FIN | FIN_WAIT_2 | ||
4. Ready to close, send FIN | LAST_ASK | ||
5. Send ACK | TIME_WAIT | ||
6. Receive ACK | CLOSED | ||
7. Close after double MSL time | CLOSED |
TIME_WAIT
Wait for double maximum segment life(MSL) time
- Ensure the reliability of TCP close
- wait double MSL to make sure the passive host is closed
- otherwise, resend ACK
- Avoid the re-transmission or delay packet having impacts to the new connection
- If there is a new connection with the same IP and PORT just after the connection closed, it may causes errors.