TCP Congestion Control
Simulate TCP congestion control mechanisms. Watch packets flow and observe Slow Start, Congestion Avoidance, and Fast Retransmit phases. Experiment with packet loss, latency
Continue with the guided workspace
Use the paired workspace to connect this guide's mental model with live component state, visible signals, and the outcome each step or scenario is meant to prove.
Transmission Control Protocol (TCP) shares one network path among many senders, so without congestion control the routersβ buffers fill and the network collapses. TCP instead probes for available bandwidth: it opens the window quickly at first (Slow Start), then creeps up linearly (Congestion Avoidance), and backs off sharply the moment it detects loss β additive increase, multiplicative decrease β so the network stays stable as senders come and go.
Mental Model
Think of TCP Congestion Control like driving a car in heavy fog. When you start (Slow Start), you accelerate quickly to see how fast you can go. Once you reach a speed where visibility gets sketchy (the threshold ssthresh), you accelerate very slowly (Congestion Avoidance). If you tap another carβs bumper (3 duplicate ACKs), you tap the brakes and cut your speed in half (Fast Retransmit/Recovery). If you hit a brick wall and come to a complete stop (Retransmission Timeout), you must shift back into first gear and start driving at 5 mph again (cwnd = 1).
Components and Why They Exist
Sender Node
The source of data transmission that dynamically calculates network capacity to avoid overwhelming the link. Tracks state variables like Congestion Window (cwnd) and Slow Start Threshold (ssthresh), adapting the transmission rate based on incoming ACKs. In the demo, observe the Sender scaling its window size up during Slow Start and throttling it back when packet loss occurs.
Router (Bottleneck Link)
Represents the network path constraint with finite queue buffers and throughput capacity. Forwards packets to the destination and buffers bursts of traffic; drops packets (drop-tail) when the queue buffer limit is exceeded. In the demo, notice that monitor the router queue filling up and observe packet drop events when the queue capacity is exceeded.
Receiver Node
The destination endpoint that consumes payloads and informs the sender of delivery status. Sends cumulative ACKs back to the sender and triggers duplicate ACKs if out-of-order packets are received. In the demo, watch the Receiver return ACKs and observe the arrival of duplicate ACKs when a packet is dropped.
Edge Cases and Misconceptions
- Bufferbloat: Increasing router buffer sizes to prevent packet loss backfires. Large buffers delay packets rather than dropping them, causing latency (RTT) to spike massively before a drop is finally detected, ruining real-time applications.
- Congestion vs. Link Loss: TCP assumes all packet loss is caused by network congestion (buffer overflow). On wireless links, packets are often lost due to RF interference. Traditional TCP handles this poorly by cutting its congestion window, reducing throughput unnecessarily.
- Fast Retransmit is not a Timeout: When the sender receives 3 duplicate ACKs, it retransmits the missing packet immediately and enters Fast Recovery (
cwnd = ssthresh). It does not resetcwndto 1, avoiding the severe performance hit of a full retransmission timeout (RTO).
Common Questions
What is the difference between TCP Flow Control and TCP Congestion Control?
Flow control protects the receiver from being overwhelmed by a fast sender (using the Advertised Window field in ACKs). Congestion control protects the intermediate network routers from buffer overflow (using the sender's internal Congestion Window `cwnd`).
How does TCP distinguish between mild congestion and severe congestion?
Mild congestion is signaled by receiving 3 duplicate ACKs (Fast Retransmit), where TCP halves `cwnd`. Severe congestion is signaled by a Retransmission Timeout (RTO) where no ACKs are received, causing TCP to reset `cwnd` to 1 and wait for the network to clear.
Why does the Congestion Window double in Slow Start but increase linearly in Congestion Avoidance?
Slow Start exists to quickly claim idle network capacity by doubling the transmission rate every round-trip time (RTT). Once the window approaches the estimated limit (`ssthresh`), TCP switches to Congestion Avoidance to carefully probe for additional bandwidth without risking immediate buffer overflow.
What is AIMD (Additive Increase Multiplicative Decrease)?
It is the mathematical feedback loop of TCP. It increases `cwnd` slowly (additively) to probe for bandwidth, but drops it sharply (multiplicatively, by halving it) upon detecting loss. This ensures network stability and prevents congestion collapse.
What triggers a Retransmission Timeout (RTO) versus Fast Retransmit?
Fast Retransmit is triggered when 3 duplicate ACKs arrive at the sender, indicating that subsequent packets made it to the receiver but one packet in the middle was lost. An RTO occurs when no ACKs arrive at all within a calculated time window (typically when the entire tail of a window is lost), forcing a full pause and reset.
How does TCP calculate the Retransmission Timeout (RTO) dynamically?
TCP tracks the Round Trip Time (RTT) of sent packets to compute a smoothed RTT (SRTT) and RTT variation (RTTVAR). A common estimator starts with SRTT + 4 * RTTVAR, then applies implementation-specific minimums, maximums, and clock-granularity rules. The formula is an estimator, not an exact wire-level constant.
What is the slow start threshold (ssthresh)?
ssthresh is the target limit that determines when TCP should transition from exponential window growth (Slow Start) to linear window growth (Congestion Avoidance). When packet loss occurs, ssthresh is updated to half of the current cwnd.