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?

Explore Related Topics

1

Interfacing Bluetooth and Zigbee with the 8051 Microcontroller

The course explains how to interface Bluetooth (HC‑05) and Zigbee (XBee) modules with an 8051 microcontroller using its UART, covering hardware connections, voltage‑level considerations, UART initialization, and module configuration.

  • UART on the 8051 is set with SCON = 0x50, TMOD = 0x20, TH1 = 0xFD and Timer 1 for 9600 baud with an 11.0592 MHz crystal.
  • HC‑05 operates at 3.3 V TTL; connect TX/RX crosswise and add a level‑shifter on the 8051 TX line.
  • XBee also needs 3.3 V logic; use transparent mode for simple serial pass‑through or API mode for framed packets with addressing.
  • Bluetooth provides a point‑to‑point serial bridge, whereas Zigbee adds PAN IDs, coordinator/end‑device roles, and multi‑node networking.
  • Typical firmware flow: initialize UART → receive bytes → parse commands → control outputs → transmit acknowledgments (API mode adds frame parsing and checksum).
2

Optimizing Web Performance with HTTP/3

HTTP/3 boosts web performance by replacing TCP with QUIC over UDP, enabling 0‑RTT handshakes and eliminating head‑of‑line blocking.

  • Uses QUIC transport, so firewalls must allow UDP on port 443.
  • Consolidates TLS and transport setup into a single round trip, reducing RRTRRT compared to HTTP/1.1/2.
  • Deploy via Alt‑Svc headers after confirming load balancers, CDNs, and proxies support QUIC.
  • Monitor for QUIC greasing and MTU issues, as UDP packets can be throttled or dropped.
3

Computer Network

A computer network is a packet‑switched system that interconnects devices to exchange data using layered protocols such as OSI/TCP‑IP, enabling addressing, routing, and a range of services across different scopes.

  • Core concepts: encapsulation/decapsulation, bandwidth, latency, with transfer time ≈ Data SizeBandwidth+Latency\frac{\text{Data Size}}{\text{Bandwidth}}+\text{Latency} and throughput ≤ min(Access Link Rate,Path Bottleneck Rate)\min(\text{Access Link Rate},\text{Path Bottleneck Rate}).
  • OSI (7 layers) and TCP/IP (4 layers) models map functions from physical signaling up to application protocols (e.g., HTTP, DNS).
  • Addressing hierarchy: MAC for local delivery, IP for routing, DNS for name resolution, DHCP for automatic configuration, and NAT for private‑public translation.
  • Transport choices: TCP provides reliable, ordered delivery with congestion control; UDP offers low‑overhead, best‑effort delivery for latency‑sensitive apps.
  • Security fundamentals include firewalls, VPNs, TLS, and access controls, which must be balanced against performance and usability.