ยง48.3โ€“48.4Reliable Communication Layers and Communication Abstractions

Part III OSTEP pp. 609โ€“612 ยท ~8 min read

  • reliable communication layer
  • acknowledgment
  • timeout
  • retry
  • exactly-once semantics
  • sequence counter
  • tcp
  • exponential back-off
  • distributed shared memory

We can send datagrams, but they get lost. Most applications donโ€™t want to worry about that โ€” they want a reliable communication layer that guarantees delivery on top of the unreliable network. Letโ€™s build one.

48.3 Reliable Communication Layers

Start with one question: how does a sender know the receiver got its message? The answer is an acknowledgment (ack) โ€” a short reply confirming receipt. And if no ack comes back? The sender sets a timeout when it sends; if the timer fires with no ack, it assumes loss and does a retry , re-sending a saved copy. The pair is called timeout/retry. But thereโ€™s a subtlety โ€” walk all three cases:

Reliable messaging = acknowledgment + timeout/retry โ€” and a sequence number to kill the duplicate the retry can create. Step through all three cases.
Sender
Network
Receiver
Case 1 โ€” the happy path (message + ack)
Case 2 โ€” the request is dropped โ†’ timeout/retry
Case 3 โ€” the ACK is dropped โ†’ a duplicate!
step 1 / 20 ยท time flows downward

The sender never throws the message away until it is acknowledged.

Case 3 is the trap. A lost ack is indistinguishable from a lost request at the sender, so it retries โ€” and the receiver gets the message twice. For a reliable layer we usually want exactly-once delivery, so the receiver must detect and suppress duplicates.

You could give each message a unique ID and have the receiver remember every ID it has ever seen โ€” but that needs unbounded memory. The cheap fix is a sequence counter : both sides keep a counter, and the value rides along as the message ID.

The sequence counter, step by step. Both sides start at 1. The counter value rides along as the message ID; the receiver only delivers an ID that matches its expected counter.
Sendercounter = 1Receiverexpected = 1msg ID = โ€”agreed start value = 1

1Both counters start at 1

Sender and receiver agree on a start value (1). The sender will stamp each message with its current counter as the ID.

step 1 / 5

One counter per side, and duplicates are caught. The most common reliable layer, TCP/IP , does all this and far more (congestion control, multiple outstanding requests, hundreds of optimizations).

Tip: Be Careful Setting The Timeout

Too short and the sender re-sends needlessly, wasting CPU and network; too long and it waits too long to recover, hurting perceived performance. The ideal is just long enough to detect loss. And with many clients hitting one server, loss often signals overload โ€” so a client should use exponential back-off (e.g. double the timeout after each miss, as pioneered in Aloha/Ethernet) rather than hammering an already-struggling server.

48.4 Communication Abstractions

Given a messaging layer, what should we actually program against? One early idea took OS abstractions across the network: distributed shared memory (DSM) let processes on different machines share one big virtual address space. It works through the VM system: touch a page held on another machine and a page fault fires, whose handler fetches the page over the network and installs it locally โ€” so a distributed computation looks just like a multi-threaded program.

It didnโ€™t last, for two reasons โ€” and the first is fatal:

Machine AMachine B โœ— CRASHEDone shared virtual address space, spread across machinespage 1list nodepage 2gone"next" โ†’ dangles into vanished memorya remote page fault normally fetches page 2 from B โ€” but if B dies, part of the address space is simply gone
DSMโ€™s downfall: when a machine holding part of the shared address space dies, that memory simply vanishes โ€” a linked-list โ€œnextโ€ pointer can now dangle into nothing. Dealing with failure when your address space develops holes is brutally hard.

The second reason is performance: code assumes memory access is cheap, but in DSM some accesses silently become expensive remote page faults. Programmers had to organize computations to avoid communication almost entirely โ€” defeating the point. Much was researched; little stuck. Nobody builds reliable distributed systems on DSM today. The abstraction that did win is a programming-language idea โ€” remote procedure call โ€” up next.

Check yourself: reliable messaging and abstractions

1.How do acknowledgments, timeouts, and retries combine to recover from a lost request?

2.When the ACK is lost (not the request), why does plain timeout/retry cause a problem?

3.How does a sequence counter detect duplicates cheaply, preserving exactly-once?

4.Under heavy load, why might a client use exponential back-off rather than retrying at a fixed interval?

5.Distributed shared memory (DSM) let machines share one virtual address space. Why isn't it used to build reliable distributed systems today?

6.What is TCP/IP in this picture?

6 questions