← Concepts

阅读中文版本

TCP Congestion Window

The TCP congestion window caps how many unacknowledged bytes a sender may have in flight, growing on delivery and collapsing on loss, and it often dominates throughput on long routes.

http

Definition

The congestion window is a sender-side state variable limiting in-flight data as a defense against network overload. Slow start grows it exponentially until a threshold, congestion avoidance grows it linearly, and loss events shrink it via fast retransmit or a timeout reset. Bandwidth-delay product defines how large the window must be to fill a path.

Context and scope

Explains why uploads start slow then accelerate, why long-distance transfers need window scaling, and why a few concurrent connections can outperform one saturated TCP stream over lossy links.

Common misconceptions

  • Throughput equals link bandwidth — the window and round-trip time bound it long before the link saturates
  • Bigger buffers always help — bloated buffers cause bufferbloat and hide loss feedback
  • Congestion control is a router feature — it is enforced by senders reacting to signals like loss and delay

Anti-patterns

  • Transferring one huge file over a single TCP stream on a high-RTT path and blaming the network for slow throughput
  • Ignoring window scaling or using legacy stacks with small default buffers on fat long pipes
  • Treating packet loss purely as an error to retransmit rather than a congestion signal to react to

Related concepts

Related examples

Authoritative source

https://datatracker.ietf.org/doc/html/rfc5681

What it is

Every TCP sender maintains a congestion window alongside the receiver window, and the effective limit is the smaller of the two. The window is a control loop output: acknowledgments grow it, loss shrinks it. Over a path with a large bandwidth-delay product, a window that is too small starves the link regardless of capacity.

How it works

Slow start doubles the window per round trip until the slow-start threshold, then congestion avoidance adds roughly one segment per round trip. Three duplicate acknowledgments trigger fast retransmit and fast recovery; a timeout is treated as a severe signal and resets the window to a small value. Modern algorithms such as CUBIC and BBR refine these reactions.

When to care

Bulk transfer throughput, database replication lag, and large object uploads are all congestion-window phenomena. Parallel connections open multiple windows and can grab more capacity on lossy paths, which is also why fairness matters. Diagnose with retransmit counts and goodput-versus-bandwidth comparisons.

Pitfalls

Deep queues absorb bursts, delay loss signals, and produce bufferbloat latency spikes. Wireless links drop packets from radio noise, confusing loss-based algorithms that read loss as congestion. BBR models bandwidth and RTT instead of loss, behaving very differently on such paths.