The TCP Handshake, visualized

Every reliable connection on the internet begins with a three-way handshake and ends with a graceful four-way teardown. Watch the packets flow, inspect the flags, and follow the state transitions in real time.

Layer 5 — Session / Transport
Controls
Speed
Packet flow
💻
Client
CLOSED
Port 52430 →
🖥️
Server
LISTEN
← Port 443
Packet log
Press Play or Step to begin
Sequence / Ack tracker

Client → Server

SEQ
ACK
Flags

Server → Client

SEQ
ACK
Flags

What this proves

Three-Way Handshake

TCP establishes connections using SYN, SYN-ACK, and ACK. The client sends a synchronize request with an initial sequence number, the server acknowledges and sends its own, then the client confirms.

Sequence Numbers

Every byte in a TCP stream is numbered. The SEQ field marks the first byte being sent, and ACK confirms the next byte expected from the other side. This ensures ordered, reliable delivery.

State Machine

TCP endpoints track connection state: CLOSED → SYN_SENT → ESTABLISHED on the client side, LISTEN → SYN_RCVD → ESTABLISHED on the server. Each transition is triggered by a specific packet.

Graceful Teardown

Closing requires four packets: each side sends FIN independently and receives ACK. This allows half-close — one side can stop sending while still receiving data.

TCP Flags

SYN initiates a connection. ACK acknowledges received data. FIN signals the sender is done. RST aborts immediately. Flags are bit fields in the TCP header — a single packet can carry multiple flags.

Why This Matters

Every HTTP request, database query, and API call travels over a TCP connection. Understanding the handshake explains latency (1 extra RTT before data flows), connection pooling, and why TIME_WAIT exists.