7 routes42 sections324 units

Unit 3.8 · about 3 h

256 / 324

Deterministic network fault injection

Robustness claims are predictions until a fault schedule runs. This unit builds the harness the milestone's fault-tested service slice depends on, with the deterministic schedules of systems/concurrency-bounded-work/schedule-testing-contention.

  • implement
  • measure

You can now

  • Implement a deterministic proxy that injects delay, duplicate, drop and restart faults on a framed protocol.
  • Measure timeout, duplicate and disconnect behavior and state the resulting delivery guarantee precisely.
  • Write the fault matrix the section mini-project will execute.

Covers

  • Deterministic delay, disconnect, duplicate and restart injection

Study, in this order

3 steps

  1. Replicated Log and Stream Processor: protocol slice
    Replicated Log and Stream Processor - protocol slice

    The deterministic network fault list (delay, duplicate, disconnect, restart and companions); the protocol requirements for the single-node framed service; the delivery-contract questions

    Depth · Use only the fault list and the single-node protocol slice. Replication and consensus stay in the later project.

  2. Failure modes and unknown outcomes
    AlgoMaster Networks - pcap and concurrent server labs

    A Network Call Has Several Failure Points; Timeouts Turn Unbounded Waiting into a Decision; Known Failure, Known Success, and Unknown Outcome

  3. Observable overload and failure behavior
    AlgoMaster Networks - pcap and concurrent server labs

    Overload Behavior Is Observable; Failure Behavior; Common Failure Patterns

    Depth · Read for the failure-injection checklist; you already implemented the server contract in the sockets unit.

Focus on

  • Deterministic means seeded and scripted: same fault schedule, same interleaving, same verdict. Random chaos finds bugs; only replayable schedules prove fixes.
  • Inject above TCP when testing the protocol (duplicate frames, truncated writes, slow reads) and at the connection level when testing the path (delay, drop, restart).
  • Each fault has an expected client observation: delay past deadline gives timeout with unknown outcome; duplicate gives one effect under keys; drop gives disconnect with unknown outcome.
  • Restart is two faults at once: in-flight requests resolve as unknown, and post-restart state must reconcile pre-restart keys by policy.

Reproduce closed-book

Run the three-case proxy matrix on loopback (CPython 3.14.4): 200 ms injected delay with a 100 ms client deadline records timeout; duplicate delivery leaves a second frame waiting on the connection; response drop records disconnect. Extend the script with a restart case and record all four rows with the fault parameters beside each verdict. Reference run on Linux x86-64 kernel 7.0.0-38-generic, i9-12900K confirmed the first three rows.

Traps

  • Counting a passed clean-path test as fault coverage. Timeouts, duplicates and restarts exercise different code than the happy path.
  • Driving fault timing from wall-clock sleeps with tight deadlines. Slow machines flake; script explicit fault steps with generous margins.
  • Logging faults only at the injector. Verdicts need client observation, server state and the schedule in one record, or failures cannot be replayed.

Practice

The section mini-project covers this: the full fault matrix (partial, coalesced, oversized, malformed, timeout, duplicate, disconnect, restart) against the versioned framed service, with replayable schedules and verdict records.

Self-test

  1. The delay fault fires but the client still reports success. Is the test wrong?

  2. Why must the duplicate test read twice?

  3. The server restarts between request receipt and response. What may the client conclude?

Completion criterion

Stop when

Your proxy replays a scripted fault schedule, every row records fault parameters with client observation and server state, and you can state the exact delivery guarantee in one sentence.

Mark passed, then open 4.1 Only mark this when you can do it without notes.

Leads to

Comes after

Resources for this unit

  • AlgoMaster Networks - pcap and concurrent server labs
    AlgoMasterrequiredpractice
    Use Reading a Packet Capture: A Real Bug and Building a Concurrent TCP Echo Server after the Beej implementation. Reproduce one packet-level observation and one admission, deadline or shutdown behavior in your independently written service.
  • Replicated Log and Stream Processor - protocol slice
    Roadmap-Finalsupportproject
    Use only the protocol requirements, deterministic network fault matrix and delivery-contract questions. Build the single-node framed service now; keep replication and consensus for the later project.

Also in this section

  • Beej's Guide to Network Programming - sockets to multiplexing
    Brian Hallprimarycourse
    Read What is a socket?, IP addresses and data structures, Client-server background, System calls or bust, Client-server examples, Slightly advanced techniques and sendall. Build the simple TCP pair first, then replace delimiter assumptions with a bounded length-prefixed protocol.
  • Beej's Guide to Network Concepts - TCP and UDP path
    Brian Hallrequiredtheory
    Read the OS and sockets, protocol layering, IP, UDP and TCP chapters alongside packet captures from your own client and server. Use it to explain transport behavior rather than memorize layer names.
  • MIT 6.5840 - RPC, threads and fault vocabulary
    MIT PDOSsupporttheory
    Read the introductory RPC and threads material plus the lab guidance. Use it to enumerate timeout ambiguity and duplicate effects. Stop before Raft and the full lab sequence.
  • Designing Data-Intensive Applications, 2nd edition - Chapter 5
    O'Reillyrequiredtheory
    Read Formats for Encoding Data (printed pp. 163 to 177) for schema merits and compatibility, and Dataflow Through Services: REST and RPC (printed pp. 180 to 186) for service dataflow, version coexistence and the idempotence pointer.
  • gRPC Deadlines guide
    gRPC Authorsreferencereference
    Read Overview, Deadlines on the Client and Deadline Propagation for absolute deadlines, remaining-time forwarding and clock-skew shielding.
  • gRPC Status Codes
    gRPC Authorsreferencereference
    Read the full status list, including DEADLINE_EXCEEDED, UNAVAILABLE and the codes never generated by the library, for the error taxonomy.
  • W3C Trace Context
    W3Creferencereference
    Read Section 3.2 for the traceparent format and Sections 3.4 to 3.5 for the legal traceparent and tracestate mutations when forwarding.

Quick find

Search Michi

Type to search every route, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels