Labs / Networking

TCP Congestion Control

Simulate TCP Reno and Tahoe. Watch the congestion window grow, hit ssthresh, and react to packet loss.

New to this? There\'s a lesson below ↓
← BACK TO LABS
Cwnd Over Time (Simulation)
X-Axis: Time (RTT)   |   Y-Axis: Congestion Window (MSS)
Configuration & Metrics
CURRENT PHASE: SLOW START
CWND (MSS)
1.0
SSTHRESH
16
PACKETS SENT
0
PACKETS LOST
0
What's happening?

Slow Start: cwnd doubles every RTT. (Exponential growth).

Congestion Avoidance: Once cwnd >= ssthresh, cwnd grows by 1 MSS per RTT. (Linear growth).

Triple Dup ACK: Indicates mild congestion. ssthresh = cwnd/2. TCP Reno enters Fast Recovery (cwnd = ssthresh + 3). TCP Tahoe drops cwnd to 1.

Timeout: Indicates severe congestion. cwnd drops to 1 MSS, ssthresh = cwnd/2, restart Slow Start.

The lesson

TCP Congestion Control: Slow Start, Congestion Avoidance, and AIMD

How TCP probes network capacity with cwnd and ssthresh, and why TCP Reno and Tahoe react differently to Triple Duplicate ACKs vs. Timeouts.

1. Flow Control vs. Congestion Control

A TCP sender limits how many unacknowledged bytes it can have in flight at any moment using two distinct windows:

  • Flow Control (rwnd — Receive Window): Advertised by the receiver in every ACK header so the sender does not overflow the receiver's socket buffer.
  • Congestion Control (cwnd — Congestion Window): Maintained by the sender so it does not overload intermediate routers and links in the network.

The sender's effective window is min(cwnd, rwnd). Because standard IP routers do not tell endpoints their available link capacity, TCP must probe the network dynamically using cwnd (measured in multiples of MSS — Maximum Segment Size) and infer congestion from packet loss.

2. Slow Start and Congestion Avoidance

Set PACKET LOSS PROBABILITY (%) = 0 in the simulator above, click RESET, and click TICK (1 RTT) 7 times. Watch CWND (blue line) relative to the Slow Start Threshold (ssthresh, red dashed line, initially 16 MSS):

PhaseConditionGrowth RulePer-RTT Trajectory (from cwnd = 1, ssthresh = 16)
Slow Startcwnd < ssthreshcwnd += 1 MSS on every ACK received → doubles every RTT (exponential)1 → 2 → 4 → 8 → 16
Congestion Avoidancecwnd ≥ ssthreshcwnd += 1/cwnd MSS per ACK → +1 MSS per RTT (linear / additive increase)16 → 17 → 18 → 19…

Why is exponential growth called "Slow Start"? Because starting at cwnd = 1 MSS is much slower than immediately blasting a full receive window on the first RTT; doubling each RTT lets the sender quickly discover the order-of-magnitude capacity before switching to cautious linear probing at ssthresh.

3. Reacting to Loss: Timeout vs. 3 Duplicate ACKs (Tahoe vs. Reno)

TCP detects packet loss in two ways, which signal very different levels of network congestion:

  • Retransmission Timeout (RTO — Severe Congestion): The sender transmits a window of segments and receives no ACKs before its timer expires. The network path may be completely congested.
  • Triple Duplicate ACK (3 Dup ACKs — Mild Congestion): Segment k is lost, but subsequent segments k+1, k+2, k+3 still arrive at the receiver! Each out-of-order arrival triggers an immediate duplicate ACK requesting segment k. Receiving 3 duplicate ACKs triggers Fast Retransmit (resending segment k immediately without waiting for the timeout timer).

Compare how TCP Tahoe (1988) and TCP Reno (1990) respond in the simulator using the FORCE 3 DUP ACKs and FORCE TIMEOUT buttons:

Loss EventNew ssthreshTCP Tahoe ActionTCP Reno Action
Timeout⌊cwnd / 2⌋cwnd = 1 MSS, enter Slow Startcwnd = 1 MSS, enter Slow Start
3 Duplicate ACKs⌊cwnd / 2⌋cwnd = 1 MSS, enter Slow StartFast Recovery: cwnd = ssthresh + 3, then continue in Congestion Avoidance (halving the window instead of resetting to 1)

4. AIMD Sawtooth and Bandwidth Fairness

In steady state under TCP Reno, Congestion Avoidance increases cwnd linearly by +1 MSS per RTT (Additive Increase), and Triple Duplicate ACKs cut cwnd in half (Multiplicative Decrease). This AIMD rule produces the classic sawtooth graph when you click AUTO-RUN.

Why AIMD guarantees fairness across competing flows: Suppose Flow A has cwnd = 30 and Flow B has cwnd = 10 sharing a bottleneck router. During Additive Increase, both add +1 per RTT (gap stays 20). When the bottleneck drops a packet, Multiplicative Decrease halves both windows to 15 and 5 — shrinking the gap from 20 to 10! Repeated AIMD cycles provably converge competing flows toward an equal share of bottleneck bandwidth.

Exercises

1. Set Packet Loss to 0%, click RESET, and click TICK (1 RTT) until CWND = 20. Now click FORCE 3 DUP ACKs under TCP Reno, then repeat under TCP Tahoe. Compare the resulting SSTHRESH, CWND, and Phase.

Show solution
At cwnd = 20, both set ssthresh = 20 / 2 = 10.
• TCP Reno: Enters Fast Recovery with cwnd = 10 + 3 = 13.0, then transitions to Congestion Avoidance on the next ACK.
• TCP Tahoe: Treats 3 Dup ACKs the same as a Timeout, resetting cwnd = 1.0 and re-entering Slow Start.

2. Starting from cwnd = 1 and ssthresh = 16 with zero packet loss, how many RTT ticks does it take for cwnd to reach 20 MSS?

Show solution
• RTTs 1–4 (Slow Start doubling): 1 → 2 → 4 → 8 → 16 (reaches ssthresh after 4 RTTs).
• RTTs 5–8 (Congestion Avoidance +1/RTT): 16 → 17 → 18 → 19 → 20 (4 more RTTs).
Total = 8 RTTs. Verify in the simulator by clicking TICK 8 times at 0% loss.

Quiz

How does cwnd grow during the Slow Start phase?

Under TCP Reno, if cwnd = 24 MSS when 3 Duplicate ACKs arrive, what are the new values of ssthresh and cwnd?

Why does TCP treat a Retransmission Timeout more severely than 3 Duplicate ACKs?

Why does AIMD (Additive Increase, Multiplicative Decrease) converge competing TCP flows to fair bandwidth shares?