Reliable data transfer

A reliable data transfer protocol ensures that data:

Key parts of a reliable protocol:

  1. acknowledgments (positive and negative)
  2. checksums to detect errors
  3. sequence numbers to track order
  4. 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 packet loss or corruption
  • no need to provide any feedback to the sender
  • packets arrive in order
  • data is received as fast as the sender happens to send data, no need to ask him to slow down

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:

  • ACK = packet received correctly
  • NAK = packet corrupted, resend

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:

  1. error detection: allow the receiver to detect corrupted packets (e.g. checksum)
  2. receiver feedback: receiver tells sender if packet was OK (ACK) or bad (NAK)
  3. retransmission: sender resends packets that were received in error

This is a stop-and-wait protocol: the sender must wait for ACK/NAK before sending the next packet.

rdt2.1 - Retransmission and sequence number

ACK/NAK messages can also be corrupted.

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: 0 or 1) in the packet.

This allows the receiver to distinguish:

  • new packet → has the next sequence number
  • duplicate packet → has the same sequence number as the last correctly received one

rdt2.2 - No NAKs (ACK-only system)

Simplify control messages.

Instead of using both ACK and NAK, use a NAK-free system:

  • the receiver only sends ACK for the last correctly received packet
  • duplicate ACKs signal an error

If the sender receives repeated ACKs for the same packet:

  • it infers the next packet was lost or corrupted
  • and retransmits it

rdt3.0 - Packet loss (timers)

Packets/ACKs can be lost entirely and the sender may never hear back from the receiver.

How to detect packet loss?

The sender can wait long enough so that it is certain that a packet has been lost:

  • the worst-case maximum delay is difficult to estimate
    • at least as long as a round-trip delay (including buffering at intermediate routers)
    • plus whatever amount of time is needed to process a packet at the receiver
  • thus the approach adopted in practice is to use a countdown timer that makes it likely that the packet is lost, although not guaranteed

What to do when packet loss occurs?

  • if a packet is not received within this time, it is retransmitted
  • if a packet experiences a particularly large delay, the sender may retransmit it, though it hasn't been lost, introducing the possibility of duplicate data packets

Sender actions:

  1. start the timer when sending a packet
  2. retransmit on timeout
  3. stop timer when ACK arrives

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.

Stop-and-wait protocol and pipelined protocol

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)

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:

Example:

Go-Back-N

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:

Selective repeat (SR)

In a SR protocol:

Selective repeat

Event Sender Receiver

Packet received

  • if the packet is within the sender window:
    • send it
  • otherwise, buffer it
  • if the packet is within the receiver window:
    • send ACK
    • buffer it
    • if the sequence number = rcv_base, deliver it and any consecutive buffered packets to the upper layer
    • slide the receiver window forward by the number of packets sent to the upper layer
  • if the packet was already received:
    • re-send ACK (reacknowledge instead of ignoring the packet)
    • this prevents the sender window from getting stuck if a previous ACK was lost
  • if the packet is outside both ranges:
    • ignore it

Timeout

  • each packet has its own timer to detect lost ones
  • if a timer expires, only that packet is retransmitted
—

ACK received

  • mark the packet as received (if it's in the window)
  • if the sequence number = send_base, slide the window forward
  • if new space opens, send any buffered packets
—

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:

To avoid this ambiguity:

Selective repeat receiver dilemma

Summary

Mechanisms for reliable data transfer:

Name Mechanism

Checksum

  • detects bit errors in a packet

Timer/timeout

  • triggers retransmission of lost packets or missing ACKs
  • can cause duplicates due to:
    • premature timeout (packet delayed but not lost)
    • lost ACKs

Sequential numbering of packets

  • gaps allow the receiver to detect missing packets
  • duplicate sequence numbers allow the receiver to detect duplicates

Acknowledgment

  • confirms correct receipt of a packet
  • carries sequence number
  • can be individual or cumulative

Negative acknowledgment

  • indicates a packet was not received correctly
  • carries sequence number

Window, pipelining

  • limits number of unacknowledged packets in transit
  • window size may be set on:
    • receiver buffer capacity
    • level of congestion in the network
    • or both

Previous UDP All ⏎ Next TCP

A Kemar Joint