Sliding Window Protocol solves this problem by allowing several frames to remain in transit before acknowledgements return.
From this basic idea we get three extremely important ARQ mechanisms: Stop-and-Wait ARQ, Go-Back-N ARQ and Selective Repeat ARQ.
Sliding Window Protocol is a Data Link Layer flow-control and error-control technique in which the sender can transmit multiple frames before waiting for acknowledgements, depending on the sender window size.
It uses sequence numbers, acknowledgements and sender/receiver windows to control which frames may be sent, accepted and retransmitted.
The major ARQ protocols are: Stop-and-Wait ARQ, Go-Back-N ARQ and Selective Repeat ARQ.
What Is Sliding Window Protocol?
Sliding Window Protocol is a technique used to control the transmission of frames between a sender and receiver.
Instead of forcing the sender to wait after every single frame, the protocol gives the sender a range of sequence numbers called the sending window.
Frames whose sequence numbers fall inside this window may be transmitted.
As acknowledgements arrive, the window moves or slides forward.
Why Do We Need Sliding Window Protocol?
Stop-and-Wait is easy to understand, but it wastes time.
Suppose a frame takes only 1 ms to transmit but the acknowledgement takes a long time to return.
The sender may remain idle for most of the communication cycle.
Sliding Window solves this by keeping the link busy.
Stop-and-Wait
Send one frame and wait for ACK.
Sliding Window
Allow several outstanding frames.
Go-Back-N
Multiple frames may be sent, but one loss can force retransmission of several outstanding frames.
Selective Repeat
Retransmit only the missing or damaged frames.
Basic Idea of Sliding Window
Suppose frame sequence numbers are:
0, 1, 2, 3, 4, 5, 6, 7
Assume sender window size is 4.
Initially, the sender may transmit:
Frames 4, 5, 6 and 7 must wait.
What Is a Window?
A window is the range of sequence numbers that a sender or receiver is currently allowed to use.
There are two important windows:
- Sender Window
- Receiver Window
Sender Window
The sender window contains the sequence numbers of frames that may currently be transmitted.
It may contain:
- Already transmitted but not yet acknowledged frames
- Frames that are allowed to be transmitted immediately
The sender cannot normally transmit a new frame whose sequence number lies outside the current window.
Receiver Window
The receiver window defines which sequence numbers the receiver is willing to accept.
Its behaviour depends on the ARQ protocol.
| Protocol | Receiver Window Behaviour |
|---|---|
| Stop-and-Wait ARQ | Expects only one specific sequence number. |
| Go-Back-N | Receiver window is normally 1. |
| Selective Repeat | Receiver window can contain multiple sequence numbers and buffer out-of-order frames. |
Sequence Numbers in Sliding Window Protocol
Every data frame is assigned a sequence number.
Sequence numbers help the protocol:
- Identify individual frames
- Detect duplicates
- Track acknowledgements
- Recognize missing frames
- Maintain correct delivery order
Modulo Sequence Numbering
Sequence numbers are not infinitely large.
If m bits are used for a sequence number, the total number of possible sequence numbers is:
Example
If m = 3:
After sequence number 7, numbering returns to 0.
Sequence
Space
How Does the Window Slide?
Suppose sender window contains:
Frame 0 is successfully acknowledged.
The window can now move forward:
Frame 4 becomes eligible for transmission.
This movement is called sliding the window.
Acknowledgement and Negative Acknowledgement
ACK
ACK means Acknowledgement.
It tells the sender that a frame or group of frames has been successfully received.
NAK
NAK means Negative Acknowledgement.
It may be used to request retransmission of missing or damaged data.
What Is Piggybacking?
In bidirectional communication, both devices may be sending data to each other.
Instead of sending a separate ACK frame immediately, a device can sometimes attach the acknowledgement information to its outgoing data frame.
This technique is called piggybacking.
Data →
← ACK
Piggybacking:
Data + ACK information inside reverse-direction data frame
Advantage
Reduces separate acknowledgement overhead.
Limitation
The protocol cannot delay an ACK indefinitely while waiting for reverse-direction data, so a timer or maximum ACK delay is usually required.
Role of Timers
A sender needs to know when an expected acknowledgement has taken too long.
A timer is therefore associated with outstanding data.
When the timer expires:
The exact retransmission behaviour depends on the ARQ protocol.
- Stop-and-Wait → retransmit one frame.
- Go-Back-N → may retransmit the oldest missing frame and subsequent unacknowledged frames.
- Selective Repeat → retransmit only the required frame.
Stop-and-Wait ARQ
Stop-and-Wait ARQ is the simplest reliable ARQ protocol.
Its sender window size is:
Only one data frame can remain unacknowledged at any moment.
Working of Stop-and-Wait ARQ
- Sender creates Frame 0.
- Frame 0 is transmitted.
- Sender starts a timer.
- Receiver receives Frame 0 correctly.
- Receiver delivers its packet upward.
- Receiver sends ACK.
- Sender receives ACK and stops timer.
- Sender changes sequence number from 0 to 1.
- Frame 1 is transmitted.
Lost Frame and Lost ACK in Stop-and-Wait ARQ
Case 1 – Data Frame Is Lost
Case 2 – ACK Is Lost
Receiver may successfully receive Frame 0 but its ACK may disappear.
The sender eventually retransmits Frame 0.
Receiver uses the sequence number to identify it as a duplicate.
Alternating Bit Protocol
Stop-and-Wait ARQ commonly uses one sequence-number bit:
This is known as the Alternating Bit Protocol.
Stop-and-Wait ARQ Efficiency
Let:
- Tt = frame transmission time
- Tp = one-way propagation delay
- a = Tp / Tt
If ACK transmission time and processing delay are negligible:
Stop-and-Wait performs poorly when propagation delay is much larger than transmission time.
Go-Back-N ARQ
Go-Back-N improves Stop-and-Wait by allowing multiple frames to be sent before waiting for individual acknowledgements.
The sender keeps several unacknowledged frames in its window.
However, the receiver normally accepts only the next expected frame.
If Frame k is lost or damaged, the receiver rejects later out-of-order frames, and the sender eventually retransmits Frame k and the following outstanding frames.
How Go-Back-N ARQ Works
Suppose sender window size is 4.
The sender transmits:
without waiting after each individual frame.
If all arrive correctly, acknowledgements allow the sender window to move forward.
Go-Back-N Window Size
If the sequence number field has m bits:
Example
For a 3-bit sequence number:
Cumulative Acknowledgement in Go-Back-N
Go-Back-N commonly uses cumulative acknowledgements.
A cumulative ACK confirms multiple consecutive frames at once.
The exact ACK numbering convention depends on the protocol description.
Some textbooks describe ACK n as:
- “All frames up to n were received.”
Others describe it as:
- “The next frame expected is n.”
What Happens When a Frame Is Lost in Go-Back-N?
Suppose the sender sends:
but Frame 2 is lost.
Step-by-Step
- Frames 0 and 1 arrive correctly.
- Frame 2 is lost.
- Frame 3 arrives while receiver is expecting Frame 2.
- Frame 3 is normally discarded.
- Frame 4 is also discarded.
- Sender eventually detects the missing progress through timeout or acknowledgement behaviour.
- Sender retransmits Frame 2 and later outstanding frames.
Timer Management in Go-Back-N
A common Go-Back-N implementation maintains a timer for the oldest unacknowledged frame.
When that timer expires, the sender retransmits the oldest outstanding frame and later outstanding frames in the window.
Advantages of Go-Back-N
- Better utilization than Stop-and-Wait.
- Multiple frames can be in transit.
- Receiver logic is simple.
- Receiver does not need to buffer many out-of-order frames.
- Cumulative ACK reduces acknowledgement overhead.
Limitations of Go-Back-N
- One lost frame can cause retransmission of many correct frames.
- Wastes bandwidth when error rate is high.
- Receiver discards correctly received out-of-order frames.
Selective Repeat ARQ
Selective Repeat is a more efficient ARQ protocol for noisy links.
Unlike Go-Back-N, the receiver can accept and buffer correctly received frames even if an earlier frame is missing.
Only the missing or damaged frame needs retransmission.
Selective Repeat: One error → retransmit only the required frame.
How Selective Repeat ARQ Works
Suppose the sender transmits:
Frame 2 is lost.
Frames 3 and 4 still reach the receiver.
Instead of discarding them, Selective Repeat stores them in a receiver buffer.
When retransmitted Frame 2 arrives:
- Frame 2 is placed in order.
- Buffered Frames 3 and 4 now become part of a complete consecutive sequence.
- Frames can be delivered upward in correct order.
Selective Repeat Window Size
Selective Repeat has a stricter window-size condition because old and new sequence numbers must never become ambiguous.
If m bits are used:
Example
If m = 3:
Why Does Selective Repeat Need More Buffer?
Go-Back-N discards out-of-order frames.
Selective Repeat keeps them.
Therefore the receiver must maintain memory for:
- Frames received correctly but out of order
- Sequence-number status
- Individual acknowledgement information
Lost Frame in Selective Repeat
Suppose:
The receiver:
- Recognizes Frame 2 is missing.
- Buffers Frames 3 and 4.
- Acknowledges correctly received frames according to protocol rules.
- Waits for Frame 2.
The sender retransmits only Frame 2 after the required retransmission condition occurs.
Timers in Selective Repeat
Selective Repeat commonly needs independent tracking of outstanding frames.
Conceptually, each unacknowledged frame may require its own timer or equivalent per-frame retransmission timing information.
SR → individual outstanding frame timing
Important Window Size Rules
| Protocol | Sender Window | Receiver Window | m-Bit Rule |
|---|---|---|---|
| Stop-and-Wait ARQ | 1 | 1 | 1-bit numbering 0 and 1 is sufficient |
| Go-Back-N ARQ | Up to 2m − 1 | 1 | Ws ≤ 2m − 1 |
| Selective Repeat ARQ | Up to half sequence space | Usually same supported range | Ws, Wr ≤ 2m−1 |
Why Is Go-Back-N Window at Most 2m − 1?
If the sender used the entire sequence number space, a new frame after wraparound could become ambiguous with an old unacknowledged frame.
Leaving at least one sequence number outside the sender window prevents this ambiguity.
Why Is Selective Repeat Limited to Half the Sequence Space?
Selective Repeat accepts out-of-order frames and stores them.
After sequence numbers wrap around, the receiver must distinguish:
- Old delayed frames
- New frames using the same sequence number
Keeping each active window no larger than half the sequence space prevents the old and new windows from overlapping ambiguously.
Sliding Window Efficiency
For an ideal no-error sliding-window link, let:
- W = sender window size
- Tp = propagation delay
- Tt = frame transmission time
- a = Tp / Tt
Condition for Full Link Utilization
To keep the sender continuously busy in the ideal case:
The window must be large enough to fill the communication path while earlier acknowledgements are still returning.
Bandwidth-Delay Product
Bandwidth-delay product tells us how much data can be “in flight” on a link.
For bidirectional acknowledgement timing, sliding-window sizing is closely related to the round-trip delay and the amount of unacknowledged data needed to keep the link busy.
Solved Numericals on Sliding Window Protocol
Numerical 1: Maximum Go-Back-N Window
A protocol uses 4-bit sequence numbers. Find the maximum sender window size for Go-Back-N.
Numerical 2: Maximum Selective Repeat Window
A protocol uses 4-bit sequence numbers. Find the maximum Selective Repeat window.
Numerical 3: Stop-and-Wait Efficiency
Frame transmission time = 10 ms.
Propagation delay = 20 ms.
Numerical 4: Sliding Window Utilization
Suppose:
- Window size W = 5
- Propagation delay = 20 ms
- Transmission time = 10 ms
Numerical 5: Required Window for Full Utilization
Propagation delay = 40 ms.
Frame transmission time = 10 ms.
Numerical 6: Required Sequence Bits for GBN
A Go-Back-N protocol requires a sender window of 31 frames.
Find the minimum sequence-number bits.
Numerical 7: Required Sequence Bits for Selective Repeat
Selective Repeat requires a window size of 16.
Stop-and-Wait ARQ vs Go-Back-N vs Selective Repeat
| Feature | Stop-and-Wait ARQ | Go-Back-N ARQ | Selective Repeat ARQ |
|---|---|---|---|
| Sender Window | 1 | Multiple frames | Multiple frames |
| Receiver Window | 1 | 1 | Multiple frames |
| Outstanding Frames | One | Several | Several |
| Sequence Number Need | 1 bit sufficient | m-bit modulo numbering | m-bit modulo numbering |
| Sender Window Rule | 1 | ≤ 2m − 1 | ≤ 2m−1 |
| Receiver Window Rule | 1 | 1 | ≤ 2m−1 |
| Out-of-Order Frames | Not relevant beyond duplicate handling | Discarded | Buffered |
| ACK Type | Per-frame | Usually cumulative | Selective / individual style |
| Frame Loss | Retransmit one frame | Retransmit missing frame and following outstanding frames | Retransmit only required frame |
| Receiver Buffer | Small | Small | Larger |
| Timer Complexity | Simple | Usually oldest outstanding frame | Per-frame tracking more complex |
| Efficiency | Lowest on long-delay links | Good when errors are rare | Best when errors are significant |
| Protocol Complexity | Lowest | Moderate | Highest |
Advantages and Limitations of Sliding Window Protocols
Advantages
- Better link utilization than basic Stop-and-Wait.
- Several frames can be in transit simultaneously.
- Supports efficient flow control.
- Supports reliable error recovery through ARQ.
- Sequence numbers prevent duplicate delivery.
- Window size can be chosen according to link characteristics.
- Go-Back-N uses simple receiver logic.
- Selective Repeat reduces unnecessary retransmission.
- Useful on high bandwidth-delay links.
Limitations
- More complex than Stop-and-Wait.
- Requires sequence-number management.
- Requires sender buffers.
- Selective Repeat requires substantial receiver buffering.
- Timers add implementation complexity.
- Incorrect window size can create sequence ambiguity.
- GBN can waste bandwidth after one error.
- SR requires more complex ACK and reordering logic.
Common Exam Mistakes
No. Stop-and-Wait, GBN and SR use different window rules.
Classical GBN receiver window is 1, so out-of-order frames are normally discarded.
No. SR retransmits only the required lost or damaged frame.
No. Maximum classical GBN sender window is 2m − 1.
No. Classical SR window must generally be no larger than half the sequence space.
Its sender window size is exactly 1.
They also prevent duplicate delivery and help associate ACKs with frames.
In bidirectional traffic, ACK information may be piggybacked.
GBN retransmits a sequence of outstanding frames; SR retransmits selectively.
Utilization cannot exceed 100%, and protocol sequence-space limits still apply.
They represent different physical effects.
Recovery depends on ACK/NAK and timer behaviour. In the classical timeout case, the sender retransmits from the oldest missing unacknowledged frame.
Sliding Window Protocol Quick Revision
Important Exam Questions With Answers
1. What is Sliding Window Protocol?
2. Why is Sliding Window better than Stop-and-Wait?
3. What is a sender window?
4. What is a receiver window?
5. What is meant by sliding the window?
6. What is sequence-number space?
7. What is Stop-and-Wait ARQ?
8. Why are sequence numbers 0 and 1 enough in Stop-and-Wait ARQ?
9. What is the Alternating Bit Protocol?
10. What happens when a data frame is lost in Stop-and-Wait ARQ?
11. What happens when an ACK is lost?
12. What is Go-Back-N ARQ?
13. What is the maximum sender window of Go-Back-N?
14. What is the receiver window size in Go-Back-N?
15. What is cumulative acknowledgement?
16. Why is Go-Back-N called Go-Back-N?
17. What is Selective Repeat ARQ?
18. What is the maximum window size in Selective Repeat?
19. Why must the Selective Repeat window be at most half the sequence space?
20. How does Selective Repeat handle out-of-order frames?
21. Why does Selective Repeat require more memory?
22. What is piggybacking?
23. What is the advantage of piggybacking?
24. What is the role of a timer in ARQ?
25. Differentiate between Go-Back-N and Selective Repeat.
26. What is the Stop-and-Wait utilization formula?
27. What is the ideal sliding-window utilization formula?
28. When can a sliding-window protocol achieve 100% ideal utilization?
29. What is bandwidth-delay product?
30. Why are Sliding Window protocols important?
31. A GBN protocol uses 3-bit sequence numbers. What is the maximum sender window?
32. A Selective Repeat protocol uses 3-bit sequence numbers. Find maximum window size.
33. GBN needs a window of 15 frames. What is the minimum number of sequence bits?
34. Selective Repeat needs a window of 8 frames. Minimum sequence bits?
35. Tp = 30 ms and Tt = 10 ms. Find Stop-and-Wait utilization.
36. Tp = 20 ms, Tt = 5 ms and W = 9. Find ideal sliding-window utilization.
37. Tp = 20 ms and Tt = 5 ms. What minimum window gives full utilization?
38. A 5-bit sequence field is used. Find sequence space, maximum GBN window and maximum SR window.
39. Why does GBN perform poorly when error rate is high?
40. Which protocol is more efficient on an error-prone long-delay link: GBN or SR? Why?
Sliding Window Protocol MCQs With Answers
A. Link utilization
B. DNS resolution
C. IP addressing
D. Encryption
A. 1
B. 2
C. 7
D. Unlimited
A. 0 and 1
B. 0 to 255 only
C. 1 to 100
D. No sequence numbers
A. 1
B. N
C. 2N
D. Unlimited
A. 2^m − 1
B. 2^m
C. 2^(m−1)
D. m
A. Half the sequence space
B. Entire sequence space
C. One frame only
D. Zero frames
A. Buffers valid out-of-order frames
B. Always discards every out-of-order frame
C. Has no sequence numbers
D. Cannot acknowledge frames
A. Cumulative ACK
B. No ACK
C. DNS ACK
D. Routing ACK
A. Frame 3 and following outstanding frames
B. Only Frame 0
C. No frames
D. Only the final frame
A. Only the required frame is retransmitted
B. Entire network is restarted
C. Every frame from zero is retransmitted
D. No recovery is possible
A. Adding ACK information to reverse-direction data
B. Adding a router
C. Duplicating every frame
D. Removing sequence numbers
A. Missing expected acknowledgement
B. MAC address length
C. IP route cost
D. DNS response type
A. Duplicate delivery
B. Cable attenuation
C. Router congestion only
D. Encryption errors
A. Go-Back-N
B. Selective Repeat
C. Both are identical
D. Neither
A. Selective Repeat
B. Go-Back-N
C. Stop-and-Wait
D. Pure ALOHA
A. 15
B. 16
C. 8
D. 4
A. 8
B. 15
C. 16
D. 4
A. Propagation delay
B. Packet size
C. Processing rate
D. Protocol number
A. W ≥ 1 + 2a
B. W = 0
C. W < 1 always
D. ACK is disabled
A. Selective Repeat
B. Go-Back-N
C. Stop-and-Wait always
D. Unrestricted Simplex
Frequently Asked Questions About Sliding Window Protocol
What is Sliding Window Protocol in simple words?
It is a method that allows a sender to send several frames before waiting for all acknowledgements, improving link utilization compared with basic Stop-and-Wait.
What are the main Sliding Window ARQ protocols?
The main protocols are Stop-and-Wait ARQ, Go-Back-N ARQ and Selective Repeat ARQ.
What is the sender window?
The sender window contains the sequence numbers of frames that the sender is currently allowed to transmit.
What is the receiver window?
The receiver window contains the sequence numbers the receiver is currently prepared to accept.
What is the maximum Go-Back-N window for m bits?
The maximum classical Go-Back-N sender window is 2^m − 1.
What is the maximum Selective Repeat window for m bits?
The maximum classical Selective Repeat window is 2^(m−1), or half of the sequence-number space.
Why does Go-Back-N discard out-of-order frames?
Its receiver window is normally one, so the receiver only accepts the exact next expected sequence number.
Why is Selective Repeat more complex?
It accepts out-of-order frames, buffers them, tracks individual acknowledgements and performs selective retransmission.
What is cumulative ACK?
A cumulative acknowledgement confirms that a consecutive range of frames has been successfully received.
What is piggybacking?
Piggybacking attaches acknowledgement information to reverse-direction data instead of sending a separate ACK frame.
What is the Stop-and-Wait efficiency formula?
Ignoring ACK transmission time and processing delay, U = 1/(1+2a), where a = Tp/Tt.
When can Sliding Window achieve full utilization?
Under the simplified no-error model, full utilization is possible when the sender window satisfies W ≥ 1+2a.
Final Chapter Summary
Sliding Window Protocol improves communication efficiency by allowing several frames to remain unacknowledged at the same time.
The protocol revolves around four ideas:
Stop-and-Wait ARQ keeps only one frame outstanding.
Sequence = 0,1
Error → Timeout → Retransmit One Frame
Go-Back-N allows multiple outstanding frames but keeps a receiver window of one.
Receiver Window = 1
Cumulative ACK
Error → Retransmit Missing + Later Outstanding Frames
Selective Repeat accepts and buffers out-of-order frames.
Out-of-Order Frames Buffered
Selective ACK
Error → Retransmit Only Required Frame
For numericals:
Stop-and-Wait: U = 1 / (1 + 2a)
Sliding Window: U = min[1, W / (1 + 2a)]
Full Utilization: W ≥ 1 + 2a
The easiest final memory line is:
Go-Back-N = Error Means Go Back
Selective Repeat = Repeat Only the Error
Next Chapter: HDLC in Computer Networks: Stations, Configurations, Frames, Modes & Working
