Skip to content
Documentation Background

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.


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 |
FieldSizePurpose
Label20 bitsThe lookup key
Traffic class3 bitsQoS marking
Bottom of stack1 bitSet on the last label when several are stacked
TTL8 bitsLoop 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.


A label-switching router (LSR) forwards by looking up the incoming label in a small table. There is no longest-prefix match.

OperationWhereWhat happens
PushIngress edge routerLooks at the IP destination once, picks a label, attaches it
SwapCore routersReplaces the incoming label with an outgoing label and forwards out an interface
PopEgress edge routerRemoves 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 labelOut labelOut interface
17221
4090

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.


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.


MPLSSDN with OpenFlowSegment routing
ControlDistributed signaling protocolsCentral controllerSource routing using a stack of labels
ForwardingLabel lookupMulti-field match plus actionLabel (or IPv6 header) stack
State in the corePer-LSPPer-flow rulesNone 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.


If a path crosses an MPLS network, traceroute shows it in two ways.

Terminal window
# Linux traceroute prints MPLS labels carried in ICMP extensions
traceroute -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 -e and mtr -e display.
  • 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.