Back to the 2015 paper

Module 4: Transport Layer & Congestion Control

20157m

Explain connection establishment in TCP using three-way handshaking.

Worked SolutionAI Assisted

TCP Connection Establishment — Three-Way Handshake

TCP is connection-oriented, so a logical connection must be established before data transfer. Connection establishment uses a three-way handshake in which both sides exchange SYN and ACK segments and agree on initial sequence numbers (ISNs).

Message exchange

        Client                                  Server
     (first)                                   (second)
        |                                         |
        | ---- (1) SYN, seq = x ---------------> |   SYN bit = 1
        |                                         |   ISN = x chosen by client
        | <--- (2) SYN+ACK, seq = y, ack = x+1 -- |   SYN bit = 1, ACK bit = 1
        |                                         |   ISN = y chosen by server
        | ---- (3) ACK, seq = x+1, ack = y+1 --> |   ACK bit = 1
        |                                         |
        |        ===== CONNECTION ESTABLISHED === |   both in ESTABLISHED state

Description of each step

  1. Step 1 — Connection request (SYN): The client picks an initial sequence number x and sends a segment with SYN = 1 and no data (SYN segments consume one sequence number). The client enters SYN-SENT state.
  2. Step 2 — Connection accepted (SYN + ACK): The server acknowledges by sending SYN = 1, ACK = 1, its own ISN y, and ack = x + 1 (acknowledging the client's SYN). The server enters SYN-RECEIVED state.
  3. Step 3 — Acknowledgement (ACK): The client sends ACK = 1, seq = x + 1, ack = y + 1, acknowledging the server's SYN. Both sides now enter ESTABLISHED and normal data transfer begins.

Why three segments?

  • It lets both sides agree on and acknowledge each other's initial sequence numbers (needed for reliability and flow control).
  • It guarantees that both ends are ready to receive — a two-way handshake cannot resolve the problem of old duplicate connection requests still roaming the network (the classic two-way handshake failure case); with three-way handshake, the server replies with a SYN-ACK containing a new ISN, and stale duplicates cannot be accepted.
  • It also synchronises timing parameters (maximum segment size, window scale, timestamps) exchanged in the SYN options.

Note on simultaneous open

TCP also supports simultaneous connection establishment: if both sides send SYN at the same time, both move to SYN-SENT and then answer each other's SYN with SYN+ACK — still converging in three segments to ESTABLISHED.

Result: After exactly three segments (SYN → SYN+ACK → ACK) the connection is established, and only then is application data exchanged.

Similar questions

AI LearningWeb Platform

Coursify — Personal AI Course Generator

Struggling with a difficult subject or concept? Turn any engineering topic into a structured course with interactive lessons, quizzes, and research-backed explanations.