Octet

What is the TCP sliding window, and how is flow control different from congestion control?

Show the answer

Say this first

The receiver advertises a receive window in every segment: how many more bytes it has buffer space for. The sender may have at most the smaller of that receive window and its own congestion window sent but not yet acknowledged. As ACKs arrive the window slides forward and more data can go. Flow control protects the receiver and is driven by the receiver's advertised window. Congestion control protects the network and is the sender's private estimate, the congestion window, which never appears in a packet.

Go deeper

The picture

Output
bytes:  | acked | sent, not acked | can send now | cannot send yet |
                ^ SND.UNA         ^ SND.NXT      ^ SND.UNA + window

Usable window = min(rwnd, cwnd) minus bytes in flight. When the receiver's application reads data, the receiver advertises a bigger window. When the sender gets ACKs, SND.UNA moves right.

Why it bounds throughput

A sender can put at most one window of data on the wire per round trip, so one flow's throughput is at most window / RTT. That single formula explains most "fast link, slow transfer" tickets.

Who sets what

ControlVariableSet byVisible in packets
Flow controlrwndReceiver, from free bufferYes, Window field
Congestion controlcwndSender's algorithmNo

Traps

  • Saying the window is counted in segments. The advertised window is in bytes (after scaling).