How the Internet works

Routing, chapter 18 of 36

MPLS and Segment Routing

On the backup path, two routers of AS64510 would forward our SYN without reading its destination address.

Suppose the exchange port of border1 goes dark at the moment the laptop sends its SYN. AS64500 falls back to the route it learned from its transit provider, and the SYN leaves border2 with TTL 60 for 203.0.113.129, a router of AS64510. That router looks up 192.0.2.80 once and writes four bytes in front of the IPv4 header.

03 F0 41 3B
the four bytes pe1 writes in front of the SYN's IPv4 header: label 16132, TTL 59
19.1%
of 427,121 MPLS tunnels seen from CAIDA's Ark in 2025 hid their routers from traceroute
80 bytes
what SRv6 with two SIDs adds to our 60-byte SYN, against 4 for one label

Push, swap, pop across AS64510

Our SYN's label stack on each link of the backup path from border2 to AS64505. Step from router to router, then switch between LDP and segment routing, penultimate hop popping on or off, and the uniform and short pipe TTL models.

Why forward on a label instead of an address?

RFC 3031, Section 2.1 splits a forwarding decision in two: sort packets into Forwarding Equivalence Classes, then map each class to a next hop. IP repeats the sorting at every router with a longest match. MPLS sorts once, at the ingress, and encodes the class as a short fixed-length label.

The idea arrived from several vendors in 1996 and 1997, with ATM underneath most of it. Providers paid for ATM in cells: a 44.736 Mbit/s DS3 carried 30.96 Mbit/s of IP (RFC 3439, Section 3.4). In AS64510 the interior routers carry only the IGP's routes, and pe2 looks up 192.0.2.80 itself.

What do the four extra bytes say?

Our four bytes 03 F0 41 3B split 20, 3, 1, and 8 bits in the layout of RFC 3032, Section 2.1: label 16132, Traffic Class 0, bottom-of-stack bit 1, TTL 59. Twenty bits give 1,048,576 values, and the first sixteen are reserved. Implicit NULL, value 3, may be distributed but never appears in the encapsulation.

The three bits after the label were Experimental Use in 2001, and RFC 5462 renamed them Traffic Class in 2009. The entry has no protocol field: the router that pops the last label must infer what lies underneath (RFC 3032, Section 2.2).

How do two routers agree on what a label means?

The receiver decides. The router downstream of a link binds a label to a FEC and tells its upstream neighbor, so a label means something only to the router that will receive it (RFC 3031, Section 3.4). For the FECs the IGP already knows, LDP carries those bindings over TCP port 646 (RFC 5036, Section 3.10.1).

LDP lags behind the IGP. When a link comes up, IS-IS may route across it before LDP has exchanged labels, and labeled traffic falls into a black hole. The fix changes no protocol: the IGP advertises the link with the maximum metric, 0xFFFFFE in IS-IS, until LDP is fully operational (RFC 5443, Section 2).

What happens to the TTL inside the tunnel?

RFC 3032, Section 2.4.3 copies the IP TTL into the label at the push and back at the last pop. In this uniform model the SYN leaves pe2 with TTL 56, as if AS64510 had routed it hop by hop (RFC 3443, Section 3.1). In the short pipe model it leaves with 58.

Only the uniform model lets traceroute see inside. p1 carries no BGP routes and has no route back to 198.51.100.77. It can copy the label stack onto its Time Exceeded, which travels to the end of the tunnel before it turns around (RFC 3032, Section 2.3.2). Linux drops the expired packet and sends nothing back [Linux2026].

What if the packet carried its own route?

RFC 3031 let a label stand for a route that signaling had installed in every router along it. Segment routing puts the route back into the packet and keeps per-flow state only at the ingress (RFC 8402, Section 1). Over MPLS a SID is a label, and a segment list is a label stack.

Each router sets aside a Segment Routing Global Block, and a global SID travels as an index into it (RFC 8660, Section 2.4). AS64510 uses 16000 to 23999 everywhere, and pe2's loopback carries index 132. That is the 16132 of our dump, the same on every router.

Can p1 repair a broken link before anyone else knows?

Break the link between p1 and p2 while our SYN carries 16132. p1 notices first, and on AS64510's ring it finds no loop-free alternate and no remote LFA: pe1 would hand the SYN straight back, and no PQ node exists.

TI-LFA encodes the post-convergence path as segments: the Node-SID of p4, then the Adjacency-SID from p4 over the thin link to p3 (RFC 9855, Section 5.3). p1 sends 16134 15133 16132, and nothing was signaled. For link protection on nine real topologies, a repair of at most one SID covered more than 99 percent of prefixes in eight networks (RFC 9855, Appendix B).

pe1from AS64500p1p2pe2to AS64505p4p3p510, SYN10, SYN10, SYN101010010
From the book: AS64510 (our construction): IS-IS metrics and the SYN's path on the backup route

The book keeps asking

This chapter has 5,508 words and 10 questions. These 4 are answered only in the book and the audiobook.

  • How did labels learn to take paths the IGP would not choose?
  • How does one backbone carry many private networks?
  • Why hash on a label that means nothing?
  • What changes when the segments are IPv6 addresses?

Open the sources

  • RFC 3031 Multiprotocol Label Switching Architecture 2001, Proposed Standard
  • RFC 3032 MPLS Label Stack Encoding 2001, Proposed Standard
  • RFC 5036 LDP Specification 2007, Draft Standard
  • RFC 4364 BGP/MPLS IP Virtual Private Networks (VPNs) 2006, Proposed Standard
  • RFC 8402 Segment Routing Architecture 2018, Proposed Standard
  • RFC 8660 Segment Routing with the MPLS Data Plane 2019, Proposed Standard
  • RFC 8986 Segment Routing over IPv6 (SRv6) Network Programming 2021, Proposed Standard
  • RFC 9855 Topology Independent Fast Reroute Using Segment Routing 2025, Proposed Standard

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

Routing, chapter 19 of 36

Anycast and CDNs

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.