ELEC3506

Topics

Transport LayerLecture 7 PDF20 min

TCP congestion control

How congestion control differs from flow control, how the congestion window grows through slow start and congestion avoidance, and how TCP reacts differently to a timeout than to three duplicate ACKs.

By the end of this page you should be able to

  • Distinguish what flow control guarantees from what congestion control guarantees
  • State the actual-window-size formula and explain why it takes the minimum of cwnd and rwnd
  • Trace how cwnd grows during slow start and how that differs from congestion avoidance
  • State what happens to ssthresh and cwnd after a timeout versus after three duplicate ACKs, and why the two responses differ

The idea

Flow control, from the previous topic, keeps a fast sender from overrunning one specific receiver’s buffer. It says nothing about the routers and links in between, which can be shared by many connections at once and can overflow even when every receiver is keeping up fine. That separate failure mode — the network itself getting overloaded — is what congestion control exists to manage.

How it works

Flow control vs. congestion control

Flow control guarantees the receive window is never overflowed — no congestion at the receiving end. It does not guarantee the intermediate buffers inside the network stay clear; those can still be overflowed. Congestion control is the set of mechanisms and techniques used to control congestion and keep the network’s load below its capacity.

How it works

The congestion window

cwnd, the congestion window, has its value determined by the congestion situation in the network — separately from rwnd, which the receiver sets based on its own buffer. Together, cwnd and rwnd define the size of the send window.

Actual send window
cwnd
Congestion window, set by the sender based on network conditions
rwnd
Receive window, set by the receiver based on its buffer

How it works

Congestion control categories

  • Open loop — prevent congestion before it happens.
  • Closed loop — alleviate congestion after it has already happened.

How it works

TCP's three phases

TCP’s general policy for handling congestion runs through three phases: slow start, congestion avoidance, and congestion detection.

How it works

Phase 1 — slow start (exponential increase)

cwnd starts at one maximum segment size (MSS), or some other starting number, and increases by one MSS each time an ACK arrives — until cwnd reaches the slow-start threshold (ssthresh). Because every ACK received increases cwnd, and more segments are in flight each round, cwnd effectively doubles every RTT: this is exponential growth in terms of round-trip times.

Slow start growth
n
Number of round-trip times elapsed since slow start began

Worked example

Slow start's exponential growth

  1. Start: cwnd = 1 (2⁰).

  2. After 1 RTT: cwnd = cwnd + 1 = 2 (2¹).

  3. After 2 RTT: cwnd = cwnd + 2 = 4 (2²).

  4. After 3 RTT: cwnd = cwnd + 4 = 8 (2³).

  5. After n RTT: cwnd = cwnd + 2^(n−1) = 2^n.

AnswerAfter n RTT, cwnd = 2^n.

How it works

Phase 2 — congestion avoidance (additive increase)

Once ssthresh is reached, cwnd’s growth switches from exponential to additive: if an ACK arrives, cwnd = cwnd + n, growing linearly in terms of round-trip times, until congestion is detected.

Congestion avoidance growth
i
Congestion window size when congestion avoidance began
n
Number of round-trip times elapsed since congestion avoidance began

Worked example

Congestion avoidance's linear growth

  1. Start: cwnd = i.

  2. After 1 RTT: cwnd = i + 1.

  3. After 2 RTT: cwnd = i + 2.

  4. After 3 RTT: cwnd = i + 3.

  5. After n RTT: cwnd = i + n.

AnswerAfter n RTT, cwnd = i + n, where i is the window size when this phase began.

How it works

Phase 3 — congestion detection

Congestion is detected two ways, and TCP reacts differently to each:

By timeout (no ACKs received at all). A stronger sign of congestion, so TCP acts strongly:

  • Sets the threshold (ssthresh) to one-half the current window size.
  • Sets cwnd to 1 MSS (or whatever the starting value is).
  • Restarts slow start from the beginning.

By three duplicate ACKs (some ACK is missing, but most segments are still arriving). A weaker sign of congestion, so TCP acts weakly:

  • Sets the threshold (ssthresh) to one-half the current window size.
  • Sets cwnd to the threshold’s new value directly.
  • Starts congestion avoidance, skipping slow start entirely.

The fast retransmit covered in the previous topic — triggered by the same three-duplicate-ACK condition — is the retransmission half of this response; the ssthresh and cwnd adjustment above is the congestion-control half.

TimeoutThree duplicate ACKs
Signal strengthStrong — nothing is getting throughWeak — most segments are arriving
ssthreshHalf the current windowHalf the current window
cwndReset to 1 MSSSet to the new ssthresh
Next phaseSlow start, from scratchCongestion avoidance, directly
Both halve ssthresh — what differs is how far cwnd falls and which phase TCP resumes in, matching how confident TCP is that the network is actually congested.

Where marks get lost

Duplicate ACKs do not reset cwnd all the way to 1

It is tempting to treat both congestion-detection triggers the same way, since both halve ssthresh. They do not do the same thing to cwnd: a timeout drops cwnd to 1 MSS and restarts slow start; three duplicate ACKs drop cwnd only to the new ssthresh and go straight into congestion avoidance. Confusing the two loses the distinction the lecture is testing.

Aside

The slides’ complete state-transition diagram for TCP’s congestion policy — covering states A through E and the transitions between them — did not survive extraction. Only the three named phases and the two detection triggers above are given directly in the source.

How it works

A partial worked example

The lecture sets up one numeric scenario: cwnd grows exponentially from slow start; at cwnd = 12, some ACKs go missing, giving ssthresh = 12 / 2 = 6; at cwnd = 20, all ACKs go missing, giving ssthresh = 20 / 2 = 10.

Aside

This example’s own numeric trace does not fully survive extraction, and the transition list the slide gives is not internally consistent with the general rule stated above: the general rule says a timeout (all ACKs missing) resets cwnd to 1 MSS and restarts slow start, but the slide’s own transition list for the “all ACKs missing” step names “congestion avoidance window” as the outcome instead. This page does not attempt to reconcile that inconsistency or invent the missing numeric trace — apply the general rule above (stated directly and unambiguously) rather than this example’s own last step if the two conflict on an exam question.

In the exam

  • Flow control protects the receiver’s buffer; congestion control protects the network’s. A question that conflates the two is testing exactly this distinction.
  • Actual window size = min(cwnd, rwnd). State the formula and identify which of the two is the binding constraint in a given scenario.
  • Slow start doubles cwnd every RTT (2^n); congestion avoidance adds one per RTT (i + n). Know which formula applies in which phase.
  • Timeout vs. triple duplicate ACK is the exam-favourite pair. Both halve ssthresh. Only a timeout resets cwnd to 1 MSS and restarts slow start; three duplicate ACKs set cwnd to the new ssthresh and go straight to congestion avoidance.
  • Fast retransmit and the congestion-control response to triple duplicate ACKs happen together, triggered by the same event, but they are two different mechanisms — one resends data, the other adjusts cwnd/ssthresh.

Check yourself

  • Flow control stops the receiver’s buffer overflowing; congestion control stops the network’s buffers overflowing — not the same guarantee.
  • The actual send window is always the smaller of cwnd and rwnd.
  • Slow start grows cwnd exponentially (2^n per RTT) up to ssthresh; congestion avoidance then grows it additively (i + n per RTT).
  • A timeout is congestion control’s strong response: halve ssthresh, reset cwnd to 1 MSS, restart slow start. Three duplicate ACKs are the weak response: halve ssthresh, set cwnd to that new threshold, go straight to congestion avoidance.

Check yourself

  1. A sender's cwnd is 20 segments and the receiver's rwnd is 12 segments. What is the actual window size the sender can use?
  2. A receive window that never overflows still does not guarantee an uncongested network. Why not?
  3. During slow start, cwnd begins at 1 MSS. What is cwnd after 3 round-trip times, assuming all ACKs are received and ssthresh is not yet reached?
  4. TCP detects congestion via a timeout, with the window at 16 segments when it happens. What does TCP do?
  5. TCP detects congestion via three duplicate ACKs, with the window at 16 segments when it happens. What does TCP do differently from the timeout case?