Flow Control in the Transport Layer
Flow Control in the Transport Layer
Introduction
One of the important responsibilities of the Transport Layer is to ensure that the sender does not transmit data faster than the receiver can process it. This mechanism is known as Flow Control.
Flow control maintains a balance between the rate at which data is produced by the sender and the rate at which it is consumed by the receiver. If this balance is not maintained, data may be lost or the communication system may become inefficient.
Definition
Flow Control is a mechanism that regulates the rate of data transmission between the sender and the receiver so that the receiver is not overwhelmed with more data than it can handle.
Its primary objective is to prevent buffer overflow and data loss at the receiving side.
Why is Flow Control Needed?
Consider two situations.
Case 1: Sender is Faster than Receiver
Suppose,
- Sender transmits 1000 packets/second
- Receiver can process only 500 packets/second
Sender ---------------------> Receiver 1000 Packets/sec Can process only 500 Packets/sec
The receiver's memory (buffer) becomes full.
Result:
- Buffer overflow
- Packet loss
- Retransmissions
- Reduced performance
Case 2: Receiver is Faster than Sender
Suppose,
- Sender transmits 100 packets/second
- Receiver can process 1000 packets/second
Sender -----------------------> Receiver 100 Packets/sec Can process 1000 Packets/sec
Now the receiver remains idle waiting for data.
Result:
- Poor utilization
- Reduced efficiency
Therefore, there must be a balance between the sender's transmission speed and the receiver's processing speed.
Producer and Consumer Concept
Flow control can be understood using the Producer–Consumer model.
- Producer → Creates data.
- Consumer → Receives and processes data.
Producer -----------------> Consumer Produces data Consumes data
The producer should not produce data faster than the consumer can consume it.
Pushing and Pulling
Data can be delivered in two different ways.
1. Pushing
In Pushing, the producer sends data without waiting for a request from the consumer.
Producer │ │ Sends data automatically ▼ Consumer
Characteristics
- Sender controls communication.
- Data is sent continuously.
- Receiver may become overloaded.
- Flow control is required.
Example
A video camera continuously sends video frames.
If the receiver becomes slow,
- Frames accumulate.
- Buffer becomes full.
- Some frames may be lost.
2. Pulling
In Pulling, the consumer requests data only when it is ready.
Consumer │ │ Request ▼ Producer │ │ Sends data ▼ Consumer
Characteristics
- Receiver controls communication.
- Producer sends data only after request.
- No receiver overload.
- Flow control is generally unnecessary.
Example
Downloading a webpage.
The browser requests data, and the server sends only the requested information.
Pushing vs Pulling
| Feature | Pushing | Pulling |
|---|---|---|
| Who initiates communication? | Producer | Consumer |
| Data sent | Automatically | On request |
| Receiver overload | Possible | Not possible |
| Need for Flow Control | Yes | Usually No |
Flow Control at the Transport Layer
Communication at the transport layer involves four entities.
Application Process (Sender) │ Sender Transport Layer │ Receiver Transport Layer │ Application Process (Receiver)
Each entity has a different role.
1. Sending Application Process
Acts as a Producer.
- Generates data.
- Pushes message chunks to the transport layer.
Application Produces Message ↓ Transport Layer
2. Sending Transport Layer
Acts as both
- Consumer
- Producer
It
- Receives data from the application.
- Encapsulates the data into packets.
- Sends packets to the receiving transport layer.
Application ↓ Sender Transport Layer Receives Data ↓ Creates Packet ↓ Sends Packet
3. Receiving Transport Layer
Also performs two roles.
It
- Receives packets.
- Removes the transport header.
- Produces application messages.
Packet ↓ Receiver Transport Layer ↓ Original Message
4. Receiving Application Process
Acts as a Consumer.
Unlike the sender, it does not receive data continuously.
Instead,
it requests data whenever it is ready.
Thus, the last delivery follows the Pulling model.
Where is Flow Control Required?
According to the transport-layer communication model, flow control is required in two places.
Case 1
Between
Sending Application Layer
and
Sending Transport Layer
Application ↓ Transport Layer
If the transport layer buffer becomes full,
it tells the application
STOP SENDING
When space becomes available,
START SENDING AGAIN
Case 2
Between
Receiving Transport Layer
and
Sending Transport Layer
Sender Transport Layer ↓ Receiver Transport Layer
If the receiver buffer becomes full,
the receiver sends a signal
STOP
When space becomes available,
CONTINUE
Thus, data loss is prevented.
Role of Buffers
Flow control is usually implemented using buffers.
What is a Buffer?
A buffer is a temporary memory area used to store packets before they are processed.
Buffers exist at
- Sender Transport Layer
- Receiver Transport Layer
Sender Buffer
Application ↓ Sender Buffer ↓ Network
Purpose
- Temporarily stores outgoing packets.
- Prevents packet loss if the network is busy.
If full,
Application STOP Sending
Receiver Buffer
Network ↓ Receiver Buffer ↓ Application
Purpose
- Stores incoming packets until the application processes them.
If full,
Receiver informs the sender
STOP Sending
After processing some packets,
CONTINUE Sending
Flow Control Using Buffers
Step 1
Application generates data.
Application ↓ Sender Buffer
Step 2
Sender sends packets.
Sender Buffer ↓ Network
Step 3
Receiver stores packets.
Network ↓ Receiver Buffer
Step 4
Application reads packets.
Receiver Buffer ↓ Application
Step 5
If receiver buffer becomes full,
Receiver Buffer FULL ↓ Signal STOP
Step 6
Sender temporarily stops transmission.
Sender Waits
Step 7
After the application processes some packets,
the receiver buffer has free space.
Receiver ↓ Buffer Empty ↓ Signal CONTINUE
Sender resumes transmission.
Complete Flow Control Diagram
Advantages of Flow Control
- Prevents buffer overflow at the receiver.
- Avoids packet loss.
- Matches the sender's speed with the receiver's processing capability.
- Improves communication efficiency.
- Reduces unnecessary retransmissions.
- Ensures reliable end-to-end communication.
Real-Life Analogy
Imagine a supermarket checkout counter.
- Customers are the data packets.
- Cashier is the receiver.
- Queue area is the buffer.
If customers arrive faster than the cashier can serve them, the queue becomes full. The security guard temporarily stops new customers from entering until there is space again.
Similarly, in a network:
- The sender produces packets.
- The receiver processes them.
- The buffer temporarily stores packets.
- Flow control prevents the sender from transmitting more data when the receiver's buffer is full.
Summary
- Flow Control is a transport-layer mechanism that regulates the rate of data transmission so that the sender does not overwhelm the receiver.
- Data transfer can occur through pushing, where the producer sends data without waiting for requests (requiring flow control), or pulling, where the consumer requests data only when ready (typically eliminating the need for flow control).
- At the transport layer, the sending application produces data, the sending transport layer encapsulates and forwards it, the receiving transport layer decapsulates it, and the receiving application consumes it.
- Flow control is commonly implemented using buffers at both the sender and receiver. When a buffer becomes full, the receiving side signals the sender to pause transmission, and when space becomes available, it signals the sender to resume, thereby preventing data loss and ensuring efficient communication.


Comments
Post a Comment