congestion window (cwnd)
termKept in this browser · My desk
A Transmission Control Protocol (TCP) sender's state variable that caps how much unacknowledged data it may have in the network, raised and cut by congestion control from what losses, delays or marks reveal; the sender uses the smaller of it and the receiver's window.
It is the one number that decides how fast a Transmission Control Protocol (TCP) connection goes once the receiver has room. It starts small, doubles every round trip in slow start, grows by about one segment per round trip in congestion avoidance, and is cut when the sender sees loss: to half the data in flight after three duplicate acknowledgements, to a single segment after a retransmission timeout. Because at most one window is delivered per round trip, throughput is roughly cwnd divided by the round-trip time, which is why the same congestion window gives very different speeds over a short path and a long one, and why one lost segment can cost a long connection seconds of rebuilding.
What it is. Request for Comments (RFC) 5681 (September 2009) defines the congestion window, cwnd, as a TCP state variable that limits the amount of data a TCP can send: at any time a sender must not send data with a sequence number higher than the highest acknowledged sequence number plus the minimum of cwnd and rwnd, the most recently advertised receiver window. The receiver window says how much the other end can take; the congestion window says how much the sender believes the path can take. The amount actually outstanding is FlightSize, the data sent but not yet cumulatively acknowledged, and it can be smaller than both windows when the application has little to send.
Where it came from. Van Jacobson and Michael J. Karels introduced it in Congestion Avoidance and Control (November 1988) in three lines: add a congestion window, cwnd, to the per-connection state; when starting or restarting after a loss, set cwnd to one packet; on each acknowledgement (ACK) for new data, increase cwnd by one packet; and when sending, send the minimum of the receiver's advertised window and cwnd. They noted that this slow-start is not so slow: it takes R log2 W, R being the round-trip time and W the window in packets. The rules later grew into RFC 2001, RFC 2581 and, today, RFC 5681.
The variables around it. RFC 5681 names them all. The sender maximum segment size (SMSS) is the largest segment the sender can transmit. The initial window (IW) is cwnd after the three-way handshake: at most 4 segments when the SMSS is 1,095 bytes or less, 3 when it is between 1,095 and 2,190, and 2 above that, and a single segment if the SYN (synchronize) or the SYN/ACK was lost. RFC 6928 (April 2013, Experimental) raises the bound to min(10*MSS, max(2*MSS, 14600)) bytes, ten segments of 1,460 bytes. The loss window (LW) is cwnd after a loss detected by the retransmission timer, one segment. The restart window (RW) is cwnd after an idle period. The slow start threshold, ssthresh, decides which algorithm runs: slow start while cwnd is below it, congestion avoidance above it, either when they are equal. Its initial value SHOULD be arbitrarily high, for example the largest possible advertised window, so that the network rather than a guess ends the first slow start.
The equations. In slow start, each ACK for new data adds cwnd += min(N, SMSS), equation (2), N being the bytes newly acknowledged; with one ACK per segment the window doubles every round trip. In congestion avoidance the increase is about one SMSS per round trip, commonly cwnd += SMSS*SMSS/cwnd per ACK, equation (3). When loss is detected, ssthresh is set to no more than max(FlightSize/2, 2*SMSS), equation (4); the specification warns that using cwnd instead of FlightSize there is an easy mistake. On the third duplicate ACK the missing segment is retransmitted and cwnd becomes ssthresh plus 3*SMSS, inflated by the three segments that have left the network; each further duplicate ACK adds one SMSS; when an ACK for new data arrives, cwnd deflates to ssthresh and congestion avoidance continues. When the retransmission timer fires instead, cwnd falls to the loss window and slow start starts again up to the new ssthresh. RFC 6582 (April 2012), NewReno, refines recovery for partial acknowledgements when several segments of one window are lost. CUBIC, RFC 9438 (August 2023), keeps cwnd in segments, cuts it by beta_cubic = 0.7 rather than to half, and regrows it along W_cubic(t) = C(t - K)^3 + W_max.
Worked trace. Take an SMSS of 1,460 bytes, a round trip of 50 ms and an initial window of 3 segments. Slow start gives 3, 6, 12, 24 and 48 segments in the first five round trips. One segment of the fifth round is lost and three duplicate ACKs report it: FlightSize was 48 segments, so ssthresh becomes 24; after recovery cwnd is 24 and grows by one per round trip, 25, 26 and so on to 32. Then a retransmission timeout: ssthresh becomes 16, cwnd becomes 1, and slow start climbs 1, 2, 4, 8, 16 before congestion avoidance resumes at 17. The rate in each round is about cwnd x 1,460 x 8 / 0.05 s: 48 segments carry about 11.2 Mbit/s, 24 segments about 5.6 Mbit/s and a single segment about 0.23 Mbit/s, before counting the second or more the timer itself waited.
In practice. On Linux, ss -ti prints for each TCP socket its cwnd, its ssthresh, its congestion algorithm (cong_alg, cubic by default according to the manual) and its round-trip estimate, so the window can be read on a live host instead of inferred from a capture. A capture shows its effect: bursts that double per round trip at the start of a transfer, a burst after each ACK, and the pause after a timeout.
What goes wrong. A window that stays small is not always the network: an application that writes little keeps FlightSize below cwnd. A transfer of a few dozen segments may finish inside slow start, so its speed depends on the initial window and the round trip rather than the link. A timeout costs far more than a fast retransmit: the window goes back to one segment and must be rebuilt. And the congestion window is per connection, so comparing one connection with a tool that opens many measures the tool as much as the path.
Neighbours. Congestion control is the algorithm that moves it; the receiver window is the other limit; the bandwidth-delay product says how large it must be to fill a path; the retransmission timeout decides the worst of its cuts.
Also known as: cwnd, congestion window, janela de congestionamento
Sources
- IETF, RFC 5681, TCP Congestion Control, M. Allman, V. Paxson, E. Blanton, September 2009 (read 2026-11-23): definitions of cwnd, rwnd, IW, LW, RW, FlightSize and SMSS; the IW bounds; equations 2, 3 and 4; fast retransmit and fast recovery steps; the initial ssthresh arbitrarily high
- Van Jacobson and Michael J. Karels, Congestion Avoidance and Control, November 1988 (read 2026-11-23): add a congestion window, cwnd, to the per-connection state; one packet at start or after a loss; one more per ACK; send the minimum of the receiver's advertised window and cwnd; slow-start takes R log2 W
- IETF, RFC 6928, Increasing TCP's Initial Window, April 2013, Experimental (read 2026-11-23): min(10*MSS, max(2*MSS, 14600)), a change from RFC 3390's two to four segments
- IETF, RFC 9438, CUBIC for Fast and Long-Distance Networks, August 2023 (read 2026-11-23): cwnd, ssthresh, W_max and K defined in segments; the window function and beta_cubic 0.7
- IETF, RFC 6582, The NewReno Modification to TCP's Fast Recovery Algorithm, April 2012 (read 2026-11-23): RFC 5681's four intertwined algorithms and the modifications it explicitly allows, partial acknowledgements during recovery
- Linux man-pages, ss(8) (read 2026-11-23): ss -i shows cwnd, ssthresh, cong_alg (default cubic), rto, rtt/rttvar and wscale per TCP socket