Sliding window: stop-and-wait, Go-Back-N, Selective Repeat
Reliable delivery over a lossy link with acknowledgements, timeouts and sequence numbers: stop-and-wait, the sliding window idea that keeps the pipe full, Go-Back-N (cumulative acknowledgements, receiver window 1, resend everything from the lost frame) and Selective Repeat (individual acknowledgements, receiver buffers, resend only the lost frame), the utilisation min(1, N / (1 + 2a)), the window needed to fill the pipe, and the limits on the window for k-bit sequence numbers (2^k - 1 and 2^(k-1)); animations come from a slotted simulation of the protocols.
Why it exists
A link or a network can lose or damage frames (the CRC detects damaged ones, which are then dropped, error detection). To deliver data reliably, the receiver acknowledges what it receives, the sender keeps a copy until acknowledged and retransmits after a timeout. The simplest scheme sends one frame and waits for its acknowledgement. On a long fast link this leaves the channel idle almost all the time (performance metrics); sliding window protocols keep several frames in flight.
Prerequisites
You need transmission time, propagation delay and the bandwidth-delay product (performance metrics).
Precise definitions
Frames are numbered with sequence numbers. Let be the transmission time of a frame, the one-way propagation delay, . Acknowledgements are short (their transmission time is ignored) and the round-trip cycle of a frame is .
Stop-and-wait. Send one frame, wait for its acknowledgement (or a timeout, then resend). Sequence numbers alternate (1 bit) so that the receiver can tell a retransmission from a new frame. Utilisation .
Sliding window. The sender may have up to frames outstanding (sent, not yet acknowledged): its window holds their sequence numbers; each acknowledgement slides the window forward. With a window of frames per cycle the utilisation (no errors) is
and the window that keeps the sender busy all the time is (that is, the bandwidth-delay product in frames, plus one).
Go-Back-N (GBN). The receiver accepts frames only in order (receiver window ) and sends cumulative acknowledgements: acknowledgement means "all frames up to have arrived". If a frame is lost or damaged, the receiver discards all later frames and repeats the last acknowledgement; the sender's timer for the oldest unacknowledged frame expires and the sender goes back and retransmits that frame and all frames after it.
Selective Repeat (SR). The receiver accepts any frame inside its window (receiver window ), stores out-of-order frames and acknowledges each frame individually; the sender keeps a timer per frame and retransmits only the frames that were not acknowledged. The receiver delivers frames to the upper layer in order.
Sequence number space. With -bit sequence numbers there are values, used modulo . The window size is limited so that old and new frames are never confused:
- Go-Back-N: ;
- Selective Repeat: (half the sequence numbers);
- stop-and-wait: (so bit suffices).
How it works
Why windows
Utilisation of the sender with window size N: start
Computed by a script, not typed| link | transmission time tt | a = tp / tt | stop-and-wait | N = 7 | N = 127 | window to fill the pipe 1 + 2a |
|---|---|---|---|---|---|---|
| 1000-bit frames, 1 Mbps, one-way 10 ms | ||||||
| 8000-bit frames, 1 Mbps, one-way 10 ms | ||||||
| 12000-bit frames, 100 Mbps, one-way 5 ms | ||||||
| 12000-bit frames, 1 Gbps, one-way 25 ms |
Step 0
Acknowledgements are short and take no transmission time, no frames are lost. Utilisation = min(1, N / (1 + 2a)).
With -bit frames at Mbps and a one-way delay of ms, , stop-and-wait uses percent of the channel; a window of fills the pipe (). With -bit frames at Gbps and ms, and one needs more than frames in flight to use the link; even frames use only percent. This is why sequence numbers must be large on fast, long links.
Go-Back-N
Go-Back-N with a lost frame: start
Computed by a script, not typed| time | sender | receiver | frames sent: base .. next |
|---|---|---|---|
| slot 0 | |||
| slot 1 | |||
| slot 2 | |||
| slot 3 | |||
| slot 4 | |||
| slot 5 | |||
| slot 6 | |||
| slot 7 | |||
| slot 8 | |||
| slot 9 | |||
| slot 10 | |||
| slot 11 | |||
| slot 12 | |||
| slot 13 | |||
| slot 14 | |||
| slot 15 | |||
| slot 16 | |||
| slot 17 |
Step 0
10 frames, window N = 4, one-way delay 2 slots (one slot is the transmission time of a frame), frame 3 is lost on its first transmission; timeout = one round trip (4 slots). Acknowledgements are not lost.
Window , round trip slots. Frame is lost. The receiver gets , and out of order and discards them, repeating the acknowledgement of frame ; the sender cannot slide its window past frame . When the timer for frame expires (one round trip after it was sent) the sender goes back and resends frames . Frames had arrived once already and were thrown away: the capacity wasted is up to frames per loss.
Selective Repeat
Selective Repeat with a lost frame: start
Computed by a script, not typed| time | sender | receiver | frames sent: base .. next |
|---|---|---|---|
| slot 0 | |||
| slot 1 | |||
| slot 2 | |||
| slot 3 | |||
| slot 4 | |||
| slot 5 | |||
| slot 6 | |||
| slot 7 | |||
| slot 8 | |||
| slot 9 | |||
| slot 10 | |||
| slot 11 | |||
| slot 12 | |||
| slot 13 | |||
| slot 14 | |||
| slot 15 | |||
| slot 16 | |||
| slot 17 |
Step 0
10 frames, window N = 4, one-way delay 2 slots (one slot is the transmission time of a frame), frame 3 is lost on its first transmission; timeout = one round trip (4 slots). Acknowledgements are not lost.
The same loss: the receiver stores frames and acknowledges each of them; after the timeout the sender resends only frame . When it arrives the receiver can deliver to at once.
Frames sent and time in slots for the three protocols: start
Computed by a script, not typed| losses | stop-and-wait (frames / slots) | Go-Back-N | Selective Repeat |
|---|---|---|---|
| 0 frame(s) lost | |||
| 1 frame(s) lost (5) | |||
| 2 frame(s) lost (5, 11) | |||
| 3 frame(s) lost (5, 6, 11) |
Step 0
The first transmission of the listed frames is lost. 'Frames' is the number of transmissions, 'slots' the time until the last frame is acknowledged.
For frames: with one lost frame stop-and-wait needs transmissions (and slots), Go-Back-N transmissions, Selective Repeat (always plus the number of lost frames). Selective Repeat uses the channel more economically but needs a receiver with buffers and a timer per frame; on these small examples the finishing time is the same as Go-Back-N or slightly later, so its advantage is fewer transmissions, not speed. (If every transmission is lost with probability the textbook value for Selective Repeat is transmissions per frame; Go-Back-N is larger because a loss costs up to retransmissions.)
Why the window is limited
Suppose all acknowledgements of a full window are lost. The sender will resend frame . In Go-Back-N the receiver, which has accepted frames, expects number ; it takes the old frame for a new one if , i.e. : so . In Selective Repeat the receiver's new window is ; the old frame lies in it if : so .
Largest usable window for k-bit sequence numbers: start
Computed by a script, not typed| sequence number size | sequence numbers | Go-Back-N window | Selective Repeat window |
|---|---|---|---|
| 1-bit sequence numbers | |||
| 2-bit sequence numbers | |||
| 3-bit sequence numbers | |||
| 4-bit sequence numbers | |||
| 5-bit sequence numbers | |||
| 6-bit sequence numbers | |||
| 7-bit sequence numbers | |||
| 8-bit sequence numbers |
Step 0
Stop-and-wait needs only 1 bit (window 1). In Go-Back-N the receiver window is 1, in Selective Repeat the receiver window equals the sender window.
Worked examples
EX 1Stop-and-wait utilisation
Easy-bit frames at Mbps, one-way delay ms: ms, ; percent; the throughput is kbps.
EX 2Window to fill the pipe
MediumSame link: frames must be outstanding for percent. With : percent. The sequence numbers needed: for Go-Back-N with needs (); for Selective Repeat needs ().
EX 3Retransmissions after one loss
Medium; frame is lost, frames were already sent. GBN resends (four frames). SR resends only (one frame).
EX 4Typical questions
GATE level(a) "Maximum window size of GBN with -bit sequence numbers?" . (b) "Of SR?" . (c) "Bits needed for a GBN window of ?" : . (d) "Bits for SR window ?" : . (e) "Receiver window size in GBN?" . (f) "Utilisation of stop-and-wait?" . (g) "Efficiency of a window protocol with and ?" percent.
Cheat box
Cheat box
- , ; stop-and-wait . Window to fill the pipe .
- GBN: receiver window , cumulative ack, resend from the lost frame; .
- SR: receiver window , individual acks, resend only the lost frame; .
- Sequence numbers modulo .
- Round-trip cycle .
Traps and GATE patterns
Connections
Across subjects
No cross-subject links yet.
TCP uses a sliding window with cumulative acknowledgements, plus receiver-advertised windows (TCP flow control) and a congestion window (TCP congestion control). Damaged frames are found by the CRC (error detection). The window needed is the bandwidth-delay product of performance metrics.
PYQs
19 previous year questions from your book. I re-solved each one myself (18 by running or simulating, 1 by reasoning only); the book's key is shown next to my answer. All PYQs
Consider the implementation of a sliding window protocol over a lossless link, with a window size of W frames, where each frame is of size 1000 bits (including header). The bandwidth of the link is 100 kbps (1k = 103) and the one-way propagation delay is 100 milliseconds. Assume that processing times at the sender and receiver are zero and the transmission time of acknowledgements is also zero. Which one of the following options gives the minimum size of W (in number of frames) required to achieve 100% link utilization?
- (a)10
- (b)21
- (c)20
- (d)11
Suppose we are transmitting frames between two nodes using Stop-and-Wait protocol. The frame size is 3000 bits. The transmission rate of the channel is 2000 bps (bits per second) and the propagation delay between the two nodes is 100 milliseconds. Assume that the processing times at the source and destination are negligible. Also, assume that the size of the acknowledgment packet is negligible. Which ONE of the following most accurately gives the channel utilization for the above scenario in percentage?
- (a)88.23
- (b)93.75
- (c)85.44
- (d)66.67
Suppose two hosts are connected by a point-to-point link and they are configured to use Stop-and-Wait protocol for reliable data transfer. Identify in which one of the following scenarios, the utilization of the link is the lowest.
- (a)Longer link length and lower transmission rate
- (b)Longer link length and higher transmission rate
- (c)Shorter link length and lower transmission rate
- (d)Shorter link length and higher transmission rate
Consider the sliding window flow-control protocol operating between a sender and a receiver over a full- duplex error-free link. Assume the following: The time taken for processing the data frame by the receiver is negligible. The time taken for processing the acknowledgement frame by the sender is negligible. The sender has an infinite number of frames available for transmission. The size of the data frame is 2000 bits, and the size of the acknowledgement frame is 10 bits. The link data rate in each direction is 1 Mbps (= 106 bits per second). One-way propagation delay of the link is 100 milliseconds. The minimum value of the sender's window size in terms of the number of frames, (rounded to the nearest integer) needed to achieve a link utilization of 50% is _______.
The values of parameters for the Stop-and-Wait ARQ protocol are as given below: Bit rate of the transmission channel = 1 Mbps. Propagation delay from sender to receiver = 0.75 ms. Time to process a frame = 0.25 ms. Number of bytes in the information frame = 1980. Number of bytes in the acknowledge frame = 20. Number of overhead bytes in the information frame = 20. Assume that there are no transmission errors. Then, the transmission efficiency (expressed in percentage) of the Stop-and-Wait ARQ protocol for the above parameters is ______ (correct to 2 decimal places).
Consider a 128×103 bits/second satellite communication link with one-way propagation delay of 150 milliseconds. Selective retransmission (repeat) protocol is used on this link to send data with a frame size of 1 kilobyte. Neglect the transmission time of acknowledgment. The minimum number of bits required for the sequence number field to achieve 100% utilization is ______. COMPUTER NETWORK
A sender uses the Stop-and-Wait ARQ protocol for reliable transmission of frames. Frames are of size 1000 bytes and the transmission rate at the sender is 80 Kbps (1 Kbps = 1000 bits/second). Size of an acknowledgment is 100 bytes and the transmission rate at the receiver is 8 Kbps. The one-way propagation delay is 100 milliseconds. Assuming no frame is lost, the sender throughput is __________ bytes/second.
A link has a transmission speed of 106 bits/sec. It uses data packets of size 1000 bytes each. Assume that the acknowledgment has negligible transmission delay, and that its propagation delay is the same as the data propagation delay. Also assume that the processing delays at nodes are negligible. The efficiency of the stop-and-wait protocol in this setup is exactly 25%. The value of the one-way propagation delay (in milliseconds) is:
Consider a network connecting two systems located 8000 kilometers apart. The bandwidth of the network is 500 × 106 bits per second. The propagation speed of the media is 4 × 106 meters per second. It is needed to design a Go-Back-N sliding window protocol for this network. The average packet size is 107 bits. The network is to be used to its full capacity. Assume that processing delays at nodes are negligible. Then, the minimum size in bits of the sequence number field has to be
Suppose that the stop-and-wait protocol is used on a link with a bit rate of 64 kilobits per second and 20 milliseconds propagation delay. Assume that the transmission time for the acknowledgment and the processing time at nodes are negligible. Then the minimum frame size in bytes to achieve a link utilization of at least 50% is: __________
Consider a selective repeat sliding window protocol that uses a frame size of 1 KB to send data on a 1.5 Mbps link with a one-way latency of 50 msec . To achieve a link utilization of 60%, the minimum number of bits required to represent the sequence number field is ____ .
Frames of 1000 bits are sent over a 106 bps duplex link between two hosts. The propagation time is 25 ms. Frames are to be transmitted into this link to maximally pack them in transit (within the link). What is the minimum number of bits (l) required to represent the sequence numbers distinctly? Assume that no time gap needs to be given between transmission of two frames.
- (a)I = 2
- (b)I = 3
- (c)I = 4
- (d)I = 5
Suppose that the sliding window protocol is used with the sender window size of 2l, where l is the number of bits identified in the earlier part and acknowledgements are always piggybacked. After sending 2l frames, what is the minimum time the sender will have to wait before starting transmission of the next frame? (Ignore frame processing time.)
- (a)16 ms
- (b)18 ms
- (c)20 ms
- (d)22 ms
The distance between two stations M and N is L kilometers. All frames are K bits long. The propagation delay per kilometer is t seconds. Let R bits/second be the channel capacity. Assuming that processing delay is negligible, the minimum number of bits for the sequence number field in a frame for maximum utilization, when the sliding window protocol is used, is:
- (a)⌈log2 (2LtR+2K) K ⌉
- (b)⌈log2 ( 2LtR K)⌉
- (c)⌈log2(( 2LtR + K) K )⌉
- (d)⌈log2( (2LtR + K) (2K) )⌉
Station A uses 32 byte packets to transmit messages to Station B using a sliding window protocol. The round trip delay between A and B is 80 milliseconds and the bottleneck bandwidth on the path between A and B is 128 kbps. What is the optimal window size that A should use?
- (a)20
- (b)40
- (c)160
- (d)320
Station A needs to send a message consisting of 9 packets of Station B using sliding window (window size 3) and go-back-n error control strategy. All packets are ready and immediately available for transmission. If every 5th packet that A transmits gets lost (but no ACKs from B ever get lost), then what is the number of packets that A will transmit for sending the message to B?
- (a)12
- (b)14
- (c)16
- (d)18
The maximum window size for data transmission using the selective reject protocol with n-bit frame sequence numbers is:
- (a)2n
- (b)2n-1
- (c)2n -1
- (d)2n-2
It is necessary to design a link-layer protocol between two hosts that are directly connected over a lossless link of length 3000 km. The link bandwidth is 108 bits per second, and the propagation delay is 5 ns per meter. Every transmitted data byte is assigned a unique sequence number. Let N be the minimum number of bits needed for the sequence number field such that: i. the sequence numbers do not wrap around before 60 seconds, and ii. the maximum utilization of the link is achieved. Find N. (answer in integer)
Consider a selective repeat sliding window protocol that uses a frame size of 1 KB to send data on a 1.5 Mbps link with a one-way latency of 50 msec. To achieve a link utilization of 60%, the minimum number of bits required to represent the sequence number field is __________.
Self-check
Question 1
. What window gives full utilisation, and what is the utilisation with ?
Show answerHide
frames for full utilisation; with : percent.
Question 2
Why can a Selective Repeat window not exceed half of the sequence numbers?
Show answerHide
Otherwise the receiver's new window overlaps the old one and a retransmitted old frame can be taken for a new frame.
Question 3
How many frames does Go-Back-N resend if the third frame of a window of is lost (the other five were already sent)?
Show answerHide
Frames to of the window: the lost one and all the following frames sent after it, frames.
Revision card
One-screen revision
- ; fill the pipe with .
- GBN: receiver window 1, resend from the lost frame, . SR: resend only the lost, .
- Cumulative acks (GBN), individual acks (SR).
References
- ·Kurose, Ross, Computer Networking: A Top-Down Approach (8th edition), Chapter 3, Section 3.4 (Principles of reliable data transfer)
- ·Tanenbaum, Wetherall, Computer Networks (5th edition), Chapter 3, Section 3.4 (Elementary data link protocols) and 3.4.3 (Sliding window protocols)
Verification
scripts/enum-checks/cn_tcp_check.py: the slotted simulator of scripts/cn_tcp.py (one frame per slot, one-way delay d slots, acknowledgements never lost, timeout = one round trip) gives, for 3000 frames, every protocol with windows 1 to 32 and delays 1 to 8 slots, a sender utilisation within 0.01 of min(1, N / (1 + 2a)) with the cycle 1 + 2a = 2d slots; under random loss (800 random cases with up to 6 lost first transmissions) Go-Back-N and stop-and-wait deliver all frames in order, Selective Repeat sends exactly n + (number of lost frames) frames, Go-Back-N sends at least that many and at most N more per loss; the sequence number limits come from a concrete model of the scenario in which all acknowledgements of a full window are lost (for k = 1 to 6 and every window size: Go-Back-N is ambiguous exactly when W is at least 2^k, Selective Repeat exactly when W exceeds 2^(k-1)). THE SIMULATION SHOWS THAT SELECTIVE REPEAT IS NOT ALWAYS FASTER than Go-Back-N in time on short examples with several losses (it sends fewer frames); the page claims only fewer transmissions. MODEL: acknowledgements are never lost and are not delayed; one fixed timeout; in Go-Back-N the receiver sends a (cumulative) acknowledgement for every arriving frame, repeating the last one for out-of-order frames; textbooks differ in details (negative acknowledgements, piggybacking, window numbering from 0 or 1). The formula for the expected number of transmissions with loss probability p (Selective Repeat 1/(1-p)) is the textbook value, not simulated here. Textbook chapter references are from memory. SECOND PASS (2026-11-02, done by the assistant, not a human check): every Self-check question was solved before the printed answer was read and all agreed; the definitions, worked examples, cheat box and traps were read claim by claim and the numbers re-derived by hand or by a small script (CRC remainders, binomial tail, checksums); long C programs were not re-read line by line (they are compiled and compared by npm run verify:c, and their printed outputs were checked against the prose). One confusing callout title fixed (it read '2^k, not 2^k - 1, for Selective Repeat's half' while the text states Go-Back-N 2^k - 1 and Selective Repeat 2^(k-1)). Status raised to self-checked; verified needs a textbook or human check.
last verified: never
My notes (saved in this browser)