Bird
Raised Fist0
Computer Networksknowledge~10 mins

Flow control (stop-and-wait, sliding window) in Computer Networks - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to identify the flow control method where the sender waits for an acknowledgment after sending each frame.

Computer Networks
if sender_waits_for_ack == [1]:
    method = "Stop-and-Wait"
Drag options to blanks, or click blank then click option'
ATrue
BFalse
CMaybe
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing False because they think the sender sends frames continuously.
Selecting None or Maybe as they are not boolean values.
2fill in blank
medium

Complete the code to calculate the window size in sliding window flow control given the sequence number bits.

Computer Networks
window_size = 2[1] - 1
Drag options to blanks, or click blank then click option'
A**2
B**3
C**5
D**4
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of exponentiation.
Forgetting to subtract 1 from the power of 2.
3fill in blank
hard

Fix the error in the code that checks if the sender can send more frames in sliding window protocol.

Computer Networks
if frames_sent < [1]:
    can_send = True
else:
    can_send = False
Drag options to blanks, or click blank then click option'
Awindow_size - 1
Bwindow_size + 1
Cwindow_size
Dwindow_size * 2
Attempts:
3 left
💡 Hint
Common Mistakes
Adding or subtracting 1 incorrectly from window size.
Multiplying window size by 2 which is not correct.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps frame numbers to their acknowledgment status if the frame number is less than the window size.

Computer Networks
{frame_num: status for frame_num, status in frames.items() if frame_num [1] window_size and status [2] 'sent'}
Drag options to blanks, or click blank then click option'
A<
B==
C!=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '<' for frame number comparison.
Using '!=' instead of '==' for status comparison.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps sequence numbers (mod window size) to frame data for frames with status 'acknowledged'.

Computer Networks
{(frame_num [1] window_size): data for frame_num, (data, status) in frames.items() if status [2] 'acknowledged' and frame_num [3] window_size}
Drag options to blanks, or click blank then click option'
A%
B==
C<
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction (-) instead of modulo (%).
Using '!=' instead of '==' for status check.
Using '>' instead of '<' for frame number filtering.

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