Introduction

Error detection tells a receiver that a frame is damaged; it does not get the data through. Automatic repeat request (ARQ) protocols add acknowledgements, timers and retransmission so that every frame is eventually delivered once and in order. The same machinery also provides flow control: the sender may have only a limited number of unacknowledged frames, its window, so a slow receiver is not flooded.

There are three classic protocols. Stop-and-wait sends one frame and waits for its acknowledgement. Go-Back-N (GBN) keeps up to NN frames outstanding and, after a loss, resends the lost frame and everything after it. Selective Repeat (SR) also keeps a window outstanding but resends only the frames that were actually lost, at the price of buffering out-of-order frames at the receiver.

The quantities to compute are link utilisation from a=Tp/Tta = T_p/T_t, the window needed to fill a link, the number of sequence-number bits, the maximum window for a given number of bits, and the number of transmissions under a stated loss pattern. TCP uses the same ideas with byte-numbered windows (TCP Flow Control).

Prerequisites

Core concepts

Terms

TermMeaning
ACKIn this note, cumulative GBN ACK nn acknowledges frames through nn. TCP ACK aa instead acknowledges bytes through a−1a-1 and requests byte aa. Individual SR ACK nn acknowledges frame nn
NAKNegative acknowledgement: asks for one frame again (optional in SR)
TimeoutTime after which an unacknowledged frame is resent; must exceed the round trip Tt+2TpT_t + 2T_p (plus ACK and processing time)
Sender window WsW_sMaximum number of frames sent but not yet acknowledged
Receiver window WrW_rNumber of frame positions the receiver will accept and buffer
Sequence number fieldkk bits; numbers run 0,1,…,2k−10, 1, \ldots, 2^k - 1 and wrap around
PiggybackingCarrying an ACK inside a data frame going the other way instead of sending a separate ACK frame

Efficiency convention used in all CN notes. Utilisation (efficiency) UU is the fraction of time the sender's link is busy sending new data frames. Unless a question states otherwise, ACK frames are taken to have negligible transmission time, processing and queueing are zero, and the round trip is 2Tp2T_p. The ratio is a=Tp/Tta = T_p/T_t (one-way propagation over frame transmission).

Stop-and-wait

Send a frame, start a timer, wait for its ACK, then send the next. One sequence bit (0 and 1, alternating) is enough: if an ACK is lost, the sender times out and resends, and the receiver recognises the duplicate by its sequence number, discards it and re-acknowledges it. Without sequence numbers a lost ACK would cause a duplicate to be delivered.

Go-Back-N

  • Sender window Ws=NW_s = N; receiver window Wr=1W_r = 1: the receiver accepts only the next expected frame and discards every other frame (it may re-send the last cumulative ACK).
  • ACKs are cumulative, so a lost ACK is covered by any later ACK.
  • One timer, for the oldest unacknowledged frame. On timeout, resend every outstanding frame, starting from the oldest.
  • Simple receiver, no buffering; wastes capacity on a lossy link with a large window.

Selective Repeat

  • Sender window WsW_s, receiver window WrW_r (usually equal). The receiver buffers out-of-order frames inside its window and delivers them in order when the gap is filled.
  • ACKs are individual. Each frame has its own timer; on timeout only that frame is resent. A NAK may trigger the resend before the timer expires.
  • Fewer retransmissions; more receiver memory and bookkeeping.

How it works

Two timelines one above the other, headed Go-Back-N and Selective Repeat, each with a sender line and a receiver line, window 4, frames numbered from 0. In both, frames 0, 1, 2 and 3 are sent; frame 2 is lost; frames 4 and 5 follow as ACKs return. In Go-Back-N the receiver discards 3, 4 and 5 and repeats ACK 1; after the timeout for frame 2 the sender resends 2, 3, 4 and 5, then sends 6: 11 transmissions in all. In Selective Repeat the receiver buffers 3, 4 and 5 and acknowledges each; after the timeout only frame 2 is resent, then 6: 8 transmissions.
Figure 1. Go-Back-N against Selective Repeat with window 4 when frame 2 is lost once: GBN resends 2, 3, 4 and 5 (11 transmissions for 7 frames), SR resends only 2 (8 transmissions).

The figure uses Tt=1T_t = 1 time unit, Tp=2T_p = 2 units, a timeout of 8 units after the end of a frame's transmission, frames 0 to 6, and only the first transmission of frame 2 lost. Frames 0 to 3 go out back to back at times 0 to 4; ACK 0 returns at time 5, so frame 4 is sent at 5 and frame 5 at 6. Then the window is stuck on frame 2. Its timer expires at 11, and the two protocols diverge.

Mathematical explanation

Utilisation without errors

A frame sent at time 0 finishes at TtT_t, its last bit arrives at Tt+TpT_t + T_p, and the ACK is back at Tt+2TpT_t + 2T_p. Stop-and-wait sends one frame per cycle:

USW=TtTt+2Tp=11+2a.U_{\text{SW}} = \frac{T_t}{T_t + 2T_p} = \frac{1}{1 + 2a}.

With a window of WW frames, the sender can send WW frames in each cycle of Tt+2TpT_t + 2T_p:

U={W1+2aif W<1+2a,1if W≥1+2a.U = \begin{cases} \dfrac{W}{1 + 2a} & \text{if } W < 1 + 2a,\\ 1 & \text{if } W \ge 1 + 2a. \end{cases}

The smallest window that keeps the link fully busy is W=⌈1+2a⌉W = \lceil 1 + 2a \rceil. In bits, this is the frame plus the round-trip bandwidth-delay product: WL≥L+R⋅2TpW L \ge L + R \cdot 2T_p. Throughput is U⋅RU \cdot R.

If ACK time and processing are included, replace the cycle Tt+2TpT_t + 2T_p by Tt+Tack+2Tp+TprocT_t + T_{\text{ack}} + 2T_p + T_{\text{proc}}.

Utilisation with errors (stop-and-wait)

If each frame is lost or damaged independently with probability pp and the timeout equals the round trip, the number of transmissions per frame is geometric with mean 1/(1−p)1/(1-p), so

USW=1−p1+2a.U_{\text{SW}} = \frac{1 - p}{1 + 2a}.

Window limits from sequence-number bits

With kk-bit sequence numbers (modulus 2k2^k):

Go-Back-N: Ws≤2k−1,Selective Repeat: Ws+Wr≤2k, so with Ws=Wr: W≤2k−1.\text{Go-Back-N: } W_s \le 2^k - 1, \qquad \text{Selective Repeat: } W_s + W_r \le 2^k, \text{ so with } W_s = W_r:\ W \le 2^{k-1}.

Why GBN cannot use 2k2^k. Suppose Ws=2kW_s = 2^k. The sender sends frames numbered 0,…,2k−10, \ldots, 2^k - 1; all arrive, the receiver now expects number 0 again, and all ACKs are lost. The sender times out and resends the old frame 0, which the receiver accepts as new. With Ws=2k−1W_s = 2^k - 1 the receiver expects 2k−12^k - 1 after a full window, which is not among the resent numbers.

Why SR needs half. After the receiver accepts a full window of WW frames, its window moves to the next WW numbers. If the ACKs are lost, the sender resends the old WW numbers. The two sets of numbers must not overlap modulo 2k2^k, which needs 2W≤2k2W \le 2^k.

Bits needed. For a target window WW: GBN needs the smallest kk with 2k−1≥W2^k - 1 \ge W; SR needs the smallest kk with 2k−1≥W2^{k-1} \ge W, so SR usually needs one bit more than GBN for the same window (compute both; Example 3).

Worked examples

Example 1: stop-and-wait utilisation

A 1 Mbps link, 1000-bit frames, Tp=10T_p = 10 ms. Tt=1T_t = 1 ms, a=10a = 10, U=1/21≈0.0476U = 1/21 \approx 0.0476, throughput about 47.6 kbps. If the ACK is also 1000 bits, U=1/22≈0.0455U = 1/22 \approx 0.0455. If each frame is lost with probability 0.2 (ACKs not counted), U=0.8/21≈0.0381U = 0.8/21 \approx 0.0381.

Example 2: utilisation with a window

Same link. A window of 5 frames gives U=5/21≈0.238U = 5/21 \approx 0.238. A window of 21 or more gives U=1U = 1. In bits: L+R⋅2Tp=1000+20,000=21,000L + R \cdot 2T_p = 1000 + 20{,}000 = 21{,}000 bits must be in flight, which is 21 frames.

Example 3: sequence-number bits

For a window of 21 frames, GBN needs k=5k = 5 (25−1=31≥212^5 - 1 = 31 \ge 21, while 24−1=152^4 - 1 = 15 is too small), and SR needs k=6k = 6 (25=32≥212^5 = 32 \ge 21, 24=162^4 = 16 too small). If the field has only k=4k = 4 bits: GBN can use W=15W = 15, U=15/21≈0.714U = 15/21 \approx 0.714; SR can use W=8W = 8, U=8/21≈0.381U = 8/21 \approx 0.381.

Example 4: counting transmissions under a loss pattern

Ten frames are sent with window 3, every 5th transmission (5th, 10th, 15th, ...) is lost, ACKs are never lost, Tt=1T_t = 1, Tp=1T_p = 1 and the timeout is longer than the time to send a window.

ProtocolTransmissions
Stop-and-wait12
Selective Repeat, W=3W = 312
Go-Back-N, W=3W = 318
Go-Back-N, W=4W = 426

For SR and stop-and-wait each loss costs exactly one extra transmission: 12 transmissions deliver 10 frames because only the 5th and 10th are lost. For GBN each loss also costs the frames sent behind the lost one, and those extra transmissions shift which later frame is the 5th, 10th or 15th transmission. With nine frames instead of ten, GBN with window 3 needs 16 transmissions. Answers to such questions depend on the conventions (what counts as a transmission, whether the window fills before the timeout); state them, then trace frame by frame.

Example 5: the window-size limits in action

With k=2k = 2 (numbers 0 to 3): GBN with W=4W = 4 sends 0, 1, 2, 3; if all four ACKs are lost, the receiver expects 0 and wrongly accepts the resent old 0. With W=3W = 3 it expects 3, and the resent 0, 1, 2 are rejected. SR with W=3W = 3: the receiver's window moves to {3,0,1}\{3, 0, 1\} after accepting 0, 1, 2, so resent old 0 and 1 are wrongly accepted as new; with W=2W = 2 the windows {0,1}\{0, 1\} and {2,3}\{2, 3\} are disjoint and the scheme is safe.

Example 6: piggybacking

Two stations exchange data in both directions. Without piggybacking each data frame needs a separate ACK frame; with piggybacking the ACK number rides in the header of the next data frame in the reverse direction. If no reverse data is ready within a short ACK timer, a stand-alone ACK is sent, so that the sender does not time out.

Example 7: ACK time and processing delay

The link of Example 1 (Tt=1T_t = 1 ms, Tp=10T_p = 10 ms), now with a 100-bit ACK (Tack=0.1T_{\text{ack}} = 0.1 ms) and 0.4 ms of processing at the receiver before it sends the ACK. One cycle is

Tt+Tp+Tproc+Tack+Tp=1+10+0.4+0.1+10=21.5 ms.T_t + T_p + T_{\text{proc}} + T_{\text{ack}} + T_p = 1 + 10 + 0.4 + 0.1 + 10 = 21.5 \text{ ms}.

Stop-and-wait gives U=1/21.5≈0.0465U = 1/21.5 \approx 0.0465, and a window of 10 gives U=10/21.5≈0.465U = 10/21.5 \approx 0.465. Full utilisation now needs W≥21.5W \ge 21.5, so W=22W = 22: the window of 21 that was enough in Example 2 reaches only 21/21.5≈0.97721/21.5 \approx 0.977.

Example 8: retransmissions when one frame is lost

Frames 1 to nn, window WW, only frame ii lost (once), ACKs never lost, and a timeout long enough for the sender to fill its window before the timer fires.

  • GBN. By the timeout the sender has sent frames ii to min⁡(i+W−1,n)\min(i + W - 1, n); the receiver discarded all of them, so all are resent: n+min⁡(W,n−i+1)n + \min(W, n - i + 1) transmissions.
  • SR. Only frame ii is resent: n+1n + 1 transmissions.

With n=10n = 10 and W=4W = 4: losing frame 6 costs GBN 10+4=1410 + 4 = 14 transmissions (6, 7, 8 and 9 are sent again), losing frame 9 costs 10+2=1210 + 2 = 12 (only 9 and 10 are behind it), and SR needs 11 in both cases. If the timer fires before the window is full, fewer frames are outstanding and GBN resends fewer; the question must then give the timing, and the frames are traced one by one.

Example 9: unequal windows in Selective Repeat

With k=3k = 3 (numbers 0 to 7) and a receiver window Wr=3W_r = 3, the rule Ws+Wr≤2kW_s + W_r \le 2^k allows Ws≤5W_s \le 5. With Ws=6W_s = 6 it fails: the receiver accepts 0 to 5 and its window moves to {6,7,0}\{6, 7, 0\}; if all six ACKs are lost, the resent old frame 0 falls inside the new window and is accepted as new. Wr=1W_r = 1 is the Go-Back-N case (Ws≤7W_s \le 7); equal windows give W≤4W \le 4.

Example 10: piggybacking with a one-bit window

Both stations always have data and use a one-bit sliding window with piggybacked ACKs only: a station sends its next frame, carrying the ACK, as soon as a frame from the other side has fully arrived. On the link of Example 1, A sends at 0; its frame has fully arrived at B at Tt+Tp=11T_t + T_p = 11 ms, when B sends its own frame with the ACK; that frame reaches A at 22 ms, when A sends its next frame. Each station sends one frame every 2(Tt+Tp)=222(T_t + T_p) = 22 ms, so each direction has U=1/22≈0.0455U = 1/22 \approx 0.0455, the same as stop-and-wait with an ACK as long as a data frame (Example 1): an ACK cannot be read until the whole frame carrying it has arrived. The gain is that no separate ACK frames are sent and both directions carry data.

Important properties and observations

  • Stop-and-wait is GBN and SR with W=1W = 1. All three formulas agree at W=1W = 1: U=1/(1+2a)U = 1/(1 + 2a).
  • Large aa needs large windows. Satellite links and fast long-haul links have a≫1a \gg 1; stop-and-wait is hopeless there.
  • Timeout choice. Too short: needless duplicates. Too long: idle link after a loss. It must exceed the full round trip.
  • GBN versus SR under errors. On a clean link they perform the same. With losses, GBN wastes up to WW frames per loss; SR wastes one.
  • Sequence numbers wrap. Every comparison is modulo 2k2^k; window limits exist precisely to make the modular comparison unambiguous.

Common misconceptions.

  • "GBN window is 2k2^k." It is at most 2k−12^k - 1.
  • "SR window is 2k−12^k - 1." With equal windows it is at most 2k−12^{k-1}.
  • "Efficiency is 1/(1+a)1/(1+a)." With a=Tp/Tta = T_p/T_t the round trip gives 1/(1+2a)1/(1+2a). A book that defines aa as the round-trip time over TtT_t writes 1/(1+a)1/(1+a) for the same thing.
  • "The receiver window in GBN is NN." It is 1.

GATE examination perspective

  • Definition of aa first. Write TtT_t and TpT_p in the same unit, then a=Tp/Tta = T_p/T_t; efficiency W/(1+2a)W/(1+2a) capped at 1.
  • Window to fill the pipe. W=⌈1+2a⌉W = \lceil 1 + 2a \rceil frames; then convert to bits with the GBN or SR rule.
  • Maximum window from bits. GBN 2k−12^k - 1, SR 2k−12^{k-1}; a question that gives WrW_r for SR uses Ws+Wr≤2kW_s + W_r \le 2^k.
  • Retransmission counting. Fix the conventions, then trace. GBN resends all outstanding frames after a loss; SR resends one.
  • Throughput with losses. Multiply by 1−p1 - p for stop-and-wait with probability pp of losing a frame.
  • Extra delays in the cycle. Add ACK transmission and processing times only when given, then recompute both UU and the window that fills the link (Example 7).
  • One lost frame. GBN needs n+min⁡(W,n−i+1)n + \min(W, n - i + 1) transmissions when the window fills before the timeout; SR needs n+1n + 1 (Example 8).
  • Piggybacking saves ACK frames; it does not change the window limits.

Summary

Sources

  1. A. S. Tanenbaum, D. J. Wetherall, Computer Networks, 5th ed., Pearson, 2011, Section 3.3 (Elementary Data Link Protocols, including 3.3.3 A Simplex Stop-and-Wait Protocol for a Noisy Channel) and Section 3.4 (3.4.1 A One-Bit Sliding Window Protocol, 3.4.2 A Protocol Using Go-Back-N, 3.4.3 A Protocol Using Selective Repeat).
  2. J. F. Kurose, K. W. Ross, Computer Networking: A Top-Down Approach, 8th ed., Pearson, 2021: Section 3.4 (3.4.1 Building a Reliable Data Transfer Protocol, 3.4.2 Pipelined Reliable Data Transfer Protocols, 3.4.3 Go-Back-N (GBN), 3.4.4 Selective Repeat (SR)).
  3. B. A. Forouzan, Data Communications and Networking, 5th ed., McGraw-Hill, 2013: Chapter 11 (Data Link Control).

Next steps