Layer 3 — Network
Host-to-host across hops: IP, routing, ICMP. Packets and logical addresses.
Level: beginner
What is it?
Layer 3 moves packets from a source IP to a destination IP across many L2 hops. Routers look at the destination, match the longest prefix, decrement TTL, and wrap a new L2 frame for the next hop. ICMP is the error and diagnostic plane.
Why does it matter?
This is why the internet scales: hierarchical addresses and hop-by-hop forwarding. Subnetting, NAT, and traceroute all live here.
Mental model
The city name on the envelope. Each post office (router) only needs to know the next city, not the whole path.
How it works
- Purpose: logical addressing and routing across networks.
- PDU: packet. Addressing: IPv4 (32-bit) / IPv6 (128-bit).
- Protocols: IPv4, IPv6, ICMP, OSPF, BGP (routing protocols are L3 control).
- Devices: routers. Hosts have L3 too (their own stack).
- TTL/hop limit stops loops. Fragmentation is IPv4’s historical mess; IPv6 avoids it in the path.
Real-world usage
- Every internet hop
- VPCs and subnets
- Traceroute
Common mistakes
- Confusing IP with MAC
- Saying a router 'strips TCP' — it usually only rewrites L2 and looks at L3
Interview questions
What does a router change on a packet?
L2 encapsulation (new MACs), TTL, sometimes checksum. Source/dest IP usually stay (unless NAT).
Longest prefix match?
Among routes that cover the dest, pick the most specific (longest mask). Default is /0.