interviewpath
  • 0day streak
  • 10total XP
  • Level 1
0/6

Unit 4 · Networks · Lesson 1 of 10

Layering, addressing, routing and switching

How a packet gets from one host to another: layers and encapsulation, IPv4 and IPv6 addressing with CIDR prefixes, longest-prefix-match forwarding, ARP and Ethernet switching. Questions about latency, cloud VPCs, Kubernetes networking and "what happens when you load a URL" all assume this model.
About 4 hFocus mode

Step 1: Learn the ideas

  • Layering and encapsulation
  • IPv4 addressing, CIDR and subnetting
  • IPv6 addressing and Neighbor Discovery
  • Longest-prefix-match forwarding and default routes
  • Forwarding (data plane) versus routing (control plane)
  • ARP and Ethernet frames
  • Learning switches, VLANs and spanning tree
  • NAT and private address ranges
  • TTL, ICMP, traceroute and MTU
  • DHCP host configuration

Why it matters

A reliable way into networking questions in systems interviews is to ask: which box makes which decision, using which header field, looked up in which table? If you can trace a packet through a laptop, a home router, a cloud VPC and a load balancer while naming the lookup at each hop, you can reason about reachability bugs, MTU problems, NAT surprises and why a subnet ran out of addresses. Cloud networking (VPC subnets, route tables, overlay networks in Kubernetes) is the same model with software doing the forwarding.

Core ideas

Layering and encapsulation. Each layer adds a header that only its peer layer interprets: application data, then a transport segment (ports), then an IP packet (addresses), then a link-layer frame (MAC addresses). The link layer moves frames within one network, IP moves packets between networks, and transport multiplexes between processes on the end hosts. Routers rewrite the link-layer header at every hop but leave the IP addresses alone unless NAT is involved.

Addresses and prefixes. An IPv4 address has 32 bits; a prefix such as 10.20.0.0/16 names every address that shares its first 16 bits. CIDR replaced fixed address classes, so prefixes can have any length and can be aggregated: 10.20.0.0/17 and 10.20.128.0/17 together form one /16. A /24 holds 256 addresses, but the network and broadcast addresses are reserved, and cloud providers reserve a few more per subnet. IPv6 uses 128-bit addresses written in hex with :: compression, normally /64 subnets with stateless autoconfiguration, and replaces ARP with Neighbor Discovery over ICMPv6. Private ranges plus NAT let many hosts share one public address, at the cost of end-to-end addressing: inbound connections need explicit port mappings and the NAT holds per-connection state.

Forwarding versus routing. Forwarding is the per-packet data-plane step: look up the destination and choose the entry with the longest matching prefix. With routes 10.0.0.0/8 via A and 10.1.0.0/16 via B, a packet to 10.1.2.3 goes to B, one to 10.2.0.1 goes to A, and 0.0.0.0/0 (the default route) catches everything else. Routing is the control-plane process (static configuration, OSPF, BGP) that fills the table. Because forwarding only consults the table, a more-specific route installed by any source silently overrides a broader one.

Within one network: ARP and switching. A host sends directly to destinations in its own subnet and to its default gateway otherwise. To build the Ethernet frame it needs the next hop's MAC address, which ARP obtains by broadcasting a request and caching the reply. Switches learn which MAC address sits behind which port from source addresses, forward known destinations to one port and flood unknown ones; spanning tree or a routed fabric prevents loops, and VLANs split one physical switch into separate broadcast domains.

Supporting pieces. TTL (hop limit in IPv6) stops looping packets and makes traceroute possible. ICMP carries errors such as "destination unreachable" and "fragmentation needed"; filtering it can break path-MTU discovery, producing connections that handshake but hang on large transfers. DHCP hands a host its address, prefix length, gateway and DNS servers.

Common misconceptions

  • "Routers keep a table of hosts." They match prefixes, and the most specific matching prefix wins regardless of the order in which routes were added.
  • "The MAC address travels end to end." It is replaced at every IP hop; only the IP header survives across networks, apart from TTL and checksum updates and any NAT rewrites.
  • "A /24 gives 256 usable hosts." Two addresses are reserved by convention and cloud subnets reserve more, which matters when sizing subnets for autoscaling groups or pods.
  • "IPv6 is IPv4 with longer addresses." Autoconfiguration, Neighbor Discovery, no fragmentation by routers and the usual absence of NAT change day-to-day operations.
  • "Switches and routers do the same job." A switch forwards frames by MAC address inside a broadcast domain; a router forwards packets by IP prefix between networks. Many devices do both, with different tables.

How to approach it

Drill the arithmetic until it is automatic: prefix length to block size, whether two addresses share a subnet, how to split a /16 into /20s. Then trace scenarios end to end, such as a laptop fetching a page through a home NAT, or a pod reaching a pod on another node. Graduate-level questions check encapsulation, longest-prefix match and ARP; mid and senior levels add VPC address planning (non-overlapping ranges for peering, room for growth), NAT and MTU failure modes, and how you would debug "cannot reach host X" layer by layer.

Suggested order

  1. 1Read Computer Networks: A Systems Approach Section 1.3 (Architecture) for layering and encapsulation, then Section 3.3 (Internet (IP)) for forwarding, classless addressing, ARP, DHCP and ICMP.
  2. 2Read Section 3.2 (Switched Ethernet) for learning bridges, spanning tree and VLANs, and Section 4.2 (IP Version 6) for IPv6 addressing.
  3. 3Skim RFC 4632 Section 3 (Classless Addressing as a Solution), then work ten subnetting exercises by hand: block sizes, ranges, membership and splitting a /16 into /20s.
  4. 4Write a five-entry forwarding table with overlapping prefixes and a default route, and resolve ten destination addresses with longest-prefix match.
  5. 5On a Linux machine or VM, run ip addr, ip route and ip neigh, then traceroute to a remote host, and explain every line of output.
  6. 6If you are doing the CS144 labs, complete the network-interface (ARP) and IP-router (longest-prefix match) checkpoints.

Step 2: Check off what you can do

Tap each one you can genuinely do or explain. Each earns 10 XP.

Step 3: Go deeper

  • Computer Networks: A Systems ApproachStart here

    Systems Approach (open online edition)

    Section: 3.3 Internet (IP)

    Main reading for IP forwarding, subnetting and classless addressing, ARP, DHCP and ICMP; start with Section 1.3 for layering.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Computer Networks: A Systems Approach

    Systems Approach (open online edition)

    Section: 3.2 Switched Ethernet

    Learning bridges, spanning tree and VLANs.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Computer Networks: A Systems Approach

    Systems Approach (open online edition)

    Section: 4.2 IP Version 6

    IPv6 address format, assignment and routing.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Stanford CS144 Introduction to Computer NetworkingStart here

    Stanford University

    Section: Lab checkpoints: the network interface and the IP router

    Implement ARP-backed next-hop resolution and longest-prefix-match forwarding yourself.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • RFC 4632: Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan

    IETF (RFC Editor)

    Section: Section 3: Classless Addressing as a Solution

    Short authoritative explanation of prefix notation and aggregation.

    Open(opens in a new tab)Link responded, 5 Oct 2026

Step 4: Practice

Work subnetting by hand until it is quick, then check yourself: predict longest-prefix-match results and verify them with ip route get <address> after adding test routes in a VM or network namespace. Run ip neigh before and after pinging a new host on your subnet to watch the neighbor table fill. If you do the CS144 router checkpoints, write tests for overlapping prefixes and the default route before writing the lookup.

Record attempts on each problem’s page (+15 XP, +10 more when solved on your own).

Step 5: Test yourself

Answer each one out loud or on paper before you finish the lesson.

  1. Question 1Do 192.168.10.130/25 and 192.168.10.100/25 belong to the same subnet?
  2. Question 2Which route wins for 10.1.2.3 among 10.0.0.0/8, 10.1.0.0/16 and 0.0.0.0/0, and why?
  3. Question 3Which header fields does a router change when it forwards an IPv4 packet?
  4. Question 4To send a packet to a remote server, whose MAC address does a host look up with ARP?
  5. Question 5What breaks when ICMP "fragmentation needed" messages are filtered?
  6. Question 6Why can two VPCs with overlapping CIDR ranges not simply be peered?
  7. Question 7How does a learning switch handle a frame for a MAC address it has not seen?

You’re done when you can

  • Given an address and prefix length, state the network address, broadcast address and host count in under one minute without a calculator.
  • Resolve destinations against a forwarding table with overlapping prefixes and a default route without errors.
  • Explain in under three minutes every header change on the path from a laptop behind NAT to a web server.
  • Explain the ARP exchange that precedes the first packet to a new next hop and what happens when the entry is missing or stale.

Finish the lesson

How confident do you feel?

Lesson complete!

+50 XP

Reviews will come up on the Practice tab so it sticks.

Unlocks next: TCP and UDP behavior, BGP and routing policy

Your notes and study time

Log study time