Flow Control (Sliding Window)

[!NOTE] This module explores the core principles of Flow Control (Sliding Window), deriving solutions from first principles and hardware constraints to build world-class, production-ready expertise.

1. What is Flow Control?

Flow control is a technique to ensure that a fast sender does not overwhelm a slow receiver. If the sender sends data faster than the receiver can process it, the receiver’s buffer will overflow and packets will be dropped.

2. Stop-and-Wait (The Slow Way)

The sender sends one packet and waits for an ACK before sending the next.

  • Pros: Very simple.
  • Cons: Extremely inefficient. You spend most of your time waiting for ACKs rather than sending data (The “Pipe” is empty).

3. Sliding Window (The Fast Way)

The sender is allowed to have multiple packets “in flight” (sent but not yet acknowledged).

  • Window Size: The number of bytes the sender can transmit without receiving an ACK.
  • Dynamic: The receiver tells the sender its available buffer space in every ACK packet.

4. Interactive: Sliding Window demo

Watch the window move as data is acknowledged.

1
2
3
4
5
6
7
8
Window Size: 3 Packets. Current Window: [3, 4, 5]
Waiting for ACK...

5. Zero Window (The Emergency Brake)

If the receiver’s buffer is completely full, it sends a Window Size = 0 flag.

  • The sender must stop transmitting immediately.
  • The sender then sends periodic “Window Probes” to see if any buffer space has cleared up.