Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
TCP — The Reliable Stream  ›  Lesson

Data Transfer — ACKs, Resends and Waiting in Line

Data Transfer 12 minTCP numbers every byte, resends whatever is not acknowledged, and delivers bytes strictly in order, so one lost segment holds back everything that arrived after it.

Data Transfer — ACKs, Resends and Waiting in Line

An early Manja Arena prototype sent kite positions over TCP. On good Wi-Fi it felt fine. On a crowded café network, kites froze for a moment and then leapt forward all at once. Nothing was broken: TCP was keeping exactly the promise it makes.

The rule

Every byte numbered, every gap resent, nothing skips the queue.

  • Every byte numbered. Sequence numbers count bytes, not messages, so the receiver always knows exactly which bytes it holds.
  • Every gap resent. The receiver's acknowledgment names the next byte it is waiting for. If no acknowledgment covers some data before a timer runs out, the retransmission timeout, the sender sends that data again. It resends sooner if it receives three duplicate acknowledgments: the receiver asking for the same missing byte again and again while later segments keep arriving. That early resend is called fast retransmit.
  • Nothing skips the queue. TCP hands bytes to your program strictly in order. Segments that arrive after a gap wait in the receive buffer until the gap is filled. This is head-of-line blocking.

A plain acknowledgment can only say "I have everything before byte N". Selective acknowledgment (SACK), an option both sides agree to during the handshake, lets the receiver add "and I also hold these later blocks", so the sender resends only the hole instead of everything after it.

For lobby chat, all of this is exactly right: every line arrives, in the order it was typed. For kite positions it is poison. A position from 50 ms ago is worthless once a newer one exists, yet TCP makes the newer one wait until the old one has been resent, which costs at least a round trip.

The shortcut

Track two things: what has arrived and what the program may read. The program may read only up to the first gap, and the acknowledgment number points at that same spot: the first missing byte.

Five segments, one lostStep 1 of 4
  1. Send

    The server sends five 100-byte segments: bytes 0–99, 100–199, 200–299, 300–399 and 400–499.

Drills

Answer fast — trust the rule.

quick drill

A receiver holds bytes 0–499 with no gaps. What acknowledgment number does it send?

quick drill

Bytes 0–99 and 200–299 have arrived, but 100–199 was lost. What can the program read right now?

quick drill

What does selective acknowledgment (SACK) add to plain acknowledgments?

quick drill

A sender receives three duplicate acknowledgments, all saying 100. What does it do?

quick drill

Why does head-of-line blocking hurt kite positions more than lobby chat?

Remember

  • Every byte numbered, every gap resent, nothing skips the queue.
  • The program can read up to the first gap, and the acknowledgment points at it.
  • Trap: sending state that is replaced every tick over TCP. One loss freezes everything behind it.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWhy did the kites freeze and leap?

Explain, in terms of TCP data transfer, why the Manja Arena prototype's kites froze and then leapt forward on a lossy café network, and why the very same behaviour is exactly right for lobby chat.