0
0
Computer Networksknowledge~6 mins

TCP flow control (sliding window) in Computer Networks - Full Explanation

Choose your learning style9 modes available
Introduction
Imagine sending a long letter through a small mailbox. If you send too many pages at once, the mailbox overflows and pages get lost. TCP flow control solves this problem by managing how much data is sent before waiting for confirmation.
Explanation
Purpose of Flow Control
Flow control prevents the sender from overwhelming the receiver with too much data at once. It ensures the receiver can process incoming data without losing any. This keeps communication smooth and reliable.
Flow control balances data sending speed to match the receiver's ability to handle it.
Sliding Window Mechanism
The sliding window is a range of data packets the sender can send without waiting for an acknowledgment. As the receiver confirms receipt, the window slides forward, allowing more data to be sent. This keeps data flowing efficiently.
The sliding window lets the sender send multiple packets before needing confirmation, improving speed.
Window Size
The window size is the number of bytes the sender can send before stopping to wait for an acknowledgment. The receiver tells the sender its available buffer size, which sets the window size. This size can change dynamically during communication.
Window size controls how much data can be sent at once and adapts to the receiver's capacity.
Acknowledgments and Window Sliding
When the receiver gets data, it sends an acknowledgment with the next expected byte number. This moves the window forward, allowing the sender to send new data. If acknowledgments are delayed, the sender waits, preventing overload.
Acknowledgments move the window forward, signaling the sender to send more data.
Real World Analogy

Imagine a conveyor belt delivering boxes to a worker. The worker can only handle a few boxes at a time. The belt stops when the worker is full and starts again when space is freed. This keeps the worker from being overwhelmed.

Purpose of Flow Control → Worker's limit on how many boxes they can handle at once
Sliding Window Mechanism → The length of the conveyor belt section delivering boxes before stopping
Window Size → The number of boxes the worker can hold before needing to process them
Acknowledgments and Window Sliding → Worker signaling the belt to move more boxes after processing some
Diagram
Diagram
Sender Side Window:
┌─────────────────────────────┐
│[Data 1][Data 2][Data 3][Data 4][Data 5]│
└─────────────────────────────┘
       ↓
Receiver acknowledges Data 1 and Data 2

Window slides forward:
┌─────────────────────────────┐
│       [Data 3][Data 4][Data 5][Data 6][Data 7]│
└─────────────────────────────┘
This diagram shows how the sender's sliding window moves forward as the receiver acknowledges received data.
Key Facts
Flow ControlA method to prevent the sender from overwhelming the receiver with too much data.
Sliding WindowA range of data bytes the sender can transmit before needing acknowledgment.
Window SizeThe maximum number of bytes the sender can send without waiting for acknowledgment.
AcknowledgmentA message from the receiver indicating which data bytes have been received.
Common Confusions
Believing flow control is the same as congestion control.
Believing flow control is the same as congestion control. Flow control manages data rate between sender and receiver to prevent overflow, while congestion control manages network traffic to avoid overall network overload.
Thinking the window size is fixed and never changes.
Thinking the window size is fixed and never changes. The window size can change dynamically based on the receiver's available buffer space.
Summary
TCP flow control uses a sliding window to manage how much data the sender can transmit before waiting for acknowledgment.
The window size adapts to the receiver's capacity to process data, preventing overload.
Acknowledgments from the receiver move the window forward, allowing continuous and reliable data flow.