TCP Three-Way Handshake: Spot the Valid State Claim
System DesignModel answerLast 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
CLOSEDstate. - The passive opener (server) begins in the
LISTENstate, 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?
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Correct Answer: C
There is a real window of time during the handshake where the client has already reached ESTABLISHED but the server has not yet left SYN_RCVD. This is a direct consequence of the asymmetric timing built into the three-way handshake.
Full State Walkthrough
Tracing both sides step by step makes the answer clear.
Step 1 — Client sends SYN
- Client:
CLOSED→SYN_SENT - Server: still in
LISTEN
Step 2 — Server receives SYN, sends SYN-ACK
- Server:
LISTEN→SYN_RCVD - Client: still in
SYN_SENT
Step 3 — Client receives SYN-ACK, sends ACK
- Client:
SYN_SENT→ESTABLISHED← client is done here - Server: still in
SYN_RCVD, waiting for the ACK to arrive
Step 4 — Server receives the ACK
- Server:
SYN_RCVD→ESTABLISHED
The gap between step 3 and step 4 is exactly the in-flight propagation time of that final ACK. During that window, option C is true: the client is ESTABLISHED, the server is SYN_RCVD. This asymmetry is why a server-side application may not be able to read data sent by the client immediately after the client's connect() call returns — the kernel on the server side still has work to do.
Why Each Wrong Option Is Wrong
Option A contains two independent errors.
First, SYN_SENT is a client state. It means "I have sent a SYN and am waiting for a SYN-ACK." The server never enters SYN_SENT during a normal handshake (only in the unusual simultaneous-open case, which the problem explicitly excludes). After receiving the client's SYN, the server enters SYN_RCVD, not SYN_SENT.
Second, 2MSL has nothing to do with receiving a SYN. It belongs to the TIME_WAIT state during connection teardown, not connection establishment. No 2MSL timer is started when a SYN arrives.
Option B gets the trigger wrong.
The server enters SYN_RCVD after receiving the client's SYN (the first segment), not after receiving the client's ACK (the third segment). By the time the server receives the final ACK, the server is already in SYN_RCVD and that ACK is what moves it out of SYN_RCVD into ESTABLISHED. Option B has the timing exactly backwards.
Option D misidentifies both the mechanism and the endpoint.
When the server does not receive the final ACK, it does not enter TIME_WAIT. Instead, it retransmits the SYN-ACK a limited number of times (controlled by tcp_synack_retries on Linux, typically 5). If no ACK arrives after all retransmissions, the connection attempt is abandoned and the half-open entry is removed from the SYN queue — no TIME_WAIT, no 2MSL wait.
TIME_WAIT is a state entered by the active closer during teardown (the four-way FIN exchange), not by either side during establishment. Its purpose is to let any delayed duplicates of segments from the closing connection expire before the port tuple can be reused. It has no role in the three-way handshake.
Where 2MSL Actually Applies
2MSL appears exactly once in a standard TCP connection lifecycle: the active closer (the side that sends the first FIN) enters TIME_WAIT after sending its final ACK to the passive closer's FIN. It stays in TIME_WAIT for 2 × MSL (commonly 60–120 seconds in practice) before moving to CLOSED. The two reasons are:
- Give the final ACK time to reach the other side and allow the other side's possible retransmitted FIN to arrive and be answered.
- Ensure old duplicate segments from this connection can't be mistaken for segments of a new connection on the same 4-tuple.
A common mistake on this topic is confusing TIME_WAIT with any kind of establishment-phase behavior, or assuming both sides enter it symmetrically — only the active closer does.
Common Mistakes to Avoid
- Swapping
SYN_SENTandSYN_RCVDby forgetting which side initiates. - Thinking
ESTABLISHEDis reached simultaneously by both endpoints — the client always gets there one RTT before the server. - Associating 2MSL with SYN processing rather than with FIN processing.
- Assuming the server "closes" a half-open connection via
TIME_WAITrather than through SYN-ACK retransmission timeout.