← Low-latency networking

Ch 1–2: Fundamentals and design principles

Source: Sterbenz & Touch 2001, Ch 1 (pp. 1–12) and Ch 2 (pp. 13–77), read in full. Page numbers are the book’s printed pages. The principles are listed one per line in 01-principles-map.md; this file covers the reasoning and the examples behind them.

Ch 1 in brief

The delay model (pp. 21–25)

The book’s central formula, for a chunk of b bits on a path of bandwidth r:

D = (1 + h + c) · b/r + t_p

Term Meaning
1 · b/r Sending the chunk once, at the source
h · b/r Sending it again at each of h store-and-forward hops
c · b/r Each of c per-byte operations (copies between buffers, passes over the data)
t_p Path latency: propagation at the speed of light plus delay inside the end systems and nodes

Bandwidth shrinks the b/r terms. Nothing shrinks the propagation part of t_p except a shorter path (III.1). The multiplier (1 + h + c) is why the book insists on Store-and-Forward Avoidance (II.3): “the best we can possibly do is the single transmission delay at the sending system, resulting in a zero-copy system” (p. 25).

Note: charging each copy a full b/r is the book’s simplification. A memory copy runs at memory speed, not link speed; the point is that every extra pass over the data adds a term that grows with b.

On lossy links, the book says to treat retransmissions as a loss of effective bandwidth rather than added latency, because bandwidth measures (forward error correction) fix it better than a shorter path would (p. 22).

The ideal network and the axioms (pp. 23–31)

Design principles: the reasoning that matters

Time scales (p. 32). What you optimize spans at least 18 orders of magnitude: years to deploy a protocol, days to reconfigure a network, then session, connection, packet, cell, byte and bit times.

Selective optimization (1, 1A). A path with segment latencies 50 + 2 + 25 + 10 = 87: the second segment is 0.02 of the total, so removing it entirely changes nothing (p. 35). For a 100 ms interactive budget, WAN latency matters far more than LAN latency, but LAN latency still matters for distributed processing and feedback control with tight bounds (p. 35).

Critical path (1B), three observations (pp. 35–36):

  1. Transfer control such as flow control and framing is on the critical path, even if it runs per frame rather than per byte.
  2. The critical path can split into parallel branches that rejoin.
  3. Dependencies count. If only 1% of packets need a slow transformation but packet order must be kept, every later packet waits behind it. That rare operation is on the critical path; speed it up or redesign so it is not.

Functional partitioning (1C): decide what goes into scarce, fast technology (hardware vs software, cache vs memory, custom vs semicustom chips) only after 1A and 1B tell you what needs speed (p. 36).

Resource trade-offs (2). Resources are bandwidth, processing and memory (B, P, M); latency is the constraint. The trade-offs move over time: bandwidth was expensive in early networks, became cheap with fiber, and then processing and memory became cheaper still (2A, p. 38). Parts that are hard to upgrade, such as transoceanic cables and last-mile wiring, should be heavily overprovisioned from the start (2B, p. 38). Multicast saves link bandwidth and sender work (2C, p. 39).

End-to-end argument (3). An end-to-end function is not the composition of per-hop functions, because you cannot control what happens between the hops (f ≠ f1∘f2∘f3). Encryption is the simple case: if data is in the clear anywhere along the way, there is no confidentiality (pp. 39–40). Per-hop duplicates are still worth it when they improve end-to-end performance, e.g. link-level error control on lossy wireless links (3A, p. 40).

Layering (4). Layering is a good way to think, and a bad way to implement: OSI-era stacks with one process per layer copying PDUs over IPC were “extraordinarily inefficient” (pp. 44–45). Layers can also fight each other: TCP slow start over an ATM connection with a guaranteed rate wastes the reservation by starting slow (4C, p. 46). Example 2.1 shows TCP/IP over ATM ending up with five layers handling transport, network and link functions (p. 49). Interrupts handle asynchronous events but are expensive; polling avoids that cost when you know when data will be there (4H, p. 48).

State (5) (pp. 50–54):

Control latency (6) (pp. 54–60):

Data and PDUs (7, 8). Structure data so something useful can be processed early (p. 61). Small PDUs multiplex well but leave little time per packet; large ones are efficient but delay other flows; fixed sizes simplify switches but force segmentation and reassembly (8A, p. 62). Fields should be byte aligned and fixed length (8B). Timers and sequence numbers must have enough bits for future RTTs and bandwidth–delay products (8C, p. 63).

Design techniques (pp. 63–72)

Trading-network lens (my mapping)

All of this section is my own application of the book; arithmetic and physics are No single source.

The delay model with today’s numbers. Serialization b/r for one frame (frame bytes only; preamble and inter-frame gap add 20 bytes on the wire):

Frame 10 Gb/s 25 Gb/s
64 B 51 ns 20 ns
100 B 80 ns 32 ns
1500 B 1.2 µs 480 ns

Propagation: light in fiber covers about 1 km in 4.9–5 µs (refractive index ≈ 1.47), in air about 1 km in 3.3 µs. So a 100 m cross-connect costs about 0.5 µs one way, and over 1000 km a straight-line radio path beats fiber by more than 1.5 ms one way, before counting that fiber routes are longer than the straight line.

What this means:

Critical path dependency (1B, third observation). A feed handler must process messages in sequence order. A rare message type handled on a slow path, or a gap waiting for recovery, delays every message behind it. That rare path is on the critical path.

Measure before optimizing (1A). Break tick-to-trade into wire → NIC → host stack → application → host stack → NIC → wire and time each part with hardware timestamps. Optimize the largest term first.

Header first, checksum last (2.4.5.1). Ethernet already follows this ordering: destination address first, FCS at the end. That is what lets a cut-through switch forward after reading the header, and it is also why a cut-through switch cannot drop a corrupt frame: the FCS arrives after forwarding has started, so the error only shows up downstream. No single source.

Interrupts vs polling (4H) and resource trade-offs (2A). Trading hosts dedicate CPU cores to busy-polling the NIC: cores became cheap enough that burning one to save the interrupt and wake-up latency is a good trade. The book’s principle, with today’s prices.

Separate control mechanisms (6E) and loss characterization (L-4F). UDP market data has no congestion control, so loss comes from buffer overflow (microbursts) or line errors. Check which: output discards on the switch point to bursts, CRC errors point to a bad link. See ../multicast/02-microburst-buffer.md.

Hard state amortized (5A) and minimize round trips (6A). Order-entry sessions are opened and logged in before the market opens, and feed handlers join their multicast groups at startup, so setup round trips stay off the critical path during trading.

Self-check

  1. Write the delay equation. Which term does cut-through switching attack, and which one does a zero-copy host stack attack?
  2. Path segments of 50, 2, 25 and 10 µs: which one should you leave alone, and which principle says so?
  3. Why can an operation that hits only 1% of packets still be on the critical path?
  4. Why should a checksum live in the trailer rather than the header?
  5. When is polling better than interrupts, according to the book? Why do trading hosts take it further?
  6. Give one open-loop and one closed-loop way to recover lost market data.
  7. A path has a one-way delay of 1 ms at 10 Gb/s. How much data is in flight, and why does that hurt feedback control?
Answers
  1. D = (1 + h + c)·b/r + t_p. Cut-through removes most of the h·b/r term (each hop waits for the header, not the whole frame). Zero copy removes the c·b/r term.
  2. The 2 µs segment: 2/87 ≈ 2% of the total. Second-Order Effect Corollary (1A).
  3. If order must be kept, every later packet waits behind the slow one (Critical Path Corollary, 1B, third observation).
  4. Fields that steer processing must be decoded first; a checksum computed over the data is only ready at the end. With the checksum in the trailer, a pipeline shorter than the packet can compute or check it as the bytes stream through (2.4.5.1).
  5. When the protocol knows when data will arrive, because interrupts are expensive (4H). Trading hosts dedicate whole cores to spinning on the NIC because a core is cheap compared with the microseconds saved (2A).
  6. Open loop: A/B feeds (every packet sent twice on separate paths) or FEC. Closed loop: a retransmission request or snapshot recovery after detecting a sequence gap.
  7. rd = 10¹⁰ b/s × 10⁻³ s = 10⁷ bits ≈ 1.25 MB in flight one way; a feedback loop sees about 2rd ≈ 2.5 MB go by before its action takes effect, so it reacts to stale conditions (p. 5, 5D).

Source: knowledge base note low-latency/02-ch01-02-fundamentals.md — own-words notes with sources, projected at build time.