Reliable data transfer
A reliable data transfer protocol ensures that data:
- is not lost or corrupted
- arrives in the same order it was sent
Key parts of a reliable protocol:
- acknowledgments (positive and negative)
- checksums to detect errors
- sequence numbers to track order
- timers to handle delays or loss
Building a stop-and-wait reliable data transfer protocol
We develop a "rdt" or "Reliable Data Transfer" protocol step by step, making it more capable each time:
| Protocol | Problem | Solution | Notes |
|---|---|---|---|
rdt1.0 - Perfect channel |
Assumes a perfect network channel. |
|
No reliability mechanisms needed. |
rdt2.0 - Bit errors (ACK/NAK + checksum) |
Bits in a packet may be corrupted. |
To handle this, the receiver sends feedback to the sender via control messages:
Reliable data transfer protocols based on such retransmission are known as ARQ (Automatic Repeat reQuest) protocols. They require 3 capabilities to handle the presence of bit errors:
|
This is a stop-and-wait protocol: the sender must wait for |
rdt2.1 - Retransmission and sequence number |
|
This can trigger unnecessary retransmissions, resulting in duplicate packets. Fix to distinguish between a new or duplicate packet: add a sequence number field (1 bit: |
This allows the receiver to distinguish:
|
rdt2.2 - No NAKs (ACK-only system) |
Simplify control messages. |
Instead of using both
|
If the sender receives repeated
|
rdt3.0 - Packet loss (timers) |
Packets/ |
How to detect packet loss? The sender can wait long enough so that it is certain that a packet has been lost:
What to do when packet loss occurs?
|
Sender actions:
|
Pipelined reliable data transfer protocols
A stop-and-wait protocol is inefficient because the sender must wait for an acknowledgment after each packet.
Pipelining improves performance by allowing the sender to transmit multiple packets before receiving acknowledgments.
Pipelined protocols need more sequence numbers and buffering because multiple packets may be sent before acknowledgments arrive.
There are two main pipelined error-recovery methods:
- Go-Back-N (GBN): if a packet is lost or corrupted, the sender retransmits that packet and all subsequent packets
- Selective Repeat (SR): only the lost or corrupted packets are retransmitted
Go-Back-N (GBN)
In a GBN protocol, the sender can send up to N packets without waiting for ACKs.
The allowed sequence numbers form a window of size N:
- as packets are acknowledged, the window moves forward
Nis referred to as the window size- the GBN protocol is referred to as a sliding-window protocol
Example:
- suppose the sender has a window size of
4:- the sender sends packets
0–3 - the receiver successfully gets packets
0and1, and now expects packet2 - after receiving
ACKs for0and1, the sender's window advances and it sends packets4and5 - packet
2is lost
- the sender sends packets
- at the receiver:
- packets
3,4, and5arrive after the missing packet2 - because GBN requires in-order delivery, these packets are discarded
- the receiver does not store out-of-order packets because they will be retransmitted anyway
- packets
- at the sender:
- the
ACKfor packet2never arrives, so a timeout occurs - the sender goes back to packet
2and retransmits all packets from2to5
- the
This behavior gives Go-Back-N its name: the sender goes back to the missing packet and resends all following packets.
GBN can suffer from performance problems when both the window size and the bandwidth-delay product (BDP) are large:
- BDP is the maximum amount of data that can be "in flight" on the network at one time:
BDP (bits) = bandwidth (bits/second) × RTT (seconds)- you can think of a network link like a pipe:
- pipe length = RTT (round-trip delay)
- pipe diameter = bandwidth (link capacity)
- therefore, bandwidth × RTT = pipe volume (the amount of data the network can hold)
- when the BDP is large, many packets may be in transit simultaneously
- in GBN, a single packet error can cause a retransmission of a large number of packets, many unnecessarily
- this can potentially fill the pipeline with redundant traffic and reducing efficiency
Selective repeat (SR)
In a SR protocol:
- the sender retransmits only packets that are lost or corrupted instead of resending everything
- the receiver accepts packets out of order and buffers them until missing ones arrive
- a window of size
Nlimits the number of unacknowledged packets in transit - unlike GBN, the sender may already have
ACKs for some packets in the window
| Event | Sender | Receiver |
|---|---|---|
Packet received |
|
|
Timeout |
|
— |
|
|
— |
Sender and receiver windows are not always aligned.
This can create the SR receiver dilemma. With large windows, the receiver may not know whether a packet is a new packet or a retransmission:
- suppose:
- sequence numbers are limited to
0, 1, 2, 3 - window size is
3
- sequence numbers are limited to
- steps:
- sender sends packets
0,1,2 - receiver gets them and sends
ACKs - receiver window moves to expect
3,0,1 - however,
ACKs are lost, so sender retransmits0,1,2 - receiver receives packet
0again
- sender sends packets
- the receiver cannot tell whether this
0is:- a retransmission of the old packet
0 - a new transmission of a new packet
0after sequence numbers wrapped around
- a retransmission of the old packet
To avoid this ambiguity:
- the window size must be at most half of the sequence number space for SR protocols
- if sequence space =
4→ max window size =2
Summary
Mechanisms for reliable data transfer:
| Name | Mechanism |
|---|---|
Checksum |
|
Timer/timeout |
|
Sequential numbering of packets |
|
Acknowledgment |
|
Negative acknowledgment |
|
Window, pipelining |
|