Chapter 14 of 28

Flow Control

Imagine a fast computer sending data to a slower computer. If the sender keeps sending data at full speed, the receiver may not be able to process everything. Its buffer can fill up, causing data to be lost.

Flow Control is the technique used to control the amount and speed of data sent by a sender so that the receiver can handle it properly.

In simple words:

Flow control makes sure that a fast sender does not overwhelm a slow receiver.

Fast Sender ───────→ Slow Receiver
             Flow Control
          Controls data rate

Why Do We Need Flow Control?

Different devices may have different processing speeds and buffer capacities.

For example, suppose:

  • Sender can send 100 MB/s

  • Receiver can process only 40 MB/s

If the sender continuously sends at 100 MB/s, the receiver may not be able to keep up.

Flow control helps the sender adjust its transmission so that the receiver does not become overwhelmed.

Flow Control Helps With

  • Preventing receiver buffer overflow

  • Matching sender and receiver speeds

  • Improving reliable communication

  • Avoiding unnecessary data loss


How Does Flow Control Work?

The receiver can provide information about how much data it is currently able to accept.

Based on this information, the sender controls how much data it sends.

A simple example:

Sender
  │
  │ Data
  ↓
Receiver
  │
  │ "I can accept more"
  ↓
Sender continues sending

If the receiver becomes busy:

Sender
  │
  │ Data
  ↓
Receiver
  │
  │ "Slow down!"
  ↓
Sender reduces transmission

One important protocol that implements flow control is TCP.


Types of Flow Control

Two classic flow-control techniques are:

  1. Stop-and-Wait

  2. Sliding Window

Let's understand them.


1. Stop-and-Wait Flow Control

In Stop-and-Wait, the sender sends one unit of data and then waits for an acknowledgment before sending the next one.

Sender                  Receiver

  Data  ───────────────→
         ←──────── ACK

  Data  ───────────────→
         ←──────── ACK

The sender stops after each transmission and waits for the receiver's response.

Example

Suppose the sender has four data units:

Data 1 → ACK
Data 2 → ACK
Data 3 → ACK
Data 4 → ACK

Only after receiving an acknowledgment does it send the next data unit.

Advantages

  • Very simple

  • Easy to implement

  • Helps prevent receiver overload

Disadvantages

  • Slow

  • Poor utilization of the communication channel, especially when network delay is high


2. Sliding Window Flow Control

Sliding Window allows the sender to transmit multiple units of data before waiting for acknowledgments.

For example, if the window size is 4:

Data 1 → Data 2 → Data 3 → Data 4 →
                 Receiver

The sender can send several units without stopping after every one.

As acknowledgments arrive, the window moves forward:

[1  2  3  4] 5  6  7

    ↓ ACKs received

1  2 [3  4  5  6] 7

This is why it is called a sliding window.

Advantages

  • Much faster than Stop-and-Wait

  • Better use of network bandwidth

  • Allows multiple data units to be in transit

Disadvantages

  • More complex

  • Requires more management and buffering

TCP uses a sliding-window-based mechanism for flow control.


Stop-and-Wait vs Sliding Window

Feature

Stop-and-Wait

Sliding Window

Data sent before waiting

One unit

Multiple units

Speed

Slower

Faster

Efficiency

Lower

Higher

Complexity

Simple

More complex

Network utilization

Lower

Better

Used by

Basic protocols/examples

TCP and other reliable protocols


Flow Control vs Error Control

These two concepts are often confused.

Flow Control deals with the speed of data transmission.

Error Control deals with lost or corrupted data.

Flow Control

Error Control

Prevents receiver from being overwhelmed

Handles transmission errors

Controls data rate

Detects/recover from errors

Focuses on receiver capacity

Focuses on data correctness

Example: TCP receive window

Example: retransmission

Think of it this way:

Flow Control → "Don't send faster than I can handle."

Error Control → "Make sure the data I receive is correct."


Flow Control in TCP

TCP provides flow control using a receive window.

The receiver tells the sender how much data it is currently willing to accept without waiting for further acknowledgments.

If the receiver has plenty of available buffer space, it can advertise a larger window.

If its buffer is becoming full, it can advertise a smaller window.

This allows TCP to dynamically adjust the amount of data that can be in transit.

Receiver Buffer Available
          ↓
    Receive Window
          ↓
Sender controls
amount of data sent

This is one of the reasons TCP can support reliable communication between devices with different processing speeds.

Conclusion

Flow control is a mechanism that prevents a fast sender from overwhelming a slower receiver.

The two classic techniques are Stop-and-Wait and Sliding Window. Stop-and-Wait is simple but inefficient, while Sliding Window allows multiple data units to be transmitted at once and provides much better network utilization.

The easiest way to remember it is:

Flow Control = Control the amount/rate of data so the receiver can keep up.