Sub topic 6
Labels, LSRs, and LSPs: push, swap, and pop
This chapter explains how a packet crosses an MPLS core using labels. It assumes you know IPv4 routing, can read a router routing table, and have read the previous chapter on why providers adopted MPLS. You should also be comfortable reading basic Cisco IOS configuration.
The working model
In ordinary IP forwarding, every router looks up the destination address in its routing table. It uses the longest-prefix match. Every router in the path repeats this work.
MPLS (Multiprotocol Label Switching) changes where the expensive decision happens. The first router at the edge of the provider network classifies the packet once. It attaches a short fixed-length label that says which path the packet should follow. Routers inside the core then forward on the label alone, using a simple exact-match lookup. They do not need to inspect the IP header.
Three terms carry most of the model:
- Label: a 20-bit number that identifies a forwarding class. It has meaning only on one link, between two neighboring routers.
- LSR (Label Switching Router): any router that forwards packets based on labels.
- LSP (Label Switched Path): the one-way path a labeled packet follows from the ingress router to the egress router.
LSRs have specific roles depending on where they sit:
| Role | Also called | Position | Main job |
|---|---|---|---|
| Ingress LSR | Ingress PE | Edge, where traffic enters MPLS | Push a label |
| Transit LSR | P router | Core | Swap the label |
| Egress LSR | Egress PE | Edge, where traffic leaves MPLS | Pop the label, forward as IP |
The label stack entry
A label sits in a 32-bit shim header placed between the Layer 2 header and the IP header. For this reason MPLS is sometimes described as a "Layer 2.5" technology. The header has four fields.
| Field | Size | Purpose |
|---|---|---|
| Label | 20 bits | The label value used for the lookup |
| TC (Traffic Class) | 3 bits | Used for QoS. Formerly called EXP. |
| S (Bottom of Stack) | 1 bit | Set to 1 on the last label in the stack |
| TTL | 8 bits | Loop prevention, copied from the IP TTL on entry |
Packets can carry more than one label. This is a label stack. The top label is the one the core routers read. Later chapters use a second, inner label to identify the customer VPN, while the outer label carries the packet across the core.
Label values 0 to 15 are reserved. Label 3, the implicit null label, has a special role described below.
Push, swap, and pop
Three operations make up all label forwarding.
- Push: the ingress router adds a label (or another label on top of an existing stack).
- Swap: a transit router replaces the top label with a new one and sends the packet to the next hop.
- Pop: a router removes the top label.
Each LSR keeps a LFIB (Label Forwarding Information Base). This table maps an incoming label to an outgoing label and an outgoing interface. The ingress router uses the regular FIB, extended with a label to push, because its input is still an unlabeled IP packet.
A worked example
Consider a provider core with four routers. A customer packet for 10.1.1.0/24 enters at PE1 and leaves at PE2.
The steps are:
- CE1 sends a plain IP packet to PE1. PE1 looks up 10.1.1.0/24 and finds it must push label 17.
- P1 receives label 17. Its LFIB says: in 17, out 24, via the link to P2. It swaps the label.
- P2 receives label 24. P2 is the next-to-last router and the egress PE2 asked for implicit null, so P2 pops the label.
- PE2 receives an unlabeled IP packet and forwards it by normal IP lookup.
Notice that label 17 and label 24 describe the same path. Labels are local to each link, so each router can pick its own values without coordinating the whole network.
Penultimate hop popping
Step 3 is penultimate hop popping (PHP). The router one hop before the egress removes the label. The egress router is then spared two lookups, a label lookup and an IP lookup, and does only the IP lookup. The egress signals this by advertising label 3 (implicit null) for the prefix.
PHP has a side effect that matters when you also use QoS. The egress router no longer sees the TC bits, because the label is already gone. Some QoS designs change this behavior on purpose. The QoS chapter covers that.
How labels get distributed
Labels are useless unless neighbors agree on them. A label distribution protocol does this. The most common is LDP (Label Distribution Protocol).
LDP works in a straightforward way:
- Routers run an IGP such as OSPF or IS-IS. The IGP builds the ordinary routing table.
- Neighbors discover each other with LDP Hello messages sent by UDP to 224.0.0.2 on port 646.
- Neighbors form a TCP session on port 646, using the router IDs.
- Each router creates a local label for every prefix in its routing table and advertises the binding to its neighbors.
- For each prefix, a router uses the label advertised by the next hop that its IGP selected as the best path. That label becomes the outgoing label.
The result is that LSPs follow the IGP shortest paths. LDP does not choose paths. It only attaches labels to paths the IGP already chose.
LDP needs the IGP to be working first. If the IGP is broken, no labels form. LDP also needs an LDP session to be up between each pair of neighbors. The next section shows the router configuration that enables it.
Configuring and verifying MPLS
This configuration enables CEF and LDP on a core-facing link, as in the earlier plan examples.
ip cef
mpls label protocol ldp
!
interface GigabitEthernet0/1
ip address 10.0.0.1 255.255.255.252
mpls ip
no shutdownCEF (Cisco Express Forwarding) is required. It is the FIB that MPLS extends with labels. The mpls ip command on an interface turns on label switching and starts LDP there.
Useful verification commands on Cisco IOS:
show mpls interfaceslists the interfaces running MPLS.show mpls ldp neighborshows LDP sessions and their state.show mpls ldp bindingslists local and remote label bindings per prefix.show mpls forwarding-tableprints the LFIB with local label, outgoing label, prefix, and next hop.traceroutefrom a labeled router often shows the label used at each hop.
In the LFIB output, an outgoing label of Pop Label means the router is the penultimate hop for that prefix. An entry of No Label means the next hop did not advertise a binding, so the packet leaves unlabeled.
Common errors and edge cases
Most MPLS problems come from the IGP, LDP, or MTU, in that order.
- LDP neighbor does not form. Check that the IGP route to the peer's router ID exists. LDP uses the highest loopback address as its router ID by default, and that address must be reachable. A common fix is to set
mpls ldp router-id Loopback0 force. - Hellos go out but no session forms. A firewall or ACL may block TCP 646 or UDP 646.
- Missing label for a prefix. By default LDP advertises bindings for all IGP prefixes. If someone filters bindings, only part of the network gets LSPs. Packets for the missing prefix fall back to unlabeled forwarding.
- MTU problems. Each label adds 4 bytes. A packet with a two-label stack grows by 8 bytes. If the core links use a 1500-byte MTU, full-size customer packets may exceed it. Raise the interface MTU (for example
mtu 1520or the provider's jumbo setting). Alternatively usempls mtu. Symptoms are that small pings work but large transfers stall. - Asymmetric paths. An LSP is one-way. The return traffic uses a different LSP, found by the egress router as the ingress for that direction. A path can work in one direction and fail in the other.
- TTL behavior. By default, the IP TTL is copied into the label TTL at ingress, so
tracerouteshows each core hop. Providers often hide the core withno mpls ip propagate-ttl.
Why this design pays off
Forwarding on a label is simpler than a longest-prefix match, but modern hardware makes both fast, so raw speed is no longer the main benefit. The lasting benefits are these:
- The core does not need to know customer routes. Core routers only carry provider infrastructure prefixes and labels. This is what makes MPLS Layer 3 VPNs possible.
- Traffic can follow engineered paths that differ from the IGP shortest path, using traffic engineering.
- QoS markings travel in the TC bits through the whole core.
The next chapters build on this foundation. Layer 3 VPNs use a second label to separate customers.
Summary of the forwarding rules
| Router type | Receives | Action | Sends |
|---|---|---|---|
| Ingress PE | IP packet | Push label | Labeled packet |
| Transit P | Labeled packet | Swap label | Labeled packet |
| Penultimate P | Labeled packet | Pop label (PHP) | IP packet |
| Egress PE | IP packet | IP lookup | IP packet |
Exercise
A packet crosses PE1, P1, P2, and PE2. PE1 pushes label 30. P1 swaps it to 41. P2 is the penultimate hop and PE2 advertised implicit null. What does PE2 receive, and why does PE2's LFIB not need an entry for this prefix's label?
Show answer
PE2 receives a plain, unlabeled IP packet, because P2 popped label 41 under penultimate hop popping. PE2 advertised implicit null (label 3), which tells P2 to pop rather than swap. PE2 therefore never sees a label for this prefix and only does a normal IP lookup.
Exercise
Users report that small pings across the MPLS core succeed, but file transfers stall. The core links use a 1500-byte MTU and carry two-label stacks. What is the likely cause and the fix?
Show answer
The two labels add 8 bytes, so full-size 1500-byte customer packets exceed the 1500-byte core MTU and are dropped or fragmented. Small packets fit. Raise the core interface MTU to at least 1508 (providers commonly use 1520 or more) and retest with a full-size ping that sets the do-not-fragment bit.