🚀 Tutorial 5: Pipelined Protocols – Go‑Back‑N and Selective Repeat (Advanced)

University‑level treatment – COMP347 (TrustOpen University)

Table of Contents

🎯 Learning Objectives

After completing this tutorial, you should be able to:

🔍 Overview

Stop‑and‑wait, while correct, suffers from poor link utilization due to the idle waiting period between transmissions. Pipelined protocols allow multiple packets to be in flight simultaneously, significantly improving throughput. This tutorial covers two classic pipelined error‑recovery protocols: Go‑Back‑N (GBN) and Selective Repeat (SR). Both are foundational to understanding how TCP achieves high performance. We will examine their sender and receiver behaviours, window management, sequence number requirements, and performance characteristics, and we will discuss their influence on modern transport protocols.

📘 1. Motivation for Pipelining

As we saw in Tutorial 4, stop‑and‑wait utilization is U = t_trans / (t_trans + 2*t_prop). For high‑bandwidth, long‑delay links, this ratio is extremely small. The solution is to allow multiple packets to be transmitted before waiting for acknowledgments. This is achieved by pipelining: the sender can send up to N packets without waiting for an ACK, where N is the window size.

Pipelining increases throughput by filling the network pipe. However, it introduces complexity in error recovery:

Two main approaches emerged: Go‑Back‑N (simple receiver) and Selective Repeat (efficient retransmissions).

📘 2. General Pipelined Protocol Architecture

In a pipelined protocol, both sender and receiver maintain a window of sequence numbers. The sender window defines the range of packets that can be sent without waiting for ACKs. The receiver window defines which packets are acceptable to receive (and buffer).

Pipelining relies on sequence numbers of sufficient bits to uniquely identify packets in flight and avoid confusion after wraparound.

📘 3. Go‑Back‑N (GBN) – Detailed Analysis

3.1 Sender Operation

3.2 Receiver Operation

3.3 Advantages and Disadvantages

Figure 1: GBN Sender FSM (Simplified)

+-----------------------------------+
|  Wait for call from above         |
|  (ready)                          |
+-----------------------------------+
   | event: rdt_send(data) if window not full
   | action: make_packet, send, if first packet start timer
   v
+-----------------------------------+
|  Wait for ACK / timeout           |
|  (window in flight)               |
+-----------------------------------+
   | event: rdt_rcv(ACK, acknum)
   | action: if acknum > base, slide base = acknum;
   |         if base == nextseqnum, stop timer; else restart timer
   | event: timeout
   | action: retransmit all from base to nextseqnum-1, restart timer
        

📘 4. Selective Repeat (SR) – Detailed Analysis

4.1 Sender Operation

4.2 Receiver Operation

4.3 Advantages and Disadvantages

📘 5. Sequence Number Space and Window Size Constraints

With finite‑bit sequence numbers, the window size cannot be arbitrarily large; otherwise, ambiguous situations arise when sequence numbers wrap around. The constraints differ for GBN and SR.

5.1 GBN Constraint

For GBN, the receiver discards out‑of‑order packets and sends duplicate ACKs. The sender may receive duplicate ACKs, but it only slides the window on a new cumulative ACK. To avoid ambiguity when a packet is retransmitted, we need Window size ≤ (Sequence number space) – 1.

With k‑bit sequence numbers, max window size = 2k – 1. For example, with 3 bits (0–7), max window = 7.

Why? If window size equals 2k, the sender could have all sequence numbers outstanding, and a delayed ACK for the first packet could be mistaken for an ACK for the retransmitted packet with the same sequence number.

5.2 SR Constraint

For SR, the receiver buffers out‑of‑order packets and uses individual ACKs. To avoid ambiguity between new packets and retransmissions, the window size must be ≤ half the sequence number space.

With k‑bit sequence numbers, max window size = 2k‑1. For example, with 3 bits, max window = 4.

Why? If window size > 2k‑1, after a wraparound, a packet could be mistaken for a new packet when ACKs are lost. The half‑space ensures that the sender and receiver windows do not overlap in a way that causes ambiguity.

5.3 Practical Implications

In TCP, sequence numbers are 32 bits, so the window size is limited by the 16‑bit window field in the TCP header (up to 65535), but with window scaling (RFC 1323), the effective window can be larger. TCP uses a variant of Selective Repeat (with SACK) but historically used cumulative ACKs.

📘 6. Performance Comparison: GBN vs. SR

6.1 Throughput Models

Assume a loss probability p for each packet (independent), window size N, and RTT.

For a given loss rate, SR yields higher throughput because it retransmits less. However, GBN is simpler to implement.

6.2 Impact of Window Size

Larger windows improve utilization but increase the cost of a loss in GBN (more retransmissions). In SR, larger windows improve throughput but require more buffering and timers.

6.3 Impact of Loss Pattern

If losses are bursty, GBN may suffer greatly because many packets need retransmission. SR performs better because only the lost packets are retransmitted, but it relies on accurate ACKs.

6.4 Complexity Comparison

AspectGBNSR
Receiver bufferingNoneYes (up to N)
Sender timersSingle (oldest)Multiple (one per outstanding packet)
ACK typeCumulativeIndividual
RetransmissionEntire windowSpecific packets
Memory at receiverMinimalPotentially high

📘 7. Advanced Topics: Dynamic Windows, SACK, and TCP Influences

7.1 Dynamic Window Sizing

In practice, the window size is often dynamic to adapt to network conditions (congestion control). TCP uses a congestion window (cwnd) that grows and shrinks based on loss signals. The concepts of GBN and SR are reflected in TCP's mechanisms: cumulative ACKs (GBN style) and fast retransmit (similar to SR's selective retransmission, especially with SACK).

7.2 Selective Acknowledgment (SACK)

TCP SACK (RFC 2018) allows the receiver to acknowledge non‑contiguous blocks of data, effectively enabling selective retransmission without the complexity of full SR at the transport layer. This bridges the gap between GBN and SR.

7.3 Impact of Out‑of‑Order Buffering

SR's receiver buffering requires memory and careful management to avoid head‑of‑line blocking. This is a key design consideration in high‑performance systems.

7.4 Relationship to TCP

TCP uses a sliding window with cumulative ACKs (like GBN) but also implements fast retransmit (which is SR‑like) when it receives 3 duplicate ACKs. This hybrid approach combines the simplicity of cumulative ACKs with the efficiency of selective retransmission for some losses.

📝 Quiz

Test your understanding with these 30 questions. Answers are hidden below each.

  1. What is the main advantage of pipelining over stop‑and‑wait?
    AnswerIt allows multiple packets to be in flight, increasing link utilization and throughput.
  2. In Go‑Back‑N, what does the sender do when a timeout occurs?
    AnswerIt retransmits all packets from the base to the current nextseqnum (the entire window).
  3. What type of ACK does Go‑Back‑N use?
    AnswerCumulative ACK.
  4. In Selective Repeat, what does the sender do when a timeout occurs for a specific packet?
    AnswerIt retransmits only that specific packet.
  5. What type of ACK does Selective Repeat use?
    AnswerIndividual ACKs for each packet.
  6. Does the receiver in Go‑Back‑N buffer out‑of‑order packets?
    AnswerNo, it discards them.
  7. Does the receiver in Selective Repeat buffer out‑of‑order packets?
    AnswerYes, it buffers them until the missing ones arrive.
  8. With 4‑bit sequence numbers, what is the maximum window size for Go‑Back‑N?
    Answer24 – 1 = 15.
  9. With 4‑bit sequence numbers, what is the maximum window size for Selective Repeat?
    Answer24‑1 = 8.
  10. Why does Selective Repeat require a window size ≤ half the sequence number space?
    AnswerTo avoid ambiguity between new packets and retransmissions when sequence numbers wrap around.
  11. In Go‑Back‑N, why is the window size limited to 2k – 1?
    AnswerTo avoid confusion when a delayed ACK for a packet with the same sequence number is mistaken for a new ACK.
  12. Which protocol is more efficient when the packet loss rate is high?
    AnswerSelective Repeat, because it retransmits only lost packets.
  13. Which protocol is simpler to implement?
    AnswerGo‑Back‑N, because the receiver has no buffering and the sender uses a single timer.
  14. In Go‑Back‑N, how does the receiver handle a corrupted packet?
    AnswerIt discards it and does not send an ACK; the sender will timeout and retransmit.
  15. In Selective Repeat, how does the receiver handle a corrupted packet?
    AnswerIt discards it; the sender will timeout for that packet and retransmit it.
  16. What is a cumulative ACK?
    AnswerAn ACK that acknowledges all packets up to a given sequence number.
  17. What is an individual ACK?
    AnswerAn ACK that acknowledges a specific packet by its sequence number.
  18. In Go‑Back‑N, what happens when the receiver receives an out‑of‑order packet?
    AnswerIt discards the packet and sends a duplicate ACK for the last in‑order packet.
  19. In Selective Repeat, what happens when the receiver receives an out‑of‑order packet?
    AnswerIt buffers the packet and sends an individual ACK for it.
  20. How does the sender in Selective Repeat know which packets have been acknowledged?
    AnswerIt maintains a record of ACKs received for each packet in the window.
  21. How does the sender in Go‑Back‑N know which packets have been acknowledged?
    AnswerIt uses the base pointer; all packets before base are acknowledged.
  22. In Go‑Back‑N, what does the sender do when it receives a duplicate ACK?
    AnswerIt ignores it (unless it triggers a fast retransmit in some variants, but that is not part of basic GBN).
  23. In Selective Repeat, what does the sender do when it receives a duplicate ACK?
    AnswerIt ignores it (since it already has the ACK for that packet).
  24. Which protocol requires more memory at the receiver?
    AnswerSelective Repeat, because it buffers out‑of‑order packets.
  25. Which protocol is more prone to wasting bandwidth when losses occur?
    AnswerGo‑Back‑N, because it retransmits the entire window.
  26. What is the role of the timer in Go‑Back‑N?
    AnswerTo detect lost packets; a single timer for the oldest outstanding packet.
  27. What is the role of timers in Selective Repeat?
    AnswerEach outstanding packet may have its own timer to detect loss of that specific packet.
  28. Can Go‑Back‑N be used with a window size larger than 2k – 1?
    AnswerNo, it would cause ambiguity.
  29. Can Selective Repeat be used with a window size larger than 2k‑1?
    AnswerNo, it would cause ambiguity.
  30. Which protocol does TCP primarily resemble?
    AnswerTCP uses cumulative ACKs (like GBN) but also incorporates selective retransmission via fast retransmit and SACK, making it a hybrid.

🛠️ Exercises

Apply your knowledge with these 15 exercises. Solutions are provided below each.

  1. Exercise 1: GBN Retransmission
    Suppose GBN with window size N=4. Sender sends packets 0,1,2,3. Packet 1 is lost. Describe the sender and receiver actions.
    SolutionReceiver gets packet 0 (ACK 0), packet 2 and 3 are out of order, so they are discarded and duplicate ACKs (ACK 0) are sent. Sender times out, retransmits packets 1,2,3.
  2. Exercise 2: SR Retransmission
    Using SR with window size N=4, packets 0,1,2,3 sent. Packet 2 lost. Describe the actions.
    SolutionReceiver gets 0,1,3; sends ACK 0,1,3; buffers 3. Sender gets ACKs, slides window to 4,5,6,7, but packet 2 still unacknowledged. Timer for 2 expires; retransmit only 2. Receiver gets 2, delivers in order.
  3. Exercise 3: Window Size Calculation
    With 5‑bit sequence numbers, what are the maximum sender window sizes for GBN and SR?
    Solution5 bits → 32 seq numbers. GBN max = 31, SR max = 16.
  4. Exercise 4: GBN Duplicate ACK
    In GBN, why does the receiver send duplicate ACKs for out‑of‑order packets?
    SolutionTo inform the sender that it is still expecting the next in‑order packet and to help detect losses (used later for fast retransmit in TCP).
  5. Exercise 5: SR Window Slide
    In SR, sender window base = 2, nextseqnum = 6, N=4. Which sequence numbers are in the window?
    SolutionWindow: [2, 3, 4, 5].
  6. Exercise 6: GBN Timer
    In GBN, how many timers does the sender maintain? Why?
    SolutionOne timer for the oldest unacknowledged packet. Since all outstanding packets are retransmitted together, a single timer suffices.
  7. Exercise 7: SR Timer Management
    In SR, the sender has 5 outstanding packets. How many timers might be active?
    SolutionUp to 5 (one per packet), though a single timer per packet is common.
  8. Exercise 8: GBN and ACK Loss
    In GBN, if an ACK for packet 0 is lost, but ACK for packet 1 arrives, what happens?
    SolutionThe cumulative ACK for packet 1 acknowledges both 0 and 1, so the sender slides base to 2. The lost ACK is harmless.
  9. Exercise 9: SR and ACK Loss
    In SR, if ACK for packet 0 is lost, but ACK for packet 1 arrives, what happens to packet 0?
    SolutionSender still has packet 0 marked as unacknowledged; it will timeout and retransmit packet 0. The ACK for packet 1 does not acknowledge packet 0.
  10. Exercise 10: Throughput Comparison
    For a loss rate of 1%, which protocol (GBN or SR) would have higher throughput? Briefly explain.
    SolutionSR would have higher throughput because it only retransmits the lost packet, while GBN retransmits the entire window, wasting bandwidth.
  11. Exercise 11: GBN with Large Window
    If GBN window size is 8 and sequence numbers are 3 bits, what problem occurs?
    SolutionWindow size equals 23 = 8, which is not allowed (max is 7). Ambiguity can arise when sequence numbers wrap.
  12. Exercise 12: SR with Large Window
    If SR window size is 5 and sequence numbers are 3 bits, is this valid?
    SolutionNo, max for SR with 3 bits is 4 (22). Window size 5 violates the half‑space constraint.
  13. Exercise 13: GBN Receiver State
    In GBN, if the receiver receives a packet with sequence number 5 but expected sequence number is 4, what does it do?
    SolutionIt discards packet 5 and sends a duplicate ACK for sequence 4.
  14. Exercise 14: SR Receiver Buffering
    In SR, if receiver window size is 4 and expected seq is 2, which sequence numbers are in the window?
    Solution[2, 3, 4, 5].
  15. Exercise 15: Hybrid Approach
    How does TCP combine GBN and SR features?
    SolutionTCP uses cumulative ACKs (like GBN) for most acknowledgments, but implements fast retransmit (when 3 duplicate ACKs are received) which selectively retransmits the lost packet (like SR). With SACK, TCP can explicitly acknowledge non‑contiguous blocks, enabling full selective retransmission.

📚 Homework

These advanced problems require synthesis, quantitative analysis, and research. Sample answers are provided below.

  1. Problem 1: Derive GBN Throughput with Loss
    Derive an expression for the throughput of GBN as a function of packet loss probability p, window size N, and RTT. Assume that losses are independent and timeouts are rare. Hint: consider the expected number of transmissions per packet.
    Sample AnswerLet p be loss probability. In GBN, when a packet is lost, N packets are retransmitted. The expected number of transmissions per successfully delivered packet is approximately 1/(1-p) * (1 + N*p*(1-p)?). A simplified model: throughput ≈ (1-p) * N * MSS / RTT, but with a penalty of (1 + (N-1)*p) due to retransmission overhead. More precise models can be found in networking literature.
  2. Problem 2: SR Throughput with Loss
    For SR, derive the expected number of transmissions per packet and the throughput. Assume independent losses.
    Sample AnswerExpected transmissions per packet = 1/(1-p). Throughput ≈ N * MSS / (RTT * (1 + overhead)) but since each packet is independent, the link can be fully utilised if N is large enough to fill the pipe. However, the need for individual ACKs adds overhead.
  3. Problem 3: Sequence Number Space Design
    Suppose you are designing a new reliable protocol with pipelining that uses selective retransmission. You need to support a window size of 16. What is the minimum number of sequence bits required?
    Sample AnswerFor SR, window ≤ 2k‑1. To get ≥16, we need 2k‑1 ≥ 16 → k‑1 ≥ 4 → k ≥ 5. So 5 bits.
  4. Problem 4: GBN vs SR Memory Requirements
    Compare the memory requirements of the receiver for GBN and SR when the window size is N and each packet is L bytes. Which is more memory‑intensive?
    Sample AnswerGBN receiver requires no buffering (0 bytes). SR receiver may buffer up to N packets, requiring N*L bytes. Thus SR is much more memory‑intensive.
  5. Problem 5: Impact of Bursty Loss
    If losses occur in bursts (e.g., a router drops 3 consecutive packets), how does GBN vs SR perform?
    Sample AnswerGBN will retransmit the entire window after the first loss, which may include many packets, some of which may already be lost again. SR will retransmit each lost packet individually, which can be more efficient if losses are infrequent. For burst losses, GBN's retransmission of the whole window might actually help by sending all packets again, but it wastes bandwidth for packets that were not lost.
  6. Problem 6: Timer Granularity in GBN
    If the timer in GBN is coarse (e.g., can only be set in multiples of 100 ms), how does this affect performance?
    Sample AnswerA coarse timer may cause the sender to wait longer than necessary before retransmitting, reducing throughput. It may also lead to unnecessary retransmissions if the timer is too short, causing spurious retransmissions.
  7. Problem 7: Selective Repeat with Cumulative ACKs
    Could Selective Repeat use cumulative ACKs? What would be the implications?
    Sample AnswerSR could use cumulative ACKs, but then the sender would not know which specific packets were lost unless it also uses NAKs or timeouts. Cumulative ACKs would reduce the granularity of feedback, potentially causing more retransmissions. The protocol would become closer to GBN.
  8. Problem 8: GBN with Piggybacked ACKs
    If data flows in both directions, ACKs can be piggybacked on data packets. How does this affect GBN?
    Sample AnswerPiggybacking reduces the number of separate ACK packets, saving bandwidth. However, the sender still relies on the cumulative ACK to slide the window, so the same loss recovery rules apply.
  9. Problem 9: Window Size and Delay
    How does the window size affect the end‑to‑end delay (latency) for a large file transfer?
    Sample AnswerA larger window allows more data to be in flight, which can reduce the time to send the file (higher throughput), but it may increase the time to recover from losses because more data may need to be retransmitted (especially in GBN).
  10. Problem 10: Adaptive Window Sizing
    Propose a heuristic to dynamically adjust the window size in GBN or SR based on observed loss rate.
    Sample AnswerIf loss rate is low, increase window size to improve throughput. If loss rate exceeds a threshold, decrease window size to reduce the cost of retransmissions. This is analogous to TCP's congestion control.
  11. Problem 11: Receiver Window in SR
    In SR, the receiver window size can be the same as the sender's, or larger. What happens if the receiver window is smaller?
    Sample AnswerIf receiver window < sender window, the receiver may not accept certain in‑flight packets, causing unnecessary discards. The receiver window must be at least as large as the sender window to accept all packets in the sender's window.
  12. Problem 12: GBN with Fast Retransmit
    How would you add fast retransmit to GBN to improve performance?
    Sample AnswerInstead of waiting for a timeout, if the sender receives N duplicate ACKs (typically 3), it could immediately retransmit the oldest unacknowledged packet. This would reduce recovery time for single packet losses, similar to TCP.
  13. Problem 13: SR and Duplicate ACKs
    In SR, why might a receiver send a duplicate ACK for a packet it already acknowledged?
    Sample AnswerIf the sender retransmits a packet that the receiver already has (e.g., because the original ACK was lost), the receiver will send a duplicate ACK to confirm its receipt. This helps the sender know that the packet is acknowledged.
  14. Problem 14: Performance under High RTT
    For a satellite link with high RTT (500 ms) and low loss, which protocol would you choose? Justify.
    Sample AnswerBoth protocols would benefit from pipelining, but SR would be preferred because any loss would cause GBN to waste a lot of bandwidth retransmitting many packets. With low loss, SR's overhead is acceptable.
  15. Problem 15: Formal Specification
    Write a formal specification of the SR receiver FSM, including states, events, and actions.
    Sample AnswerStates: Wait for packet (expected = e). On arrival with seq = e: deliver, send ACK for e, e++ until all buffered consecutive packets delivered. On arrival with seq within window and seq != e: buffer, send ACK for seq. On arrival out of window: discard.

📌 Summary

In the next tutorial, we will examine TCP Fundamentals and Segment Structure, applying the principles of pipelining to the real‑world transport protocol.

COMP347 – Computer Networks (Rev. 10) · TrustOpen University · Based on Kurose & Ross, Computer Networking: A Top‑Down Approach, 9th ed. (2025).