TCP Handshake Simulator

Runs in browser

Visualize the 3-way handshake

Network Conditions

0%
500ms

Connection Engine

Did you know?

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

State CLOSED

Server

State CLOSED

Connection Logs

Waiting for connection...

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:

Step 1: SYN (Synchronize)

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."

Step 2: SYN-ACK (Synchronize-Acknowledge)

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."

Step 3: ACK (Acknowledge)

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:

LISTEN

The server is waiting for an incoming connection request on a specific port.

SYN_SENT

The client has sent a SYN and is waiting for a matching connection request from the server.

ESTABLISHED

The open connection is ready to transfer data. This is the goal of the handshake.

TIME_WAIT

The connection is closed, but we wait to ensure the remote host received the final ACK.

References & Deep Dives