MPLS
Multiprotocol Label Switching (MPLS) forwards packets using a short fixed-length label instead of looking up the destination IP address. It grew out of the late-1990s effort to make IP forwarding faster, borrowing ideas from virtual-circuit networks. Hardware later made plain IP lookups fast enough, but MPLS stayed because of what it makes easy: explicit paths, quick failover, and private networks over shared infrastructure. It is mostly a service provider and large enterprise technology, but you meet it as a customer of a WAN service or when reading a traceroute through a carrier.
MPLS does not replace IP. The network still runs an ordinary routing protocol such as OSPF. MPLS adds labels on top of it.
The label
Section titled “The label”A 4-byte MPLS header sits between the link-layer header and the IP header, so it is sometimes called a layer 2.5 header.
| Ethernet header | MPLS header | IP header | payload | FCS || Field | Size | Purpose |
|---|---|---|
| Label | 20 bits | The lookup key |
| Traffic class | 3 bits | QoS marking |
| Bottom of stack | 1 bit | Set on the last label when several are stacked |
| TTL | 8 bits | Loop protection, like the IP TTL |
Labels can be stacked. An outer label steers the packet across the provider’s network and an inner label identifies a customer or service.
Push, swap, pop
Section titled “Push, swap, pop”A label-switching router (LSR) forwards by looking up the incoming label in a small table. There is no longest-prefix match.
| Operation | Where | What happens |
|---|---|---|
| Push | Ingress edge router | Looks at the IP destination once, picks a label, attaches it |
| Swap | Core routers | Replaces the incoming label with an outgoing label and forwards out an interface |
| Pop | Egress edge router | Removes the label and forwards the plain IP packet |
flowchart LR
C1["Customer site A"] -->|"IP packet"| PE1["Ingress router<br/>push label 17"]
PE1 -->|"label 17"| P1["Core router<br/>swap 17 to 22"]
P1 -->|"label 22"| P2["Core router<br/>swap 22 to 31"]
P2 -->|"label 31"| PE2["Egress router<br/>pop"]
PE2 -->|"IP packet"| C2["Customer site B"]
A sample table on a core router:
| In label | Out label | Out interface |
|---|---|---|
| 17 | 22 | 1 |
| 40 | 9 | 0 |
The path a packet takes is called a label-switched path (LSP). Routers learn which labels go with which destinations through a signaling protocol. The IETF defines RSVP-TE, which can reserve bandwidth on an explicit path, and LDP is the simpler protocol that builds label bindings along the existing IP routes.
What MPLS is used for
Section titled “What MPLS is used for”Traffic engineering. IP routing sends all traffic for a destination along one least-cost path. With MPLS an operator can set up an LSP along a chosen route, split traffic for the same destination across several, or steer a class of traffic onto a particular link. The routing protocol is extended to advertise how much bandwidth is free on each link.
Fast reroute. A backup path can be prepared in advance. When a link fails, the router adjacent to the failure moves traffic onto the backup immediately, without waiting for routing to reconverge. Restoration times are typically tens of milliseconds.
VPNs. A provider can carry many customers over the same backbone and keep their traffic and address spaces separate. The outer label crosses the provider core. An inner label identifies the customer’s virtual network. Customers can use overlapping private address ranges because the labels, not the IP addresses, decide where packets go inside the provider. This is the technology behind many “private WAN” services sold by carriers.
MPLS compared with its successors
Section titled “MPLS compared with its successors”| MPLS | SDN with OpenFlow | Segment routing | |
|---|---|---|---|
| Control | Distributed signaling protocols | Central controller | Source routing using a stack of labels |
| Forwarding | Label lookup | Multi-field match plus action | Label (or IPv6 header) stack |
| State in the core | Per-LSP | Per-flow rules | None per path |
Generalized match-plus-action forwarding, described in SDN and OpenFlow, can do the traffic engineering that MPLS pioneered, and segment routing carries the path in the packet itself so core routers hold no per-path state. Providers are migrating gradually. MPLS remains in wide use.
Seeing MPLS from the outside
Section titled “Seeing MPLS from the outside”If a path crosses an MPLS network, traceroute shows it in two ways.
# Linux traceroute prints MPLS labels carried in ICMP extensionstraceroute -e 203.0.113.50# 4 core1.example.net (198.51.100.2) 9.1 ms <MPLS:L=22,E=0,S=1,T=1>- Some routers include the label stack in the ICMP “time exceeded” reply, which
traceroute -eandmtr -edisplay. - Providers often set the core to not copy the IP TTL into the label. The core routers are then invisible, and a path appears to jump from the edge on one side to the edge on the other in a single hop, with an unexpectedly long latency for that hop.