Communication Networks · Visualized

TCP 3-Way Handshake

Transport Reliability

TCP connections, retransmission timers and sliding windows that make lossy links behave.

6 interactive subtopics — each one animated, step-through and explained.

TCP 3-Way Handshake

Transport Reliability

Before TCP moves one data byte, both endpoints synchronise initial sequence numbers and buffer sizes. The three-message handshake proves both directions work, seeds the numbering used to detect loss, and negotiates options like window scaling — all before the application payload begins.

How TCP 3-Way Handshake Works

  1. Client sends SYN with random ISN x — “I want to talk; I’ll count from x.”
  2. Server replies SYN-ACK carrying its own ISN y and ACK = x+1 — “heard you; I start at y.”
  3. Client answers ACK = y+1 — both sides now consider the connection ESTABLISHED.
  4. Sequence numbers increment per byte, which is how ACKs acknowledge exact ranges.
  5. Closing repeats the dance with FIN/ACK from both sides (four steps).

TCP 3-Way Handshake Worked Example

Try it: Play — watch seq/ack counters appear on each arrow as the connection opens, transfers, and closes cleanly.

SYN(seq=100) → SYN-ACK(seq=500, ack=101) → ACK(ack=501). The GET rides seq 101; the server’s reply acknowledges it and pushes its own bytes forward.

CLIENTSERVERSYN seq=100
client → server server → client
Stage 1 / 6
Client → SYN carrying a random ISN 100: “I want to talk; my byte counter starts at 100.” Client state: SYN_SENT.

TCP 3-Way Handshake: Key Facts to Remember

Why three?two messages cannot let both sides confirm both directions
SYN floodhalf-open connections exhaust server tables — mitigated by SYN cookies
Modern TLSruns immediately after the handshake; TLS 1.3 fits within 1-RTT

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses

See how packets really travel

Networks are built on the structures and algorithms you can watch step by step — queues, trees, and routing algorithms.