Skip to main content

TCP flow control

Short answer

TCP flow control uses a sliding window governed by the receiver's advertised window (rwnd). The receiver puts its free buffer space in the ACK's window field; the sender limits outstanding bytes to min(rwnd, cwnd). Zero-window probes prevent deadlock, and Clark/Nagle avoid silly window syndrome.

Explain how flow control is done in TCP.

Flow control stops a fast sender from overwhelming a slow receiver. TCP uses a sliding window protocol controlled by the receiver.

Mechanism

  1. TCP is byte-oriented; each byte has a sequence number.
  2. In every ACK, the receiver advertises its receive window (rwnd) = free buffer space, in the 16-bit window size field.
  3. The sender may have at most min(rwnd, cwnd) unacknowledged bytes outstanding. cwnd is the congestion window used for congestion control.
  4. As the application reads data, the receive buffer empties and a larger window is advertised; the window "slides" forward.
  5. If rwnd = 0, the sender stops and sends a small window probe periodically, so it does not wait forever if the update is lost.
Sent+ACKed | Sent, not ACKed | Can send | Cannot send
 ...........|<---------- window --------->|
            ^ left edge moves on ACK     ^ right edge moves on rwnd

Example (receiver buffer 4000 bytes)

Eventrwnd advertised
Connection set up4000
Sender sends 3000 bytes, app has not read1000
Sender sends 1000 bytes0 (sender stops)
Application reads 2000 bytes2000 (sender resumes)

Silly window syndrome

Tiny windows cause tiny segments. It is avoided by Clark's solution (receiver advertises window only when it can accept at least one MSS or half the buffer) and Nagle's algorithm (sender waits to collect data).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Networks and Security chapter 5 questions →