Chapter 4

Routing

How a packet finds its way across tens of thousands of independent networks — one longest-prefix-match lookup and one next hop at a time.

6 topics

Routing is the question of which way a packet goes when the destination is not on the local wire. Every device that speaks IP keeps a routing table, consults it once per packet, and forwards toward a single next hop — never the whole path. The forwarding rule is the same everywhere, from a laptop to a core internet router: among all routes that match the destination, the most specific one wins. Master longest-prefix match and the default route, and the behavior of an entire network stops being mysterious.

This chapter climbs from the table on one host up to the protocols that fill millions of tables in concert. It starts with how a single lookup works, then how a host hands off to its default gateway, then how routes get there — typed in by hand or learned by a protocol. From there it covers OSPF, the link-state protocol that runs inside an organization, and BGP, the path-vector protocol that stitches the internet's ~78,000 autonomous systems together. It closes with anycast, where one address lives in dozens of datacenters and routing itself does the load balancing.

One packet's routing decision, repeated at every hop
lookup
dst IP
longest-prefix
match
pick
next hop
forward
one hop

Topics in This Chapter