Chapter recap
Chapter 4.3 covered the complete internal machinery of TCP: the 20–60 byte segment header, byte-stream sequence and cumulative ACK numbers, the 3-way handshake and 4-way teardown with TIME-WAIT (2·MSL), flow control via rwnd and window scaling, Jacobson’s EWMA/RTO and Karn’s rule, and TCP Tahoe vs Reno congestion control.
Merged rule card
From 4.3.1 TCP segment header, byte-stream numbering & cumulative ACKs
- TCP Header: 20–60 B (`HLEN × 4`); 16b Src/Dst Ports, 32b Seq #, 32b Ack #, 6 Flags (`URG, ACK, PSH, RST, SYN, FIN`), 16b Window, 16b Checksum.
- Byte numbering: segment at `Seq = S` with L bytes covers `S .. S + L − 1`; receiver sends cumulative `ACK = S + L` (next expected byte).
- `MSS` = max TCP data payload per segment (`MTU − IP_hdr − TCP_hdr`).
From 4.3.2 TCP 3-way handshake, connection termination & state machine
- 3-way handshake:
SYN(seq=x) → SYN+ACK(seq=y, ack=x+1) → ACK(seq=x+1, ack=y+1). - Seq consumption:
SYN = +1,FIN = +1,Pure ACK = 0,Data(L) = +L(full connection advances byD + 2). - Teardown states: Active closer goes
FIN-WAIT-1 → FIN-WAIT-2 → TIME-WAIT (2·MSL) → CLOSED; Passive closer goesCLOSE-WAIT (half-close) → LAST-ACK → CLOSED.
From 4.3.3 TCP flow control (rwnd), sequence wrap-around time & window scaling
- Flow control:
rwnd = RcvBuffer − (LastByteRcvd − LastByteRead); sender keepsBytesInFlight ≤ rwnd. - Zero window (`rwnd = 0`): sender runs Persist Timer and sends 1-byte Zero-Window Probes.
- Wrap-around time:
T_wrap = (2³² × 8) / Bseconds (34.36 s at 1 Gbps). - Window scaling:
True rwnd = HeaderWindow × 2ˢ(S ≤ 14, negotiated inSYN).
From 4.3.4 TCP timeout estimation: EWMA, Jacobson’s algorithm & Karn’s rule
- EWMA:
Est_new = (1 − α)·Est_old + α·Sample = Est_old + (Sample − Est_old)·α(defaultα = 1/8). - Deviation & RTO:
Dev_new = (1 − β)·Dev_old + β·|Sample − Est|(defaultβ = 1/4);RTO = Est + 4·Dev. - Karn's rule: ignore RTT samples from retransmitted segments; double
RTOon each timeout.
From 4.3.5 TCP congestion control: cwnd, Slow Start, AIMD, Tahoe vs Reno
- Effective window:
W = min(cwnd, rwnd). Always trace in units of MSS! - Slow Start (
cwnd < ssthresh):+1 MSSper ACK →cwnd ← min(2·cwnd, ssthresh)per RTT. - Congestion Avoidance (
cwnd ≥ ssthresh):+1 MSSper RTT (AIMD linear growth). - On Loss:
ssthresh ← ⌊cwnd / 2⌋; Timeout →cwnd = 1 MSS; 3 Dup ACKs →cwnd = 1 MSS(Tahoe) orcwnd = ssthresh(Reno).
Practice questions
- NAT · 1 mark
A TCP segment has HLEN (Data Offset) = 9. How many bytes of TCP Options are present in this segment?
Write your answer before opening the key.
- NAT · 2 marks
Host A initiates a TCP connection to Host B with Initial Sequence Number ISN_A = 1000. Host B replies with a SYN-ACK carrying ISN_B = 5000. In the 3rd packet of the handshake (the ACK from A to B), which also carries 200 bytes of application data, what is the Sequence Number (Seq) field?
Write your answer before opening the key.
- MCQ · 1 mark
Why does the active closer in TCP remain in the TIME-WAIT state for 2 × MSL before completely closing the connection?
- To finish Slow Start.
- To allow the final ACK to be retransmitted if lost, and to let all old duplicate segments from this incarnation expire from the network.
- To negotiate the Window Scale option.
- To double the RTO timer.
- NAT · 2 marks
A TCP connection operates at full line rate over a 4 Gbps (4 × 10⁹ bits/sec) link. How many seconds (rounded to 2 decimal places) does it take for the 32-bit sequence number space to wrap around?
Write your answer before opening the key.
- NAT · 2 marks
During the 3-way handshake, a TCP receiver negotiates a Window Scale shift factor of S = 5. Later, it sends an ACK with the 16-bit Window Size field set to 2,000, over a path with RTT = 16 ms. What is the maximum throughput in Mbps permitted by this receive window?
Write your answer before opening the key.
- NAT · 2 marks
A TCP sender has EstimatedRTT = 120 ms and DevRTT = 16 ms. A new un-retransmitted segment produces SampleRTT = 200 ms. Using RFC 6298 defaults (α = 0.125, β = 0.25, updating DevRTT using the old EstimatedRTT = 120 ms), what is the new RTO in ms?
Write your answer before opening the key.
- NAT · 2 marks
A TCP Reno connection has MSS = 2 KB, initial cwnd = 2 KB (1 MSS) at RTT 1, and initial ssthresh = 12 KB (6 MSS). Assuming no losses, what is cwnd in KB during RTT 5?
Write your answer before opening the key.
- NAT · 2 marks
Continuing the previous question (cwnd = 14 KB = 7 MSS in RTT 5, with MSS = 2 KB), suppose a Retransmission Timeout (RTO) occurs at the end of RTT 5. What is the new value of ssthresh in KB?
Write your answer before opening the key.
- MSQ · 2 marks
Which of the following statements about TCP flow control and congestion control are TRUE?
- When rwnd = 0, the sender starts the Persist Timer and sends 1-byte Zero-Window Probes when it expires.
- When a Retransmission Timeout occurs, both TCP Tahoe and TCP Reno reset cwnd to 1 MSS.
- When 3 duplicate ACKs arrive, TCP Reno resets cwnd to 1 MSS whereas TCP Tahoe sets cwnd = ssthresh.
- By Karn’s rule, SampleRTT is never measured from an ACK of a retransmitted segment.
Answer key
Try the questions first. Open when you are ready to check.
- 16 — Total TCP header length = 9 × 4 = 36 bytes. Options = 36 − 20 (base header) = 16 bytes.
- 1001 — A’s SYN consumed sequence number 1000, so the first byte of data in the 3rd handshake packet has Seq = 1001 (and after sending 200 bytes, A’s next sequence number will be 1201).
- B — 2 × MSL ensures (1) the passive closer receives the final ACK (or its retransmission if the FIN is resent), and (2) wandering duplicate segments die out before the socket 4-tuple is reused.
- A: Slow Start occurs at the beginning of data transfer.
- C: Window scaling is negotiated in SYN.
- D: Karn’s timer backoff happens during retransmission timeouts.
- 8.58..8.60 — T_wrap = (2³² × 8) / (4 × 10⁹) = 34.3597 / 4 ≈ 8.59 seconds.
- 32 — True rwnd = 2,000 × 2⁵ = 64,000 bytes = 512,000 bits. Over RTT = 16 ms = 0.016 s, max throughput = 512,000 / 0.016 = 32 × 10⁶ bps = 32 Mbps.
- 258 — Est_new = 120 + (200 − 120)/8 = 130 ms. Dev_new = 0.75(16) + 0.25|200 − 120| = 12 + 20 = 32 ms. RTO = 130 + 4(32) = 130 + 128 = 258 ms.
- 14 — In MSS (1 MSS = 2 KB, ssthresh = 6 MSS): RTT 1 = 1 MSS, RTT 2 = 2 MSS, RTT 3 = 4 MSS, RTT 4 = min(8, 6) = 6 MSS (clamped at ssthresh), RTT 5 = 6 + 1 = 7 MSS = 14 KB.
- 6 — In MSS: cwnd was 7 MSS, so new ssthresh = ⌊7 / 2⌋ = 3 MSS = 3 × 2 KB = 6 KB! (Note: floor is taken in whole MSS segments: ⌊7/2⌋ = 3 MSS = 6 KB).
- ABD — A, B, and D are true. C is backwards: on 3 duplicate ACKs, Tahoe resets cwnd = 1 MSS whereas Reno sets cwnd = ssthresh!
- C: Tahoe resets to 1 MSS; Reno enters Fast Recovery at cwnd = ssthresh.