Skip to content
We areTOP 1%

How does TCP use a sliding window for flow control?

MediumConceptFlow & Congestion Control
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

A sliding window lets the sender transmit several segments before waiting for acknowledgements, instead of one at a time. The window is the range of bytes the sender may have in flight; it slides forward as ACKs arrive, and its size is capped by the receiver's advertised window (rwnd).

  • Each ACK states the next byte the receiver expects and how much buffer space it has free. If the receiving application reads slowly, the advertised window shrinks.
  • A zero window pauses the sender, which then sends small window probes until the receiver reopens the window.
  • Throughput can never exceed window ÷ RTT. With the classic 64 KB maximum window and a 100 ms RTT, that is 65,535 × 8 bits ÷ 0.1 s ≈ 5.2 Mbps, which is why TCP added the window scale option for fast, long links.

Example: The receiver advertises a 4,000-byte window and each segment carries 1,000 bytes.

Send bytes 1-4000 (4 segments)   window full, sender waits
ACK 2001, window 4000            bytes 1-2000 delivered; window slides to 2001-6000
Send bytes 4001-6000             in flight: 2001-6000
ACK 6001, window 0               receiver buffer full; sender pauses and probes

More in Flow & Congestion Control

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account