KatInterview

TCP Three-Way Handshake: Spot the Valid State Claim

System DesignModel answer
MediumModel answerSystem DesignnetworkingTCPstate-machine

Last updated

Identify the one correct statement about TCP connection-establishment state transitions and explain why the other three are wrong.

TCP Connection Setup: One Statement Is True

TCP uses a three-way handshake to establish a reliable connection. Each endpoint moves through a defined sequence of states as segments are exchanged. Understanding exactly which state each side occupies at each step is essential for diagnosing connection issues, writing correct network code, and reasoning about race conditions in distributed systems.

Background

  • The active opener (client) initiates the connection from the CLOSED state.
  • The passive opener (server) begins in the LISTEN state, waiting for incoming requests.
  • The three segments exchanged are: SYN (client → server), SYN-ACK (server → client), ACK (client → server).
  • MSL (Maximum Segment Lifetime) is the maximum time a segment can survive in the network. 2MSL is twice that value and appears at specific points in the TCP state machine.

Assume standard TCP per RFC 793 / RFC 9293. No TCP Fast Open, no TCP_DEFER_ACCEPT, and no simultaneous-open scenario. The client is always the active opener; the server is the passive opener.

The Question

Exactly one of the following statements about TCP connection establishment is correct. Identify which one, and explain precisely why each of the remaining three is wrong.

A. After the server receives the client's initial SYN segment, it enters the SYN_SENT state and starts a 2MSL timer.

B. The server transitions into the SYN_RCVD state after it receives the client's final ACK segment.

C. There is a window in time during the handshake where the client is already in the ESTABLISHED state while the server is still in the SYN_RCVD state.

D. If the server never receives the client's final ACK segment, it enters TIME_WAIT and waits 2MSL before closing the connection.

What is expected

  • State which option is correct.
  • Walk through the full state sequence for both endpoints across all three handshake steps.
  • Give a precise rebuttal for each incorrect option, identifying the specific error in its reasoning.
  • Explain where 2MSL actually applies in the TCP lifecycle.

Hints

Hint 1

Trace both endpoints step by step: what state does each side enter after sending or receiving each of the three segments?

Hint 2

SYN_SENT and SYN_RCVD sound symmetric, but which side sends the first SYN, and which side receives it?

Hint 3

2MSL is a real TCP mechanism — but it belongs to connection teardown, not connection establishment. Which state and which endpoint does it actually apply to?