TCP Handshake Simulator
Runs in browserVisualize the 3-way handshake
Network Conditions
Connection Engine
The 3-way handshake adds exactly 1.5 RTT of latency before data can be sent. This is why latency is the #1 killer of web performance.
Client
Server
Connection Logs
TCP: The Workhorse of the Internet
The Transmission Control Protocol (TCP) is arguably the most important protocol in existence. While IP (Internet Protocol) handles routing packets from point A to point B, IP makes absolutely no guarantees that packets arrive, arrive in order, or arrive intact. TCP is the layer built on top of IP that provides an illusion of a perfectly reliable, continuous, ordered stream of bytes over a fundamentally chaotic, lossy network.
1. Connection Establishment (The 3-Way Handshake)
Before a single byte of application data (like an HTTP GET request) can be sent, TCP must first establish a connection. This is where the famous 3-Way Handshake occurs. Its primary goal is to securely synchronize Sequence Numbers and negotiate connection parameters (like Maximum Segment Size and Window Scaling).
The Dance of SYN and ACK:
The Client wants to connect. It generates a totally random 32-bit Initial Sequence
Number (e.g., ISN_c = 4000). It sends a TCP segment to the Server with
the SYN flag set.
Translation: "Hi Server, I want to talk. I will start numbering my bytes at
4000."
The Server receives the SYN. It generates its own random Initial Sequence Number
(e.g., ISN_s = 8000). It replies with a segment that has both
SYN
and ACK flags set. It acknowledges the client's ISN by setting the ACK
number to ISN_c + 1 (4001).
Translation: "I hear you, Client. I await your byte #4001. By the way, I will
start numbering my bytes at 8000."
The Client receives the SYN-ACK. It sends back one final ACK segment,
acknowledging the Server's ISN by setting the ACK number to
ISN_s + 1 (8001).
Translation: "Got it, Server. I'm ready. I await your byte #8001. Let's send
data!"
2. Major Transition States
TCP is a Finite State Machine. Every socket on your computer is in one of these states at any given moment:
The server is waiting for an incoming connection request on a specific port.
The client has sent a SYN and is waiting for a matching connection request from the server.
The open connection is ready to transfer data. This is the goal of the handshake.
The connection is closed, but we wait to ensure the remote host received the final ACK.
References & Deep Dives
- High Performance Browser Networking (O'Reilly) - Ilya Grigorik's masterpiece.
- RFC 9293: Transmission Control Protocol - The modern, consolidated specification for TCP.