Congestion & Flow Control

the congestion window

Think of the congestion window as a self-imposed speed limit that a TCP sender sets for itself based on how busy it thinks the road is. The receiver also imposes a limit (the receive window, so it is not overrun), but the congestion window is the sender's own guess about how much the NETWORK can take. The sender always obeys whichever of the two limits is smaller — it is allowed to drive only as fast as both the road and the destination can handle.

Concretely, the congestion window, written cwnd, is a number the sender keeps that caps how many unacknowledged bytes (or packets) may be in flight on the path at once. Each round trip, those packets go out, their acknowledgments come back, and the sender adjusts cwnd: it grows it during slow start (doubling) and congestion avoidance (adding one packet's worth), and shrinks it on a congestion signal (halving on triple duplicate ACKs, or crashing to one packet on a timeout). Because the data in flight is roughly cwnd, and that data takes one round-trip time to be acknowledged, a flow's throughput is approximately cwnd divided by the round-trip time. Bigger window, faster flow — up to what the link can bear.

The congestion window is the single most important state variable in TCP congestion control, yet it lives entirely on the sender and is never sent on the wire — unlike the receive window, which the receiver advertises in every segment. Everything you have read about slow start, congestion avoidance, AIMD, and fast recovery is ultimately a story about how cwnd is raised and lowered over time. Watching cwnd plotted against time is watching TCP think.

On a path with a 50 ms round-trip time, if cwnd is 100 packets of 1500 bytes each, the sender can have about 150,000 bytes in flight, and its throughput is roughly 150,000 bytes / 0.05 s = 3,000,000 bytes/s, about 24 Mbps. Double cwnd to 200 and (if the link allows) throughput roughly doubles too. This cwnd-over-RTT relationship is why high-speed long-distance links need large windows.

Throughput is roughly cwnd / RTT, so the sender controls its speed by adjusting one private number.

Do not confuse the congestion window (cwnd, the sender's estimate of what the NETWORK allows, never transmitted) with the receive window (rwnd, what the RECEIVER advertises in every segment). The sender's actual sending limit is min(cwnd, rwnd). For a long bulk transfer over the open Internet, cwnd is almost always the binding constraint.

Also called
cwnd壅塞視窗擁塞視窗