How the Internet works

Routing, chapter 19 of 36

Anycast and CDNs

Two laptops on two continents send a SYN to 192.0.2.80, and different machines answer from that same address.

The SYN leaves the peering LAN with a TTL of 60 and enters AS64505 at 203.0.113.20. At the same moment a laptop on another continent sends a SYN to 192.0.2.80, enters AS64505 at a different router in a different building, and gets a SYN-ACK from a different machine with the same source address. Neither laptop can tell. The address that our browser took from the DNS names a service, and the routing system chose the building long before the SYN was sent.

2046
operational root server instances by the count of root-servers.org, run by 12 operators, on 13 November 2026
0.15 %
about that share of vantage point and service combinations showed regular TCP flipping toward the root letters
/24
the covering IPv4 prefix an anycast service often needs to survive import filters

Catchments of 192.0.2.0/24

A model: three sites of AS64505 announce one prefix. Withdraw a site or lengthen its AS path, and watch the catchments move and what happens to our open TCP connection.

What does it mean for one address to be in many places?

RFC 4786 (December 2006, BCP 126) by Joe Abley and Kurt Erik Lindqvist supplies the vocabulary. Anycast makes a Service Address available at two or more Anycast Nodes, and the routing system delivers each datagram to one of them (RFC 4786, Section 2). The region whose packets reach one node is its catchment, a term from physical geography for the area that one river drains.

Nothing in the packet marks the difference (RFC 7094, Section 1). The route for 192.0.2.80 is a /24 and not a host route, because a host route cannot be propagated "with confidence" in BGP, as a matter of operational policy (RFC 4786, Section 4.4.2).

Who thought of this first?

Craig Partridge, Trevor Mendez, and Walter Milliken of BBN did, in RFC 1546 (November 1993), an IRTF memo that proposes no protocol. Their example was archie: a user would type telnet archie.net and reach the nearest server. They wanted a separate class of addresses, perhaps as few as 2^16, so that a host could tell when it talked to an anycast address. That class was never assigned.

In April 2002 Ted Hardie of Nominum described the practice for authoritative name servers in RFC 3258. It needed no dedicated address space and no routing changes (RFC 3258, Section 1).

How did the root servers become the proving ground?

The root zone has 13 server names, and anycast lets each name grow. By late 2007 at least 10 of the 13 used it (RFC 7094, Section 1). In January 2014 RFC 7108 documented L-Root as 273 nodes in 143 locations.

More instances do not automatically mean lower latency. In a 2017 study with more than 7,900 RIPE Atlas probes, C with 8 instances had about the same median round-trip time as K with 33 and L with 144, all between 30 and 32 ms (RFC 9199, Section 3.2.1).

Can a TCP connection survive on an anycast address?

Usually, as long as the routing system's choice of node stays stable for much longer than one transaction (RFC 4786, Section 4.1). If border1's port on the exchange fails during the page load, AS64500 falls back to the transit route, and AS64510 may deliver the next segment to another site. That site's listener answers a segment with the ACK bit set with a reset (RFC 9293, Section 3.10.7.2). The browser opens a new connection, which lands at the new site and works.

QUIC's preferred_address offers what RFC 1546 asked of TCP (RFC 9000, Section 9.6).

Why anycast a whole web service when the BCP says it does not scale?

The scaling problem of RFC 4786, Section 4.4.8 is one covering route per service. The same document gives the way out: many service addresses under one covering prefix (RFC 4786, Section 4.8). In 2020 Cloudflare described data centers in more than 200 cities that all serve the same addresses [Wragg2020].

In 2021 only 35 percent of users of Microsoft's anycast CDN saw any latency inflation, against more than 95 percent for root DNS. In the authors' explanation, Microsoft places an anycast site at every location where it peers, and the direct peering route usually wins [Koch2021]. AS64505's site at the exchange is that arrangement in miniature.

What happens inside the site?

Three routers of AS64505 bring the SYN's TTL to 57. The top-of-rack router holds several equal-cost /32 routes for 192.0.2.80, one from each machine that announces the address while its service is healthy. Its ECMP hash picks the machine with MAC address 00:00:5e:00:53:80.

Plain ECMP moves a quarter to a half of all flows when a machine joins or leaves, nearly all with modulo-N hashing (RFC 2991, Section 4). A moved TCP flow is reset. Maglev hashing [Eisenbud2016] accepts a few extra moves for an even table. In a constructed table with 8 backends and 65537 slots, removing one changes 12.68 percent of slots, against 87.49 percent for modulo-N.

clientsite routerL4 balancerserver SYN to the service addressECMP to one balancerSYN inside GRE or IPIPSYN-ACK from the service address
From the book: A layer 4 balancer with direct server return; our site skips the middle step

The book keeps asking

This chapter has 5,520 words and 12 questions. These 6 are answered only in the book and the audiobook.

  • What does anycast do under attack?
  • How does DNS choose a server instead?
  • What does EDNS Client Subnet reveal?
  • What does the edge do with the request?
  • Why put the cache inside the ISP?
  • Can one CDN hand a request to another?

Open the sources

  • RFC 1546 Host Anycasting Service 1993, Informational
  • RFC 4786 Operation of Anycast Services 2006, Best Current Practice, BCP 126
  • RFC 7094 Architectural Considerations of IP Anycast 2014, Informational
  • RFC 3258 Distributing Authoritative Name Servers via Shared Unicast Addresses 2002, Informational
  • RFC 7871 Client Subnet in DNS Queries 2016, Informational
  • RFC 6707 Content Distribution Network Interconnection (CDNI) Problem Statement 2012, Informational
  • [Eisenbud2016] Maglev: A Fast and Reliable Software Network Load Balancer. Proceedings of the 13th USENIX Symposium on Networked Systems Design and Implementation (NSDI '16), pp. 523-535 2016, free

All 50 documents this chapter cites, each with a link to its publisher and a copy kept here.

Transport, chapter 20 of 36

UDP: Eight Bytes of Header

Transport, chapter 21 of 36

TCP: The Connection

Transport, chapter 22 of 36

Congestion Control: From Collapse to BBR

Transport, chapter 23 of 36

Beyond TCP: SCTP, DCCP, and Multipath

Names and Trust, chapter 24 of 36

DNS: The Namespace and the Wire Format

Names and Trust, chapter 25 of 36

Resolvers, DNSSEC, and Encrypted DNS

Names and Trust, chapter 26 of 36

TLS 1.3: The Handshake

Names and Trust, chapter 27 of 36

Certificates and the Web PKI

Applications, chapter 28 of 36

HTTP: Semantics and HTTP/1.1

Applications, chapter 29 of 36

HTTP/2: Multiplexing over One Connection

Applications, chapter 30 of 36

QUIC: A Transport in Userspace

Applications, chapter 31 of 36

HTTP/3: The Web on QUIC

Applications, chapter 32 of 36

Mail: SMTP and Forty Years of Patches

Applications, chapter 33 of 36

Time, Shells, and Files: NTP, SSH, Telnet, and FTP

The Whole Path, chapter 34 of 36

Measuring and Debugging the Path

The Whole Path, chapter 35 of 36

The Whole Journey, Byte by Byte

The Whole Path, chapter 36 of 36

Ossification and What Comes Next

You have reached the server. The book goes further.

Everything on this site is a short version. Follow the Packet is the long one: 36 chapters and about 280,000 words, with every protocol fact traced to the section of the standard that defines it, every byte dump built by a script you can run, and a directory of more than a thousand cited documents. It comes as a printable book and as an audiobook.

Hear how chapter 1 opens. 70 seconds, narrated by a synthetic voice.

Get the book or the audiobook Read the start of chapter 1 Browse every source

Cover of Follow the Packet: How the Internet Works, Layer by Layer, from ARPANET to QUIC, by Wolfgang Kerschbaumer

The signup uses double opt-in. Every message includes an unsubscribe link.

Published by Sysinit Press. The public addresses, AS numbers and names of the scenario come from ranges reserved for documentation, and the home network uses private addresses, so the site describes no real network. RFC texts are copied unchanged from the RFC Editor.