7 routes42 sections324 units

Unit 3.1 · about 3 h

249 / 324

Network layers, addressing, routing and DNS

Every later diagnosis in this section starts by asking which layer broke. Layers do not exist on the wire; they are a debugging vocabulary, and DNS plus routing are the two lookups every connection performs first.

  • explain

You can now

  • Use the OSI 7-layer and TCP/IP 4-layer models to place a failure at the right layer, and state where each model misleads.
  • Trace a DNS lookup from stub resolver through root, TLD and authoritative server, and apply the TTL expiry rule.
  • Read a host routing-table entry and predict the next hop with longest-prefix match.

Covers

  • Network layers as an explanatory model
  • IP addresses, ports, routing and DNS lookup

Study, in this order

4 steps

  1. The OSI 7-layer model
    AlgoMaster Networks - pcap and concurrent server labs

    The Seven Layers at a Glance; Encapsulation Across the Stack; Using OSI to Diagnose a Failure; Where the Model Has Limits

  2. The TCP/IP 4-layer model
    AlgoMaster Networks - pcap and concurrent server labs

    The Four Layers; Mapping TCP/IP to OSI; A Complete Request in TCP/IP Terms; Boundaries in Modern Protocols

  3. Layering, IP and routing in Beej's Network Concepts
    Beej's Guide to Network Concepts - TCP and UDP path

    Chapter 4, The Layered Network Model (Sections 4.3 and 4.4); Chapter 18, IP Routing (Sections 18.2 to 18.5)

  4. DNS hierarchy and debugging
    AlgoMaster Networks - pcap and concurrent server labs

    Domains and Zones Are Different; Following the Chain of Authority; Practical Implications for Engineers; then Debugging DNS with dig and nslookup: The Basic dig Command, Walk the Delegation with +trace, Diagnose Cache and TTL Behavior

    Depth · Use https://algomaster.io/learn/computer-networks/debugging-dns for the dig sections; skip DNSSEC detail.

Focus on

  • OSI layers are an explanatory model. The wire carries frames, packets and segments; nothing is tagged with a layer number.
  • DNS resolution is a chain of referrals with per-record TTLs. A cached answer is valid while now is earlier than stored time plus TTL; reading it does not refresh it.
  • Routing is longest-prefix match on the destination, per packet, per hop. The default route is only the shortest prefix that matches.
  • Sending adds transport, internet and link headers around application data in that order; receiving strips them in reverse.

Reproduce closed-book

Run dig +short example.com twice and compare the answer sets. Then closed-book, write the cold-lookup chain (stub to recursive to root to TLD to authoritative) and evaluate the TTL rule on store(api.example, 192.0.2.10, TTL 10, t=100): resolve at \(t=109\) hits, at \(t=110\) misses.

Traps

  • Treating OSI as seven things a packet passes through in code. Implementations merge and skip layers; TLS, for example, sits between transport use and the application.
  • Reading a DNS TTL as a freshness guarantee. It bounds staleness; an authoritative change still waits out the TTL at every cache.
  • Inferring network meaning from dotted quads or old class letters. Only the prefix length defines the network part.

Practice

AlgoMaster: Implement a DNS TTL Cache

store and resolve with TTL expiry (\(\text{now} < t + d\)), case-insensitive names, cached NXDOMAIN

Do not refresh expiry on resolve; the 109-hit 110-miss boundary in Reproduce is the first case to pass.

Self-test

  1. A record stored at \(t=100\) with TTL 10 is resolved at \(t=110\). Hit or miss, and why?

  2. Entries cover 10.0.0.0/8 and 10.1.2.0/24. Which carries a packet for 10.1.2.9?

  3. Why can two applications on one host share one IP address without conflict?

  4. A capture shows HTTP inside TLS inside TCP inside IPv4 inside Ethernet. Which layering claim does this support?

Completion criterion

Stop when

You place a refused connection, an NXDOMAIN and a wrong route at the right layer on the first guess, and your TTL cache passes the 109-hit 110-miss boundary.

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

Leads to

Resources for this unit

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

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