Flow Control at Transport Layer

Flow Control is a technique that ensures a sender does not send more data than the receiver can process. Without flow control, fast senders could overwhelm slow receivers, causing data loss or congestion.

 Why Flow Control Is Important at the Transport Layer

The Transport Layer (Layer 4 in the OSI model) is responsible for end-to-end communication. It manages the flow of data between two hosts. Unlike lower layers (like the Data Link Layer), which manage device-to-device transmission, the Transport Layer ensures that two applications on different hosts communicate reliably.

UDP cannot perform flow control at the transport layer because it is designed to be simple, fast, and connectionless. So, TCP is used for flow control because it is a connection-oriented protocol that provides reliable data delivery.

Sliding Window Protocol: The Heart of TCP Flow Control

The Sliding Window Protocol is a fundamental mechanism used by TCP (Transmission Control Protocol) to manage flow control, ensuring that a sender does not overwhelm a receiver with too much data at once.

What Is a Window?

  • A window is the range of bytes that the sender is allowed to send without waiting for an acknowledgment.
  • The size of the window is determined by the receiver and is communicated to the sender via the rwnd (Receiver Window) field in the TCP header.

Components of TCP Flow Control

Term Explanation
rwnd Receiver Window – advertised by receiver, tells sender how much buffer space is available
swnd Sender Window – defines the maximum number of unacknowledged bytes the sender can send
ACK (Acknowledge) Confirms receipt of data and can trigger the window to “slide” forward

 How It Works (Step-by-Step)

  1. Connection Setup: During TCP’s three-way handshake, both sender and receiver agree on initial window sizes.

  2. Data Transmission: Sender sends bytes within the allowed window size (e.g., 0–4095 bytes). Each time the receiver acknowledges some bytes, the window “slides” forward.

  3. Window Update: The receiver keeps updating the window size (rwnd) in every TCP segment. If the receiver’s buffer gets full, it sets rwnd = 0 to pause the sender.

  4. Zero Window Condition: If rwnd = 0, the sender must wait. Sender sends small “window probe” messages to check if the receiver is ready again.

  5. Resume Transmission: Once the receiver has space again, it updates the rwnd, and the sender resumes transmission.

Example of Flow Control

Imagine a sender with 1000 bytes to send and a receiver that can handle only 200 bytes at a time.

  • Receiver sets rwnd = 200
  • Sender sends bytes 0–199
  • Receiver acknowledges receipt and sets new rwnd = 200
  • Sender sends bytes 200–399
  • If receiver is busy and sets rwnd = 0, sender pauses and probes until the receiver resumes.

 Summary Table of Flow Control Across Layers

Layer Protocol Example Mechanism Purpose
Transport Layer TCP Sliding Window, rwnd Prevent sender from overwhelming the receiver
Data Link Layer Ethernet, PPP Stop-and-Wait, Backpressure Manage flow on point-to-point physical links
Application Layer HTTP, FTP Application buffers, pause/resume Control data pacing at application-level