4.3.20 · D4Computer Networks

Exercises — TCP reliability — seq - ack numbers, retransmission, cumulative ACK

2,599 words12 min readBack to topic

Every symbol used here is already earned in the parent note, but let us re-anchor the three that appear constantly, because you must never guess what they mean:

The picture below is the mental model behind almost every exercise: bytes laid out on a number line, with a moving "everything-below-here-is-safe" boundary.

Figure — TCP reliability — seq - ack numbers, retransmission, cumulative ACK

Level 1 — Recognition

(Can you read the numbers correctly?)

L1.1 A segment has SEQ and carries bytes of data. Which byte positions does it cover, and what SEQ should the next in-order segment use?

Recall Solution L1.1

Using the interval rule : That means bytes — the last byte is , not (the right end is excluded). The next in-order segment starts right after, at

L1.2 A receiver has contiguously received the byte stream up to and including byte . What ACK number does it send?

Recall Solution L1.2

ACK is the next byte expected = highest contiguous byte : Read it as: "I have everything below ; send byte next."

L1.3 During the handshake a client sends a SYN with ISN . What ACK number does the server put in its reply?

Recall Solution L1.3

The SYN flag consumes one sequence number (it is treated as one phantom byte at position ). So the highest thing "received" is , and the next expected is This is exactly why a fresh connection's data starts at , not .


Level 2 — Application

(Can you run the machinery on a stream?)

L2.1 Sender transmits four 100-byte segments starting at SEQ : A, B, C, D. All arrive in order. List every ACK the receiver sends.

Recall Solution L2.1

After each in-order arrival, the highest contiguous byte jumps by 100, and ACK that :

Arrives covers highest contiguous byte ACK
A
B
C
D
So the ACK sequence is .

L2.2 Same four segments, but B is lost; A, C, D all arrive. List every ACK the receiver sends, in order.

Recall Solution L2.2

A fills the prefix → ACK . Then C and D arrive but there is a hole at bytes , so the highest contiguous byte is still . The receiver buffers C and D but cannot advance the boundary:

  • A → ACK
  • C → still ACK (duplicate #1)
  • D → still ACK (duplicate #2)

ACK sequence: . Two of these are duplicate ACKs.

L2.3 Continuing L2.2, the sender eventually resends B and it arrives. What single ACK does the receiver now send, and why does it "leap"?

Recall Solution L2.3

B fills the last hole. Now A, B, C, D are all contiguous, up to byte : It leaps from to in one message because cumulative ACK reports the whole contiguous prefix at once — filling the single hole at B instantly connects the buffered C and D.


Level 3 — Analysis

(Can you reason about timers, duplicates, and why loss is inferred?)

L3.1 A sender measures three RTT samples in a row: all equal to ms. Before them, ms and ms. Using , , compute SRTT, RTTVAR, and RTO after these samples. What RTO results?

Recall Solution L3.1

Each update uses:

\text{RTTVAR} \leftarrow (1-\beta)\,\text{RTTVAR} + \beta\,|\text{SRTT}-R|.$$ With every sample equal to the current SRTT ($100$ ms), each update leaves both unchanged: $$\text{SRTT} = \tfrac{7}{8}(100) + \tfrac{1}{8}(100) = 100,\qquad \text{RTTVAR} = \tfrac{3}{4}(0) + \tfrac{1}{4}|100-100| = 0.$$ So after all three samples $\text{SRTT}=100$, $\text{RTTVAR}=0$, and $$\text{RTO} = \text{SRTT} + 4\cdot\text{RTTVAR} = 100 + 4\cdot 0 = 100 \text{ ms}.$$ **Insight:** when the network is perfectly steady, variance collapses to $0$ and RTO hugs the RTT.

L3.2 Now one jittery sample arrives: ms, starting from , . Compute the new SRTT, RTTVAR, and RTO.

Recall Solution L3.2

For RTTVAR, use the old SRTT deviation (standard TCP updates RTTVAR using the SRTT before this sample's SRTT update): Insight: one spike more than tripled the RTO. The term deliberately over- reacts to jitter so the sender waits longer and avoids declaring a false loss. (See RTT estimation / Jacobson's algorithm.)

L3.3 In L2.2 the receiver sent three ACKs all equal to (one original + two duplicates). How many duplicate ACKs is that, and does the standard fast retransmit rule fire?

Recall Solution L3.3

The first (after A) is the original ACK. The next two are duplicates → 2 duplicate ACKs. Fast retransmit needs 3 duplicate ACKs (4 identical ACKs total). With only 2 duplicates the threshold is not reached, so fast retransmit does not fire — the sender would have to wait for the RTO timer instead. If one more out-of-order segment arrived to produce a 3rd duplicate , fast retransmit would trigger.


Level 4 — Synthesis

(Can you assemble the full loss-recovery story yourself?)

L4.1 Segments A, B, C, D, E each carry 100 bytes. B is lost; A, C, D, E all arrive out of order after A. Trace the full sequence of ACKs, decide whether fast retransmit fires, and give the final ACK after B is resent.

Recall Solution L4.1
  • A arrives → contiguous to → ACK (original).
  • C arrives → hole at B → ACK (dup #1).
  • D arrives → still hole → ACK (dup #2).
  • E arrives → still hole → ACK (dup #3).

That is 3 duplicate ACKs for fast retransmit fires: the sender resends the segment at SEQ (that is B) immediately, without waiting for RTO.

  • B arrives → now A,B,C,D,E all contiguous, up to byte → ACK .

Full ACK trace: . One retransmission repaired the whole gap.

L4.2 Suppose instead the network merely reordered B and C (B not lost, just late): A, C, B, D all arrive, B arriving right after C. Show why the receiver never needs a retransmission here, and give every ACK.

Recall Solution L4.2
  • A → ACK .
  • C → hole at B → ACK (dup #1). Only one duplicate so far.
  • B → hole filled, and C is already buffered → contiguous to → ACK .
  • D → contiguous to → ACK .

ACK trace: . Only 1 duplicate ACK appeared — below the threshold of 3 — so fast retransmit never fires and nothing is resent. This is exactly why the rule waits for 3 duplicates: a single reorder should not be mistaken for loss.


Level 5 — Mastery

(Can you design, and defend the design against its limits?)

L5.1 A stream sends 10 segments , each 100 bytes, starting at SEQ . Segments and are both lost; all others arrive in order. Using only cumulative ACKs (no SACK), count how many total retransmissions are needed in the worst case where each recovery only fixes the single lowest hole, and explain why cumulative ACK is inefficient here.

Recall Solution L5.1

Byte layout: covers . So and .

  • arrive → ACK advances to .
  • lost. arrive → all produce duplicate ACK (contiguous stuck at ).
  • Sender resends (at SEQ ). It fills the first hole → contiguous now jumps to byte (because were buffered) → ACK . That is retransmission #1.
  • lost. arrive → duplicate ACK .
  • Sender resends (SEQ ) → fills the second hole → contiguous to → ACK . That is retransmission #2.

Total retransmissions = 2 (one per hole). Cumulative ACK's inefficiency: while the sender waited for the ACK to unstick, it could not tell which higher segments were already safely buffered — the single number (then ) hid the fact that (and later ) were fine. A naïve Go-Back-N sender that reacts to a duplicate ACK by resending everything from the hole onward would resend needlessly. This ambiguity is the precise motivation for Selective ACK (SACK).

L5.2 Design argument: your teammate proposes replacing cumulative ACK with "ACK the exact last byte received" to save the confusing . Give one concrete failure scenario that breaks their scheme, and one property of cumulative ACK their scheme loses.

Recall Solution L5.2

Failure scenario (lost ACK): With cumulative ACKs, if an ACK is lost it is self-healing — the next ACK carries a larger number that supersedes it, so no information is permanently lost. "ACK the exact last byte received" loses this: if the receiver ACKs byte and that ACK is lost, the sender never learns arrived; and because there is no "everything-below" semantics, a later ACK of, say, byte does not confirm that arrived. The sender cannot deduce the prefix. Property lost: cumulativeness — a single number can no longer summarize an entire contiguous prefix, so one ACK can no longer cover many segments, and a lost ACK is no longer automatically repaired by the next. (Also they'd reintroduce the off-by-one bug the was designed to prevent: the sender must still figure out the next byte to send, i.e. last , so the never actually goes away.)


Recall One-line self-test recap

Cumulative ACK means what, exactly? ::: The receiver has every byte below contiguously and wants byte next. How many duplicate ACKs trigger fast retransmit? ::: Three (i.e. 4 identical ACKs total). Why does the ACK "leap" when a hole is filled? ::: Cumulative ACK reports the whole contiguous prefix, so filling one hole connects all the buffered segments after it. In Jacobson's algorithm, RTTVAR uses the deviation from which SRTT? ::: The old SRTT, before this sample updates it.