Bird
Raised Fist0
Computer Networksknowledge~10 mins

Flow control (stop-and-wait, sliding window) in Computer Networks - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Flow control (stop-and-wait, sliding window)
Sender sends 1 frame
→Wait for ACK
↓
ACK received?
No→Timeout: resend frame
Yes↓
Send next frame
↓
Sender sends multiple frames up to window size
↓
Receiver sends ACKs for received frames
↓
Sender slides window forward on ACK
↓
Continue sending frames within window
↓
Timeout: resend unacknowledged frames
The sender sends frames and waits for acknowledgments (ACKs). In stop-and-wait, it sends one frame at a time and waits. In sliding window, it sends multiple frames before waiting, sliding the window forward as ACKs arrive.
Execution Sample
Computer Networks
Sender: send frame 1
Wait for ACK 1
ACK 1 received
Send frame 2
Wait for ACK 2
This shows stop-and-wait flow control where the sender sends one frame and waits for its acknowledgment before sending the next.
Analysis Table
StepActionFrame SentACK ReceivedWindow StateResult
1Send frame 11None[1]Frame 1 sent, waiting for ACK
2Wait for ACK 11No[1]Timeout, resend frame 1
3Resend frame 11No[1]Frame 1 resent
4ACK 1 received1Yes[]ACK received, slide window
5Send frame 22None[2]Frame 2 sent, waiting for ACK
6ACK 2 received2Yes[]ACK received, slide window
7Send frames 3,4,5 (window size 3)3,4,5None[3,4,5]Multiple frames sent
8ACK 3 received3,4,5Yes[4,5]Window slides, frame 3 acknowledged
9ACK 4 received4,5Yes[5]Window slides, frame 4 acknowledged
10Timeout for frame 55No[5]Resend frame 5
11ACK 5 received5Yes[]All frames acknowledged, window empty
💡 All frames sent and acknowledged, flow control cycle complete
State Tracker
VariableStartAfter Step 1After Step 4After Step 7After Step 11
Frame SentNone1None3,4,5None
ACK ReceivedNoneNoYesNoYes
Window StateEmpty[1]Empty[3,4,5]Empty
Key Insights - 3 Insights
Why does the sender wait after sending one frame in stop-and-wait?
Because the sender must receive an ACK for the current frame before sending the next, as shown in execution_table rows 1-6.
How does sliding window improve efficiency compared to stop-and-wait?
Sliding window allows sending multiple frames before waiting for ACKs, shown in rows 7-11 where frames 3,4,5 are sent together.
What happens when an ACK is not received in time?
The sender times out and resends the unacknowledged frame, as seen in rows 2-3 and 10.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 4, what is the window state after ACK 1 is received?
AWindow is empty
BWindow slides forward and is empty
CWindow contains frame 1
DWindow contains frame 2
💡 Hint
Check the 'Window State' column at step 4 in execution_table
At which step does the sender send multiple frames in sliding window?
AStep 7
BStep 3
CStep 5
DStep 10
💡 Hint
Look for multiple frames sent in the 'Frame Sent' column in execution_table
If the sender never receives ACK 5, what action is taken according to the execution_table?
ASender stops sending frames
BSender sends next frame without ACK
CSender resends frame 5 after timeout
DSender increases window size
💡 Hint
See the action at step 10 in execution_table for timeout behavior
Concept Snapshot
Flow control manages data transmission between sender and receiver.
Stop-and-wait sends one frame and waits for its ACK before next.
Sliding window sends multiple frames up to window size before waiting.
ACKs slide the window forward allowing continuous sending.
Timeouts cause resending of unacknowledged frames.
This improves efficiency and reliability in networks.
Full Transcript
Flow control in networking ensures data is sent reliably and efficiently. In stop-and-wait, the sender sends one frame and waits for an acknowledgment before sending the next. If the ACK is not received in time, the frame is resent. Sliding window flow control improves this by allowing multiple frames to be sent before waiting for ACKs. The sender maintains a window of frames it can send and slides this window forward as ACKs arrive. Timeouts cause resending of frames that were not acknowledged. This process balances speed and reliability in data transmission.

Practice

(1/5)
1. Which flow control method sends one packet and waits for an acknowledgment before sending the next?
easy
A. Stop-and-Wait
B. Sliding Window
C. Multiplexing
D. Routing

Solution

  1. Step 1: Understand Stop-and-Wait flow control

    Stop-and-Wait sends one packet and waits for an acknowledgment before sending the next packet.
  2. Step 2: Compare with other methods

    Sliding Window sends multiple packets before waiting, while Multiplexing and Routing are unrelated to flow control.
  3. Final Answer:

    Stop-and-Wait -> Option A
  4. Quick Check:

    One packet at a time = Stop-and-Wait [OK]
Hint: One packet then wait means Stop-and-Wait [OK]
Common Mistakes:
  • Confusing Sliding Window with Stop-and-Wait
  • Thinking Multiplexing is a flow control method
  • Mixing routing with flow control
2. Which of the following correctly describes the sliding window flow control method?
easy
A. Sends one packet and waits for acknowledgment
B. Sends multiple packets before waiting for acknowledgment
C. Sends packets without any acknowledgment
D. Sends packets only after a timeout

Solution

  1. Step 1: Recall sliding window behavior

    Sliding Window sends multiple packets before waiting for acknowledgment to improve speed.
  2. Step 2: Eliminate incorrect options

    Sends one packet and waits for acknowledgment describes Stop-and-Wait. The other options do not describe standard flow control methods.
  3. Final Answer:

    Sends multiple packets before waiting for acknowledgment -> Option B
  4. Quick Check:

    Multiple packets sent = Sliding Window [OK]
Hint: Multiple packets sent before wait means Sliding Window [OK]
Common Mistakes:
  • Choosing Stop-and-Wait for sliding window question
  • Thinking no acknowledgment is used
  • Confusing timeout with acknowledgment wait
3. Consider a sliding window protocol with window size 4. If the sender has sent packets 1, 2, 3, and 4, but only packets 1 and 2 are acknowledged, which packets can the sender send next?
medium
A. Packets 5 and 6
B. Packets 3, 4, and 5
C. Packets 5, 6, 7, and 8
D. Packets 3, 4, 5, and 6

Solution

  1. Step 1: Understand sliding window acknowledgments

    Packets 1 and 2 are acknowledged, so the window slides forward by 2 packets.
  2. Step 2: Calculate new window range

    Window size is 4, so after acknowledging 1 and 2, sender can send packets 5 and 6 (next two packets).
  3. Final Answer:

    Packets 5 and 6 -> Option A
  4. Quick Check:

    Window slides by acknowledged packets = Packets 5 and 6 [OK]
Hint: Window slides by acknowledged packets count [OK]
Common Mistakes:
  • Trying to resend unacknowledged packets
  • Sending too many packets beyond window size
  • Not sliding window after acknowledgments
4. A stop-and-wait protocol implementation is not receiving acknowledgments and keeps resending the same packet. What is the most likely cause?
medium
A. The sender is sending multiple packets at once
B. The sender window size is too large
C. The receiver is not sending acknowledgments
D. The network is using sliding window instead

Solution

  1. Step 1: Analyze stop-and-wait behavior

    Stop-and-wait waits for acknowledgment before sending next packet; no acknowledgment causes resending.
  2. Step 2: Identify cause of no acknowledgment

    If acknowledgments are missing, likely the receiver is not sending them or they are lost.
  3. Final Answer:

    The receiver is not sending acknowledgments -> Option C
  4. Quick Check:

    No acknowledgment = Resend same packet [OK]
Hint: No ack means receiver not responding [OK]
Common Mistakes:
  • Blaming sender window size in stop-and-wait
  • Confusing sliding window with stop-and-wait
  • Assuming multiple packets sent in stop-and-wait
5. In a sliding window protocol with window size 5, the sender transmits packets 1 to 5. Packets 2 and 3 are lost, but packets 1, 4, and 5 are acknowledged. Which packets should the sender retransmit next to maintain correct flow control?
hard
A. Packets 6 and 7
B. Packets 2, 3, and 6
C. Packets 2, 3, 4, and 5
D. Packets 2 and 3 only

Solution

  1. Step 1: Identify lost packets

    Packets 2 and 3 are lost, so they need retransmission.
  2. Step 2: Understand acknowledgments impact

    Packets 1, 4, and 5 are acknowledged, so only lost packets 2 and 3 must be resent before sending new packets.
  3. Final Answer:

    Packets 2 and 3 only -> Option D
  4. Quick Check:

    Retransmit lost packets only = Packets 2 and 3 [OK]
Hint: Retransmit only lost packets, not acknowledged ones [OK]
Common Mistakes:
  • Retransmitting already acknowledged packets
  • Sending new packets before lost ones
  • Confusing lost packets with acknowledged packets
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard