7 routes42 sections324 units

Section 3 of 7 · Systems Foundations

Networks, Sockets & RPC Contracts

A network turns local calls into partial and ambiguous outcomes. This section builds byte-stream discipline, bounded retry behavior and an observable request contract before adding replicated state.

8 units 21 topics 0/8

Units

8 in this section

  1. 3.1 Network layers, addressing, routing and DNS
    explain
    3 h
  2. 3.2 TCP and UDP transport behavior
    explain · measure
    4 h
  3. 3.3 TLS and HTTP versions
    explain
    3 h
  4. 3.4 Sockets, partial reads and writes, and message framing
    implement
    5 h
  5. 3.5 RPC schemas, versions, errors and trace context
    explain · implement
    3 h
  6. 3.6 Deadlines, retries and idempotency across RPC
    derive · implement
    4 h
  7. 3.7 Connection shutdown, pools and latency decomposition
    explain · measure
    4 h
  8. 3.8 Deterministic network fault injection
    implement · measure
    3 h

Before moving on

Checkpoint

Pass partial, coalesced, oversized, malformed, timeout, duplicate, disconnect and restart cases against a versioned framed service. State exactly when a side effect is known, unknown, prevented or safely repeated.

Deliberately out of scope

Leave for later

  • Raft and replicated protocol implementation
  • Service meshes, QUIC internals and fleet routing
  • Kernel-bypass or RDMA networking

Resources for this section

Shared by every unit above

  • Beej's Guide to Network Programming - sockets to multiplexing
    Brian Hallcourse
    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 path
    Brian Halltheory
    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.
  • AlgoMaster Networks - pcap and concurrent server labs
    AlgoMasterpractice
    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.
  • MIT 6.5840 - RPC, threads and fault vocabulary
    MIT PDOStheory
    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.
  • Replicated Log and Stream Processor - protocol slice
    Roadmap-Finalproject
    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.
  • Designing Data-Intensive Applications, 2nd edition - Chapter 5
    O'Reillytheory
    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 guide
    gRPC Authorsreference
    reference
    Read Overview, Deadlines on the Client and Deadline Propagation for absolute deadlines, remaining-time forwarding and clock-skew shielding.
  • gRPC Status Codes
    gRPC Authorsreference
    reference
    Read the full status list, including DEADLINE_EXCEEDED, UNAVAILABLE and the codes never generated by the library, for the error taxonomy.
  • W3C Trace Context
    W3Creference
    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.

Apply the section

Mini-project · Versioned framed key-value service with deadlines and fault matrix (12 to 16 h)

Put the service slice on the network with a versioned framed protocol, request identity, deadlines and idempotent writes served through the bounded pool. Then prove the contract with a deterministic fault proxy and a full verdict matrix.

Steps

  1. Define the length-prefixed versioned frame in kv/protocol.py as a pure function over a byte buffer, and test splits at every offset, small reads, oversized and truncated inputs and newer-client compatibility.
  2. Serve decoded requests through the WorkerPool with immediate overload answers when full, echo id and continue the trace with a new parent, and reject unknown versions while ignoring unknown fields.
  3. Propagate caller budgets as arrival-based deadlines on the monotonic clock, make writes idempotent by key with replay and rejection rules, and retry only retryable errors with jittered backoff inside the deadline.
  4. Write kv/client.py with client-generated request identity, a pool sized from target rate and hold time, per-request deadlines, and a test where a caller waiting for a connection gives up at its deadline.
  5. Write a schedule-driven fault proxy that logs every action and replays byte-identical logs, then pass the full fault matrix with a verdict row per case and exactly-once effects under duplication and retry, leaving the restart row for the durability section.
  6. Capture one put with tcpdump or a container-attached capture, label the handshake, length prefix, payload bytes and close, and keep the capture with the write-up.

Deliverables

  • kv/protocol.py, kv/server.py and kv/client.py with framing, identity, deadline, idempotency, retry and pool tests.
  • The schedule-driven fault proxy with replayable logs and the full verdict matrix, with restart marked for durability.
  • One labeled packet capture of a put with the handshake, frame and close identified.

Checks

  • rubric · Self-grade with the rubric below

Rubric

CriterionPassStrong
Framing and identitySplit, oversized and truncated frame tests pass, responses echo identity, and unknown versions and fields behave.A randomized split and payload property test backs the offset cases.
Deadlines and idempotencyBudgets shrink hop by hop on own clocks, expired work never starts, duplicates replay or wait, and mismatched bodies reject.A forced queue-expiry test shows the client sees a deadline error rather than a late success.
Fault evidenceEvery matrix case has a verdict row, replays give identical logs, and duplicated work applies once.Each unknown outcome names the probe that would resolve it.

Feeds into: Capstone service slice: framed RPC, identity, deadlines, retries and deterministic network faults. The matrix joins the dossier and restart passes once durable.

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