Unit 8 of 8 · about 3 hours · implement, measure

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.

You'll be able to

  • 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
1

Read

In this order, only the parts listed

0 of 3 done

  1. Replicated Log and Stream Processor: protocol sliceReplicated 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

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

  2. Failure modes and unknown outcomesAlgoMaster 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 behaviorAlgoMaster Networks - pcap and concurrent server labs

    Overload Behavior Is Observable; Failure Behavior; Common Failure Patterns

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

2

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.
Common mistakes · 3
  • 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.
3

Try it yourself

Closed-book, before checking anything

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.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

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

    Either the deadline exceeds the injected delay or the client has no deadline. A fault test must assert the client observation, not just run the injector.

  2. 2.Why must the duplicate test read twice?Answer

    The first read succeeds in both correct and buggy servers. Only the second read shows whether a duplicate arrived, and the effect log shows whether it executed twice.

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

    Only that the outcome is unknown. The effect may or may not have committed; resolution needs a keyed status query after reconnect.

You're done 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.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 7 more in the section
  • AlgoMaster Networks - pcap and concurrent server labsAlgoMaster · required

    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 sliceRoadmap-Final · support

    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 multiplexingBrian Hall · primary

    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 pathBrian Hall · required

    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 vocabularyMIT PDOS · support

    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 5O'Reilly · required

    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 guidegRPC Authors · reference

    Read Overview, Deadlines on the Client and Deadline Propagation for absolute deadlines, remaining-time forwarding and clock-skew shielding.

  • gRPC Status CodesgRPC Authors · reference

    Read the full status list, including DEADLINE_EXCEEDED, UNAVAILABLE and the codes never generated by the library, for the error taxonomy.

  • W3C Trace ContextW3C · reference

    Read Section 3.2 for the traceparent format and Sections 3.4 to 3.5 for the legal traceparent and tracestate mutations when forwarding.