Explain connection establishment in TCP using three-way handshaking.

Explain connection establishment in TCP using three-way handshaking.

Verified Sources
Sep 12, 2026

Connection establishment in TCP uses the Three-Way Handshake to reliably set up a connection before any application data is transmitted. The handshake coordinates initial sequence numbers (ISNs), establishes synchronization of sender/receiver state, and transitions both peers into the ESTABLISHED state in the TCP finite state machine.2

The core idea is summarized by the exchange:

At the end of this process:

  • Both sides have acknowledged each other’s SYN and therefore agreed on synchronized sequence numbers.
  • Each side is ready to start sending data using reliable delivery over a shared connection.2

Footnotes

  1. RFC 793 - Transmission Control Protocol (TCP) https://www.rfc-editor.org/rfc/rfc793 - Defines TCP sequence number behavior and connection establishment concepts including SYN/SYN-ACK/ACK. ↩ ↩2

  2. RFC 9293 - TCP Specifications (obsoletes RFC 9293/updates) https://www.rfc-editor.org/rfc/rfc9293 - Describes the TCP state machine and connection establishment behavior. ↩

  3. RFC 5681 - Congestion Control for TCP (and broader TCP reliability concepts) https://www.rfc-editor.org/rfc/rfc5681 - Background on TCP acknowledgment/sequence-driven reliability needed once a connection is established. ↩

TCP Three-Way Handshake (SYN, SYN-ACK, ACK) Explained

Three-Way Handshake: Message-by-Message Connection Setup

  1. 1
    Step 1

    The client chooses an initial sequence number (ISN) for its side and sends a SYN segment to the server. This is effectively “I’m starting; my initial sequence number is x.”

    Footnotes

    1. RFC 793 - Transmission Control Protocol (TCP) https://www.rfc-editor.org/rfc/rfc793 - Defines TCP sequence number behavior and connection establishment concepts including SYN/SYN-ACK/ACK. ↩

  2. 2
    Step 2

    Upon receiving the SYN, the server replies with a SYN-ACK segment: it acknowledges the client’s SYN (ACK = x+1) and includes its own ISN (y) to synchronize the server’s starting sequence number.2

    Footnotes

    1. RFC 793 - Transmission Control Protocol (TCP) https://www.rfc-editor.org/rfc/rfc793 - Defines TCP sequence number behavior and connection establishment concepts including SYN/SYN-ACK/ACK. ↩

    2. RFC 9293 - TCP Specifications (obsoletes RFC 9293/updates) https://www.rfc-editor.org/rfc/rfc9293 - Describes the TCP state machine and connection establishment behavior. ↩

  3. 3
    Step 3

    After receiving the SYN-ACK, the client sends an ACK acknowledging the server’s SYN (ACK = y+1). When the server receives this ACK, both endpoints transition to ESTABLISHED.2

    Footnotes

    1. RFC 9293 - TCP Specifications (obsoletes RFC 9293/updates) https://www.rfc-editor.org/rfc/rfc9293 - Describes the TCP state machine and connection establishment behavior. ↩

    2. RFC 5681 - Congestion Control for TCP (and broader TCP reliability concepts) https://www.rfc-editor.org/rfc/rfc5681 - Background on TCP acknowledgment/sequence-driven reliability needed once a connection is established. ↩

What gets acknowledged?

The handshake’s ACK values typically acknowledge the SYN as consuming one sequence number: client’s SYN is acknowledged with ACK=x+1ACK = x + 1, and server’s SYN is acknowledged with ACK=y+1ACK = y + 1.

Footnotes

  1. RFC 793 - Transmission Control Protocol (TCP) https://www.rfc-editor.org/rfc/rfc793 - Defines TCP sequence number behavior and connection establishment concepts including SYN/SYN-ACK/ACK. ↩

Sequence numbers and why SYN consumes space

TCP delivers a byte stream and labels each byte with a sequence number so that retransmissions and reordering can be handled deterministically. During the handshake, each SYN is treated as taking up one sequence number in order to let the final ACK precisely confirm that the peer received the synchronization segment. This design lets TCP avoid ambiguity about “what data has been received” at connection start.2

State transitions (high level)

During establishment, the TCP implementation follows a state machine whose key states include:

  • SYN-SENT on the client after its SYN
  • SYN-RECEIVED on the server
  • ESTABLISHED once both sides have acknowledged each other’s SYN and are ready for data.

Footnotes

  1. RFC 793 - Transmission Control Protocol (TCP) https://www.rfc-editor.org/rfc/rfc793 - Defines TCP sequence number behavior and connection establishment concepts including SYN/SYN-ACK/ACK. ↩

  2. RFC 5681 - Congestion Control for TCP (and broader TCP reliability concepts) https://www.rfc-editor.org/rfc/rfc5681 - Background on TCP acknowledgment/sequence-driven reliability needed once a connection is established. ↩

  3. RFC 9293 - TCP Specifications (obsoletes RFC 9293/updates) https://www.rfc-editor.org/rfc/rfc9293 - Describes the TCP state machine and connection establishment behavior. ↩

Handshake Timeline (relative ordering)

A compact view of message causality: each later step depends on receiving the previous step.

Important nuances and edge cases

From Idle to Data Transfer

Passive/Active open

T0

Server is listening; client initiates with a SYN."

Client → Server: SYN

T1

Client proposes ISN x and requests synchronization."

Server → Client: SYN-ACK

T2

Server proposes ISN y and acknowledges x+1."

Client → Server: ACK

T3

Client acknowledges y+1; both sides become ESTABLISHED."

First data segments

T4

Application data may now flow with synchronized sequence numbers."

Knowledge Check

Question 1 of 4
Q1Single choice

In the three-way handshake, what does the server’s SYN-ACK generally carry?