← Lessons

quiz vs the machine

Gold1400

Networking

TCP Flow Control and the Sliding Window

How a receiver stops a fast sender from overrunning its buffer.

5 min read · core · beat Gold to climb

The problem flow control solves

A fast sender can easily outpace a slow receiver, overflowing the receiver buffer and forcing dropped data. Flow control lets the receiver tell the sender exactly how much it can accept, so it is a receiver driven brake, distinct from congestion control which reacts to the network.

The sliding window

TCP attaches a receive window field to every segment, advertising how many more bytes of buffer space are free. The sender may have at most that many unacknowledged bytes in flight.

  • As the receiver application reads data, buffer space frees up and the advertised window grows.
  • As acknowledgements arrive, the sender slides its window forward and can transmit more.
  • If the receiver buffer fills, it advertises a window of zero and the sender pauses.

When the window hits zero the sender periodically sends a small window probe so it learns the moment space reopens, avoiding a deadlock where an updated window advertisement was lost. The window mechanism also enables high throughput, since many bytes can be outstanding at once instead of one segment at a time.

Key idea

The sliding window lets a receiver advertise free buffer space so a fast sender never overruns it.

Check yourself

Answer to earn rating on the learn ladder.

1. What does the TCP receive window advertise?

2. Why does a sender send window probes after a zero window?