📡 Tutorial 4: Principles of Reliable Data Transfer – Advanced

University‑level treatment – COMP347 (TrustOpen University)

Table of Contents

🎯 Learning Objectives

After completing this tutorial, you should be able to:

🔍 Overview

Reliable data transfer (RDT) is a fundamental problem in computer networking. The network layer (IP) provides a best‑effort service: packets may be lost, corrupted, or reordered. The transport layer must mask these imperfections and provide a reliable, ordered, error‑free service to applications. This tutorial systematically develops the principles of RDT, starting from simple protocols and gradually adding mechanisms to handle increasingly complex failure scenarios. We use finite‑state machines to rigorously specify protocol behaviour, and we analyse the performance of stop‑and‑wait protocols to understand why more sophisticated pipelined protocols are needed for modern networks.

📘 1. The Reliable Data Transfer Problem

Consider a sender that wants to send a stream of data to a receiver across an unreliable channel. The channel may:

The goal of a reliable data transfer protocol is to ensure that the receiver delivers an exact, in‑order copy of the sender’s data to the application, despite these imperfections. The protocol operates at the transport layer, using the network layer’s unreliable service.

We abstract the sender and receiver as two processes that exchange messages (packets) over an unreliable channel. The protocol is defined by the actions taken upon events: data from the application, packet arrival from the network, and timeout expiration.

📘 2. Formal Modeling with Finite‑State Machines

A finite‑state machine (FSM) is a mathematical model used to specify the behaviour of a protocol. It consists of:

For a reliable data transfer protocol, we typically model the sender and receiver separately. Each has an FSM that describes its response to events. For example, the sender might have states: Wait for data from application, Wait for ACK, etc. Transitions occur on events like rdt_send(data) (application calls send), rdt_rcv(packet) (a packet arrives from the network), and timeout.

FSMs are crucial for proving correctness and detecting design flaws. They are also used in protocol specification documents.

Figure 1: Generic Sender FSM Structure

+-----------------------------------+
|  Wait for call from above         |
|  (state: ready)                   |
+-----------------------------------+
   | event: rdt_send(data)
   | action: make_packet, send, start_timer
   v
+-----------------------------------+
|  Wait for ACK/NAK                 |
|  (state: waiting)                 |
+-----------------------------------+
   | event: rdt_rcv(ACK)
   | action: stop_timer, deliver to app, go to ready
   | event: rdt_rcv(NAK) or timeout
   | action: retransmit, restart_timer, stay in waiting
        

📘 3. Basic Mechanisms

3.1 Error Detection

To detect corrupted packets, we add a checksum field to the packet. The receiver verifies the checksum; if it fails, the packet is discarded. This is the first line of defence against bit errors.

3.2 Acknowledgments (ACKs) and Negative Acknowledgments (NAKs)

Using ACKs, the sender knows when to send the next packet. Using NAKs, the sender can retransmit a corrupted packet without waiting for a timeout (though timeouts are still needed for lost packets).

3.3 Sequence Numbers

Sequence numbers are used to distinguish between different packets, especially when retransmissions occur. Without sequence numbers, the receiver could not tell if an incoming packet is a new packet or a duplicate. For stop‑and‑wait, a 1‑bit sequence number (0 and 1) is sufficient because only one packet is outstanding at a time.

3.4 Timeouts and Retransmissions

If a packet or its ACK is lost, the sender will never receive an acknowledgment. To recover, the sender sets a timer when sending a packet. If the timer expires before an ACK arrives, the sender retransmits the packet. This is the fundamental mechanism for handling packet loss.

📘 4. Stop‑and‑Wait Protocol (rdt3.0)

The stop‑and‑wait protocol (also called rdt3.0) is the simplest reliable protocol that handles packet loss and corruption. It works as follows:

The sender FSM has two main states: Wait for call from above (ready to send) and Wait for ACK (packet sent, timer running). The receiver FSM has one state: Wait for packet.

The protocol handles:

Despite its correctness, stop‑and‑wait is inefficient for high‑bandwidth or long‑distance networks because the sender spends most of the time waiting for ACKs.

📘 5. Performance Analysis of Stop‑and‑Wait

The performance of stop‑and‑wait is determined by the utilization (or efficiency) of the link:

U = t_trans / (t_trans + 2 * t_prop)

where:

This formula ignores the time to transmit the ACK (which is usually small).

The maximum throughput is U * R. For example, with a 1 Gbps link, 100 ms RTT, and 1500‑byte packets, the utilization is about 0.012%, meaning the effective throughput is only ~120 kbps. This is clearly insufficient.

The key limitation is the bandwidth‑delay product: the amount of data that can be in transit (BDP = R * RTT). For stop‑and‑wait to fully utilise the link, the packet size must be at least as large as BDP, which is often impractical.

📘 6. The Bandwidth‑Delay Product and Link Utilization

The bandwidth‑delay product (BDP) is the number of bits that can be in the pipeline (in transit) at any time. To achieve 100% utilization, the sender must have enough data in flight to fill the pipe. In stop‑and‑wait, the amount of data in flight is at most one packet. If the packet size is smaller than BDP, the link is underutilized.

To improve utilization, we need a protocol that allows multiple packets to be outstanding simultaneously – a pipelined protocol. This is the motivation for Go‑Back‑N and Selective Repeat, covered in the next tutorial.

📘 7. Limitations and the Need for Pipelining

Stop‑and‑wait has several drawbacks:

These limitations led to the development of pipelined protocols, where the sender can transmit multiple packets before waiting for ACKs. The window size determines how many packets can be in flight, allowing the sender to fill the BDP. We will explore Go‑Back‑N and Selective Repeat in Tutorial 5.

📘 8. Advanced Topics: Duplicate Suppression and Cumulative ACKs

8.1 Duplicate Suppression

In stop‑and‑wait, sequence numbers (0 and 1) are sufficient to avoid ambiguity between a new packet and a retransmission. However, if the sender receives a duplicate ACK (e.g., because the receiver sent an ACK that was delayed), the sender must ignore it. The FSM design ensures that duplicate ACKs are simply ignored because the sender only transitions on the first ACK.

8.2 Cumulative ACKs (preview)

In pipelined protocols, cumulative ACKs (where an ACK acknowledges all packets up to a sequence number) reduce the number of ACKs sent and simplify receiver logic. This concept is central to TCP and will be covered in detail later.

8.3 Timer Management

In stop‑and‑wait, a single timer is sufficient. In pipelined protocols, multiple timers or a single timer for the oldest packet may be used (as in Go‑Back‑N). The choice affects performance.

📝 Quiz

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

  1. What is the primary goal of a reliable data transfer protocol?
    AnswerTo deliver an exact, in‑order copy of the sender's data to the receiver despite packet corruption, loss, reordering, or duplication.
  2. What is the role of a checksum in reliable data transfer?
    AnswerTo detect bit errors in a received packet.
  3. What is an ACK and what is a NAK?
    AnswerACK = positive acknowledgment; NAK = negative acknowledgment, indicating corruption.
  4. Why are sequence numbers needed in reliable protocols?
    AnswerTo distinguish between new packets and retransmissions, and to detect duplicates.
  5. How does the sender detect packet loss in a stop‑and‑wait protocol?
    AnswerUsing a timeout; if an ACK does not arrive within a specified time, the sender retransmits the packet.
  6. What is the minimum number of sequence bits needed for stop‑and‑wait?
    Answer1 bit (0 and 1) because only one packet is outstanding.
  7. In stop‑and‑wait, what happens if a packet is corrupted?
    AnswerThe receiver discards it (silently) and does not send an ACK. The sender times out and retransmits.
  8. How does stop‑and‑wait handle duplicate packets?
    AnswerThe receiver uses the sequence number to detect duplicates; if the sequence number is the same as the last received, it discards the packet but sends an ACK.
  9. Define utilization in the context of stop‑and‑wait.
    AnswerThe fraction of time the sender is actually transmitting data, i.e., t_trans / (t_trans + 2*t_prop).
  10. What is the bandwidth‑delay product?
    AnswerThe amount of data that can be in transit in the network at any time, equal to bandwidth multiplied by RTT.
  11. Why is stop‑and‑wait inefficient for high‑speed networks?
    AnswerBecause the sender spends most of its time waiting for ACKs, resulting in low link utilization.
  12. What is the effect of a long RTT on stop‑and‑wait performance?
    AnswerIt increases the waiting time, reducing utilization and effective throughput.
  13. How can the utilization of stop‑and‑wait be improved?
    AnswerBy increasing the packet size (L) or decreasing propagation delay, but fundamentally a pipelined protocol is needed.
  14. What is a finite‑state machine (FSM) and why is it used in protocol design?
    AnswerAn FSM is a model of states and transitions; it is used to rigorously specify and verify protocol behaviour.
  15. In the sender FSM for stop‑and‑wait, what event triggers the transition from "Wait for ACK" to "Wait for call from above"?
    AnswerThe receipt of an ACK for the sent packet.
  16. What event keeps the sender in the "Wait for ACK" state?
    AnswerTimeout or receipt of a NAK (or corrupted ACK).
  17. How does the receiver FSM handle a corrupted packet?
    AnswerIt discards the packet and remains in the same state, waiting for a new packet.
  18. Is a NAK strictly necessary in stop‑and‑wait?
    AnswerNo; the protocol can rely on timeouts for both corruption and loss, as in rdt3.0 which does not use NAKs.
  19. What is the purpose of the timer in the sender?
    AnswerTo trigger retransmission if an ACK is not received within a reasonable time, handling loss.
  20. How does the receiver distinguish between a duplicate packet and a new packet?
    AnswerBy comparing the sequence number of the received packet with the sequence number of the last packet it accepted.
  21. In stop‑and‑wait, can the sender send a new packet before receiving an ACK?
    AnswerNo, it must wait for the ACK.
  22. What is the maximum throughput of a stop‑and‑wait link with bandwidth R and packet size L?
    AnswerThroughput = (L / (L/R + RTT)) = R * (L / (L + R*RTT)).
  23. What happens if the ACK is lost in stop‑and‑wait?
    AnswerThe sender times out and retransmits the packet. The receiver gets a duplicate, discards it, but sends another ACK.
  24. What is the main drawback of using a single timer in stop‑and‑wait?
    AnswerSince only one packet is outstanding, a single timer is sufficient, but it cannot be reused for pipelining.
  25. How does stop‑and‑wait handle packet reordering?
    AnswerSince only one packet is outstanding, reordering is not a problem; the protocol treats any out‑of‑order arrival as an error and discards.

🛠️ Exercises

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

  1. Exercise 1: Utilization Calculation
    A stop‑and‑wait protocol uses 1000‑byte packets on a 10 Mbps link with a propagation delay of 20 ms. What is the maximum utilization?
    Solutiont_trans = (1000*8)/10e6 = 0.0008 s = 0.8 ms. t_prop = 20 ms. RTT = 40 ms. U = 0.8 / (0.8 + 40) = 0.8/40.8 ≈ 0.0196 = 1.96%.
  2. Exercise 2: Throughput Calculation
    Using the same parameters as Exercise 1, what is the effective throughput?
    SolutionThroughput = U * R = 0.0196 * 10 Mbps ≈ 196 kbps.
  3. Exercise 3: Packet Size for Full Utilization
    For a 1 Gbps link with RTT = 50 ms, what packet size (in bytes) is needed for stop‑and‑wait to achieve 100% utilization?
    SolutionFor U=1, L = R * RTT = 1e9 * 0.05 = 50,000,000 bits = 6.25 MB. This is impractical.
  4. Exercise 4: Bandwidth‑Delay Product
    A link has bandwidth 100 Mbps and RTT = 40 ms. What is the bandwidth‑delay product in bits and bytes?
    SolutionBDP = 100e6 * 0.04 = 4,000,000 bits = 500,000 bytes.
  5. Exercise 5: FSM Transition
    In stop‑and‑wait, the sender is in "Wait for ACK" state and receives a corrupted ACK. What does it do?
    SolutionIt ignores the ACK (since it's corrupted) and stays in "Wait for ACK"; the timer will eventually expire and it will retransmit.
  6. Exercise 6: Duplicate Packet Handling
    In stop‑and‑wait, the receiver receives a packet with sequence number 0, but it already accepted a packet with sequence number 0 earlier. What does the receiver do?
    SolutionIt discards the duplicate packet and sends an ACK for sequence number 0 again.
  7. Exercise 7: Loss Recovery
    Suppose the sender sends packet 0, the packet is lost. Describe the sequence of events until packet 0 is successfully delivered.
    SolutionSender times out, retransmits packet 0. Receiver gets it, sends ACK 0. Sender receives ACK, moves to next packet.
  8. Exercise 8: ACK Loss Recovery
    Sender sends packet 0, receiver gets it and sends ACK 0, but the ACK is lost. What happens?
    SolutionSender times out, retransmits packet 0. Receiver gets duplicate, sends ACK 0 again. Sender gets ACK, moves on.
  9. Exercise 9: Timer Granularity
    If the timer resolution is coarser than the actual RTT, what could happen?
    SolutionThe sender might unnecessarily delay retransmission, reducing performance, or if the timer is too long, it may not retransmit quickly enough, but correctness is maintained.
  10. Exercise 10: NAK vs Timeout
    Compare the use of NAKs vs. timeouts for error recovery in stop‑and‑wait. Which is more efficient?
    SolutionNAK can trigger faster retransmission for corrupted packets, but for lost packets, timeout is still needed. NAK adds complexity.
  11. Exercise 11: Propagation Delay Dominance
    If propagation delay is much larger than transmission time, what is the approximate utilization?
    SolutionU ≈ t_trans / (2*t_prop), which is very small.
  12. Exercise 12: Effect of Increasing Bandwidth
    If bandwidth doubles while packet size and RTT remain the same, what happens to utilization?
    Solutiont_trans halves, so U decreases (since U = t_trans / (t_trans + 2*t_prop)), making the link even less utilised.
  13. Exercise 13: Minimum Sequence Number Bits
    Why is 1 bit sufficient for stop‑and‑wait? Show that 2 bits would be redundant.
    SolutionOnly one packet is outstanding; the receiver only needs to distinguish between two possibilities: the current packet and the previous one. Thus 0 and 1 are enough.
  14. Exercise 14: FSM Design for Receiver
    Draw the receiver FSM for stop‑and‑wait (rdt3.0) indicating states and transitions on receiving packets.
    SolutionReceiver has one state: "Wait for packet". On arrival: if corrupted, discard; if seq number matches expected, deliver, send ACK, flip expected seq; else (duplicate), send ACK.
  15. Exercise 15: Impact of Processing Delay
    How would adding a non‑negligible processing delay at the receiver affect the utilization formula?
    SolutionThe effective RTT increases, reducing U further. The formula becomes U = t_trans / (t_trans + 2*t_prop + t_process).

📚 Homework

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

  1. Problem 1: Derive Utilization for Stop‑and‑Wait with ACK Transmission
    Extend the utilization formula to include the time to transmit the ACK packet (t_ack). Assume t_ack is small but non‑zero. Show the new formula.
    Sample AnswerU = t_trans / (t_trans + 2*t_prop + t_ack). The ACK transmission time adds to the idle period.
  2. Problem 2: Optimal Packet Size
    Given a link with bandwidth R and propagation delay t_prop, derive the packet size L that maximizes throughput in stop‑and‑wait, assuming overhead is negligible. Is there a trade‑off?
    Sample AnswerThroughput = L / (L/R + 2*t_prop). As L increases, throughput increases asymptotically to R. There is no finite optimum; larger L always improves utilization, but also increases latency and memory.
  3. Problem 3: Sequence Number Wrap‑Around
    In stop‑and‑wait, with 1‑bit sequence numbers, what happens if a duplicate ACK is delayed long enough that the sender has already moved to the next sequence number? Could this cause a problem?
    Sample AnswerThe sender ignores ACKs that do not match the expected sequence number. Since the protocol alternates, a delayed ACK for the previous packet will have the wrong sequence number and will be ignored, so no problem.
  4. Problem 4: Timer Granularity and Spurious Retransmissions
    If the timer is set too short, the sender may retransmit unnecessarily. What is the impact on throughput and network load?
    Sample AnswerSpurious retransmissions waste bandwidth and increase congestion, reducing effective throughput. The receiver may see duplicates, but handles them correctly.
  5. Problem 5: Lossy Channel with NAKs
    Compare the performance of a stop‑and‑wait protocol that uses NAKs vs. one that only uses timeouts, when the channel has a high bit error rate but low loss.
    Sample AnswerWith NAKs, corrupted packets are retransmitted quickly, avoiding the timeout delay. This improves throughput. However, NAKs add complexity.
  6. Problem 6: Reliable Broadcast
    Can the stop‑and‑wait protocol be extended for one‑to‑many reliable broadcast? What are the challenges?
    Sample AnswerIt would require collecting ACKs from all receivers; the sender must wait for all ACKs, or use a negative ACK approach. Scalability is a major issue.
  7. Problem 7: Unreliable ACKs
    What if ACKs themselves can be corrupted? How does stop‑and‑wait handle this?
    Sample AnswerCorrupted ACKs are treated as no ACK; the sender times out and retransmits. The receiver may get a duplicate, but handles it.
  8. Problem 8: Multi‑packet Duplicates
    In stop‑and‑wait, a duplicate packet can arrive after the sender has received the ACK and moved on. The receiver's expected sequence number will have flipped, so the duplicate is discarded. Explain.
    Sample AnswerIf sender sent packet 0 and got ACK 0, it moves to packet 1. If a delayed duplicate of packet 0 arrives, the receiver is now expecting packet 1, so it discards the duplicate and sends an ACK for packet 0 (which the sender ignores if it's already past).
  9. Problem 9: Performance with Multiple Applications
    If multiple stop‑and‑wait connections share the same link, how does the utilization scale? Compare with a single connection.
    Sample AnswerEach connection individually has low utilization, but together they may fill the link. However, they all waste time waiting for ACKs, so overall efficiency is low.
  10. Problem 10: Approaching Pipelining
    Propose a modification to stop‑and‑wait that allows sending a second packet before the ACK for the first arrives, without changing the 1‑bit sequence number. Is it possible?
    Sample AnswerNo, with 1‑bit sequence numbers, you cannot have two outstanding packets because you need to distinguish between them. You would need more sequence bits, which leads to pipelining.
  11. Problem 11: RTT Estimation
    How would you estimate RTT in stop‑and‑wait to set the timer? Discuss the challenges.
    Sample AnswerYou can measure the time from sending a packet to receiving its ACK. However, due to variable delays, use exponential smoothing (as in TCP). The challenge is to avoid unnecessary retransmissions while not waiting too long.
  12. Problem 12: Stop‑and‑Wait with Piggybacking
    If data flows in both directions, ACKs can be piggybacked on data packets. How does this affect utilization?
    Sample AnswerIt reduces the number of separate ACK packets, saving bandwidth, but does not eliminate the waiting time; the sender still cannot send new data until the piggybacked ACK arrives.
  13. Problem 13: Error Correction vs. Detection
    Why do transport protocols typically use error detection (checksum) rather than forward error correction (FEC)? Discuss the trade‑offs.
    Sample AnswerFEC adds redundancy that can correct errors without retransmission, but increases overhead. In networks with low bit error rates, detection+retransmission is more efficient.
  14. Problem 14: Stop‑and‑Wait in Space Communications
    In deep‑space communications, propagation delays can be minutes. How does stop‑and‑wait perform? What alternatives exist?
    Sample AnswerUtilization is extremely low. Protocols like Delay‑Tolerant Networking (DTN) use store‑and‑forward and bundle protocols to cope with long delays.
  15. Problem 15: Formal Verification of Stop‑and‑Wait
    Prove that stop‑and‑wait (rdt3.0) is correct: it does not deliver duplicate data and delivers data in order. Outline the proof using invariants.
    Sample AnswerInvariant: the sender's sequence number equals the receiver's expected sequence number after each successful transmission. The protocol ensures that the sender only increments after receiving an ACK for the current sequence, and the receiver only accepts a packet if its sequence matches the expected one. Thus duplicates are discarded and order is preserved.

📌 Summary

In the next tutorial, we will explore Pipelined Protocols: Go‑Back‑N and Selective Repeat, which address the performance limitations of stop‑and‑wait.

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