LABS · PROTOCOLS · ONE STEP FURTHER

MPLS and LDP: how a provider distributes labels

The foundation of provider networks, message by message: LDP Hellos, the TCP session between Loopbacks, label distribution and a ping that travels labeled from Vancouver to Toronto.

Level: advanced · 20 minutes

Interactive simulation

The animation needs JavaScript. The full lesson is written out below.

Download the capture and open it in Wireshark to keep exploring.

What MPLS and LDP are

MPLS (MultiProtocol Label Switching, RFC 3031) adds a 4-byte label between the layer 2 header and the IP header. Core routers forward on that label, without looking up the destination IP in their routing table. That lets a provider carry IP traffic, layer 3 VPNs (L3VPN) and layer 2 VPNs (VPLS) over the same core, or choose paths with traffic engineering.

LDP (Label Distribution Protocol, RFC 5036) is the protocol that distributes those labels: each router assigns a local label to each prefix in its routing table and advertises it to its LDP neighbors. LDP doesn't compute paths: it follows the ones the IGP chose, IS-IS in this case.

The MPLS label

FieldBitsPurpose
Label20The value routers switch on. 0 to 15 are reserved; Cisco assigns from 16
TC3Quality of service (formerly called EXP)
S11 if it is the last label in the stack; IP comes next
TTL8Decremented by 1 at each hop, like IP's, to prevent loops

A packet can carry several stacked labels: in an L3VPN, the outer one takes the packet to the egress PE and the inner one says which VPN it belongs to. On Ethernet, EtherType 0x8847 signals that a label follows, not IP.

How it works: from Hello to labeled traffic

Six steps: discovery, the TCP session, initialization, label distribution, labeled traffic and keepalives.

  1. Hello: «I speak LDP on this link»

    Once mpls ip is enabled on the interface, each router sends an LDP Hello every 5 s to 224.0.0.2 over UDP 646, with TTL 1 because it must not leave the link. The Hello carries its LDP ID (router ID 10.255.0.x and label space 0), a 15 s hold time and its transport address: Loopback0, which it will open the session with. When each one receives the other's Hello, it knows there is an LDP neighbor.

  2. TCP 646 between the Loopbacks

    Labels don't travel in Hellos: they travel over a reliable TCP session between the transport addresses. To avoid opening two connections, only the router with the higher address opens it: P1 (10.255.0.2) is the active side and connects from a high port to port 646 on PE1 (10.255.0.1), the passive side. The Loopbacks are reachable because IS-IS already knows them.

  3. Initialization and KeepAlive: Operational

    P1 sends an Initialization with the LDP version, a 180 s keepalive, unsolicited distribution (each one advertises its labels without waiting to be asked) and PE1's LDP ID as the receiver. PE1 accepts: it replies with its own Initialization and a KeepAlive. When P1 confirms with another KeepAlive, the session becomes Operational and PE1 logs %LDP-5-NBRCHG … is UP.

  4. Address and Label Mapping

    Each one sends an Address message with its IPs, so the other knows which labels come from which next hop, and one Label Mapping per prefix. Labels are local: PE1 chose 17 for 10.255.0.3/32 and P1 chose 21 for the same prefix. For what is its own (its Loopback and connected networks) each router advertises implicit null, label 3: «send it to me without a label».

  5. Traffic travels labeled

    PE1 pings 10.255.0.3 from its Loopback. In its MPLS forwarding table, that prefix goes out via P1 with label 21, the one P1 advertised: PE1 pushes that label (EtherType 0x8847) and P1 switches the packet just by looking at it. PE2's reply reaches PE1 as a normal IP packet: PE1 advertised implicit null for its Loopback, so P1 removed the label one hop earlier (PHP) and PE1 doesn't have to look up twice.

  6. KeepAlive every 60 s

    As long as the topology doesn't change, LDP only sends a KeepAlive every 60 s (a third of the 180 s) and Hellos every 5 s on the link. If nothing arrives over the session in 180 s, or no Hello arrives in 15 s, the neighbor goes down and its labels are deleted. When IS-IS learns a new prefix, LDP assigns it a label and advertises it without waiting for anyone.

The routers and the tables

TermWhat it is
LSRLabel Switching Router: any router that switches on labels
PE (LER)Provider edge router: pushes the label on entry and removes it on exit
PCore router: only swaps one label for another
LSPLabel Switched Path: the path of labels toward a destination, in one direction
FECForwarding equivalence class: the group of packets treated the same way (here, a prefix)
LIBLabel information base: the local label and every neighbor's label for each prefix
LFIBMPLS forwarding table: only the label of the next hop the IGP chose

There are three operations: push (add a label), swap (replace it) and pop (remove it). With PHP (penultimate hop popping), the second-to-last router pops, because the last one advertised implicit null (3): that way the egress router only does one lookup, in its IP table.

LDP messages

MessageOverPurpose
HelloUDP 646 to 224.0.0.2Discover neighbors on the link (or targeted at a remote neighbor)
InitializationTCP 646Negotiate the session parameters
KeepAliveTCP 646Confirm initialization and keep the session up
AddressTCP 646Advertise the router's IPs
Label MappingTCP 646Advertise a prefix's label
Label Withdraw / ReleaseTCP 646Withdraw a label that is no longer valid
NotificationTCP 646Report an error or an event

The commands in Cisco IOS XE

CommandWhat it does or shows
mpls ip (on the interface)Enables MPLS and LDP on the link.
mpls ldp router-id Loopback0 forceUses Loopback0 as the LDP ID and transport address.
mpls ldp autoconfig (under router isis or ospf)Enables LDP on all IGP interfaces.
show mpls interfacesWhich interfaces have MPLS and LDP.
show mpls ldp discoveryHellos sent and received, and the neighbors discovered.
show mpls ldp neighborThe sessions: state, TCP connection and the neighbor's addresses.
show mpls ldp bindingsThe LIB: local and remote labels for each prefix.
show mpls forwarding-tableThe LFIB: local label, outgoing label (or Pop Label), interface and next hop.

MPLS isn't in the CCNA v2.0 exam topics: it's one step further toward CCNP Enterprise, whose ENARSI exam (300-410) asks you to describe MPLS operations (LSR, LDP, label switching and LSP), and toward CCNP Service Provider (SPCOR 350-501 exam), where MPLS and MPLS VPNs are at the heart of the provider core.

Frequently asked questions

Why does the session run between the Loopbacks?

Because a Loopback doesn't go down when a link does. If two routers have several links between them, a single session between the Loopbacks serves them all.

What happens if the IGP doesn't know the neighbor's Loopback?

Hellos arrive, but the TCP session doesn't open: the neighbor shows up in show mpls ldp discovery but not in show mpls ldp neighbor.

Why do P1 and PE1 use different labels for the same prefix?

Because each label only means something to the router that assigned it. PE1 chose 17 for 10.255.0.3/32 and advertises it to its neighbors; P1 chose 21 for the same prefix.

What are implicit null and explicit null?

Implicit null (3) asks the previous router to remove the label (PHP). Explicit null (0) asks it to keep a label 0, to preserve the TC quality-of-service field up to the last hop.

What QoS marking does LDP carry?

Cisco sends control traffic with IP precedence 6 (CS6), as in this lab. Check it in your own capture.

What you take away

  • MPLS forwards on a 4-byte label between Ethernet and IP (EtherType 0x8847).
  • LDP discovers neighbors with Hellos to 224.0.0.2 over UDP 646.
  • The session runs over TCP 646 between the Loopbacks; the higher address opens it.
  • Each router assigns local labels and advertises them with Label Mapping.
  • Implicit null (3) makes the penultimate router remove the label (PHP).
  • LDP follows the IGP's paths: without IS-IS or OSPF there is no LSP.

NEXT STEP

From the provider core to the Career Plan

MPLS is the foundation of provider VPNs: L3VPN, VPLS and Segment Routing build on what you just saw. You'll see them in detail in The House of Routing master classes. We'll let you know when there's news.

Upcoming protocol lessons

Sources

Lesson prepared with AI assistance and checked against the sources cited. The bytes of every packet are generated according to the standard and verified with an independent tool.