When two devices communicate, one may be faster than the other then flow control mechanisms are needed.
If the sender is too fast, the receiver can get overwhelmed, leading to data loss or buffer overflow.
Flow Control = Technique to match data speed between sender and receiver.
This is used in almost all reliable protocols (UART, I2C, TCP, USB, PCIe, etc.)
1. Why Flow Control Is Needed
Imagine:
- Sender can send 1000 bytes/sec
- Receiver can only process 200 bytes/sec
Without flow control:
Sender keeps sending ----> Receiver buffer full ----> Data lost
With flow control:
Sender slows down <----- Receiver signals "WAIT"
2. Two Major Categories of Flow Control
| Category | Uses |
|---|---|
| Software-based | Special control messages (ACK, flags) |
| Hardware-based | Dedicated wires/pins |
3. Software-Based Flow Control Techniques
3.1 Stop-and-Wait Flow Control (Basic)
- Sender sends one frame at a time
- Waits for ACK before sending next
[Frame 1] -->
<-- [ACK 1]
[Frame 2] -->
3.2 Sliding Window Flow Control (Most widely used – TCP, HDLC)
Sender can send multiple frames without waiting.
Window Size = 4
Send: 1 2 3 4
Wait for ACK
Then send: 5 6 7 8
ASCII Example:
Sender Window: [1][2][3][4]
Sent all 4
Receiver ACKs 1,2
Window slides → can send 5,6
3.3 Credit-Based Flow Control (Used in PCIe, Fibre Channel)
Receiver gives “credits” to sender (how many packets it can accept).
Example:
Receiver: You have 10 credits.
Sender sends 10 packets.
Receiver processes 4, returns 4 credits.
3.4 XON/XOFF (Software Flow Control in UART)
Special characters sent over the same data line.
- XOFF = STOP sending
- XON = RESUME sending
Example:
Sender ---> data ---> data ---> XOFF (pause)
Sender (waits)
Receiver ---> XON (resume)
Sender ---> data ---> ...
4. Hardware-Based Flow Control Techniques
4.1 RTS/CTS (UART, Modems)
RTS = Request to Send
CTS = Clear to Send
Sender: RTS HIGH (I want to send)
Receiver: CTS HIGH (Okay, send)
4.2 Ready/Valid (AMBA AXI, streaming protocols)
Sender: VALID=1 (data available)
Receiver: READY=1 (can accept)
Transfer happens ONLY when both high
ASCII timing:
VALID: 1 1 1 1 0 1
READY: 1 0 1 1 1 1
XFER : 1 0 1 1 0 1 (AND of both)
Very fast
Used in high-performance buses
5. Comparison of Flow Control Techniques
+-----------------+----------------------+-------------------+
| Technique | Speed | Complexity |
+-----------------+----------------------+-------------------+
| Stop-and-Wait | Slow | Simple |
| Sliding Window | Fast | Medium |
| Credit-Based | Very Fast | High |
| XON/XOFF | Medium | Medium |
| RTS/CTS | Medium-Fast | Medium |
| Ready/Valid | Very Fast | High |
+-----------------+----------------------+-------------------+
6. Which Protocols Use Which Flow Control?
| Protocol | Flow Control Method |
|---|---|
| UART | None / XON/XOFF / RTS/CTS |
| I2C | Clock stretching (hardware pause) |
| SPI | Usually none (master controls clock) |
| USB | Credit-based + ACK |
| Ethernet | PAUSE frames (802.3x) |
| PCIe | Credit-based |
| TCP | Sliding window + Dynamic window scaling |
| AXI | Ready/Valid Handshake |
7. TCP Flow Control = Sliding Window + Congestion Control
TCP uses:
- Receive Window (receiver buffer capacity)
- ACKs (confirmation)
- Window Scaling (for high-speed networks)
- Slow Start (avoid congestion)
- Dynamic window size
It is one of the most advanced flow control mechanisms in networking.
8. Flow Control vs Congestion Control
| Term | Controls |
|---|---|
| Flow Control | Receiver side speed |
| Congestion Control | Network traffic load |
TCP does both!
9. ASCII Summary
+---------------------+
| Flow Control |
+---------------------+
/ \
Software Hardware
/ | \ / \
Stop SW CW XON/XOFF RTS/CTS Ready/Valid
SW = Sliding Window
CW = Credit Window

