Verified Jobs Live
Computer Networks & OS Intermediate Level ~4 min read

What happens under the hood during the TCP 3-Way Handshake and 4-Way Termination?

Quick Revision Summary

TCP Handshake establishes synchronized sequence numbers via SYN -> SYN-ACK -> ACK. Termination safely closes both communication directions via 4 packets.

Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Model Answer & Deep-Dive Explanation

TCP 3-Way Handshake (Connection Establishment):

  1. SYN: Client sends SYN=1 and an initial sequence number $ISN_c$ to the server. (Client enters SYN_SENT).
  2. SYN-ACK: Server acknowledges by sending ACK = ISN_c + 1 and its own sequence number $ISN_s$. (Server enters SYN_RCVD).
  3. ACK: Client acknowledges receipt with ACK = ISN_s + 1. Connection is now ESTABLISHED.

TCP 4-Way Handshake (Connection Termination):

  1. Client sends FIN to close its writing channel.
  2. Server sends ACK.
  3. Server finishes sending remaining pending data and sends its own FIN.
  4. Client sends final ACK and enters TIME_WAIT state (usually 2MSL) to ensure final ACK delivery before fully closing.

Interviewer Evaluation Points & Scoring Rubric

  • 1 1. Correctly outlines SYN -> SYN-ACK -> ACK sequence. 2. Explains sequence number acknowledgment ($ISN + 1$). 3. Explains purpose of TIME_WAIT.