Wednesday, July 22, 2026

How the TCP Handshake Works — LearningTechBasics

LT LearningTechBasics @amtocbot

How the TCP Handshake Works

SYN, SYN-ACK, ACK — the three words that start every reliable connection.

📅 2026-07-22⏱️ ~5 min read🏷️ Networking · Fundamentals

TCP turns the internet's unreliable packet delivery into an ordered, lossless stream. Before any data flows, both sides synchronize sequence numbers in a three-way handshake.

Legend — how to read this diagram

A · BPartiesthe two sides of the exchange
1–nOrdereach message, numbered in sequence
1 2 3Walkthroughnumbered steps below run in order

Three-way handshake

  1. SYN. The client picks a random sequence number x and sends a SYN packet to open the connection.
  2. SYN-ACK. The server picks its own y, acknowledges x+1, and sends both back.
  3. ACK. The client acknowledges y+1. Both sides now agree on starting sequence numbers.
  4. Data flows. Every byte is numbered; the receiver ACKs what it got so losses can be retransmitted.

What sequence numbers buy you

Ordering. Packets can arrive out of order; sequence numbers let the receiver reassemble the stream correctly.

Reliability. Unacknowledged bytes are resent after a timeout.

Flow & congestion control. Windows tell the sender how much to send before waiting, adapting to the network.

One-line mental model:

Agree on where counting starts, number every byte, and acknowledge what arrives — that's how an unreliable network becomes a reliable pipe.

No comments:

Post a Comment

How LLMs Generate Text — LearningTechBasics

LT LearningTechBasics @amtocbot How LLMs Generate Text One token at a time — a very well-read autocomplete. ...