0
0
Computer Networksknowledge~6 mins

Flow control (stop-and-wait, sliding window) in Computer Networks - Full Explanation

Choose your learning style9 modes available
Introduction
Imagine sending a letter to a friend and waiting for their reply before sending the next one. This slow process can waste time if the friend takes long to respond. Flow control in networks solves this problem by managing how data is sent and received to avoid overload and delays.
Explanation
Stop-and-Wait Flow Control
In stop-and-wait, the sender sends one data packet and then waits for an acknowledgment from the receiver before sending the next packet. This ensures the receiver is ready and prevents data loss, but it can be slow because the sender is idle while waiting.
Stop-and-wait sends one packet at a time and waits for confirmation before continuing.
Sliding Window Flow Control
Sliding window allows the sender to send multiple packets before needing an acknowledgment, up to a set window size. The receiver can accept and acknowledge packets in order, and the window slides forward as acknowledgments arrive, improving efficiency and speed.
Sliding window sends multiple packets at once, increasing data flow and efficiency.
Real World Analogy

Imagine a teacher handing out worksheets to students. With stop-and-wait, the teacher gives one worksheet and waits for the student to finish before giving the next. With sliding window, the teacher gives several worksheets at once, and as students finish, the teacher gives more.

Stop-and-Wait Flow Control → Teacher giving one worksheet at a time and waiting for it to be finished before giving the next
Sliding Window Flow Control → Teacher handing out multiple worksheets at once and giving more as students complete them
Diagram
Diagram
Stop-and-Wait:
Sender: [Pkt1] --send--> Receiver: [Ack1]
Sender: [Pkt2] --send--> Receiver: [Ack2]

Sliding Window:
Sender: [Pkt1][Pkt2][Pkt3][Pkt4] --send--> Receiver: [Ack1][Ack2]
Window slides forward as acks arrive
This diagram shows stop-and-wait sending one packet and waiting for acknowledgment, and sliding window sending multiple packets before acknowledgments.
Key Facts
Flow ControlA method to manage data transmission rate between sender and receiver to prevent overload.
Stop-and-WaitA flow control method where the sender waits for an acknowledgment after each packet.
Sliding WindowA flow control method allowing multiple packets to be sent before receiving acknowledgments.
Window SizeThe maximum number of unacknowledged packets the sender can transmit in sliding window.
Common Confusions
Believing stop-and-wait is always better because it is simpler.
Believing stop-and-wait is always better because it is simpler. Stop-and-wait is simpler but inefficient for long delays; sliding window improves speed by sending multiple packets.
Thinking sliding window sends packets without any limit.
Thinking sliding window sends packets without any limit. Sliding window has a fixed window size that limits how many packets can be sent before waiting for acknowledgments.
Summary
Flow control prevents the sender from overwhelming the receiver by managing data transmission rates.
Stop-and-wait sends one packet at a time and waits for acknowledgment, ensuring reliability but with low efficiency.
Sliding window allows multiple packets to be sent before acknowledgment, improving data flow and network efficiency.