Sub topic 6
Labels, LSRs, and LSPs: push, swap, and pop
This chapter assumes you can read IPv4 routing tables, know how an IGP such as OSPF builds routes, and understand the idea of a next hop. It builds on the previous chapter's question of why providers moved beyond point-to-point circuits.
The working model
MPLS forwards packets by looking up a short fixed-length label instead of a destination IP address. A label is a 20-bit value carried in a 32-bit shim header placed between the Layer 2 header and the IP header. The shim also holds 3 bits for traffic class (EXP/TC), 1 bit marking the bottom of the label stack, and an 8-bit TTL.
Three terms matter here:
- A label switching router (LSR) is any router that forwards packets based on labels.
- A label switched path (LSP) is the one-way chain of LSRs a labeled packet follows across the network.
- A forwarding equivalence class (FEC) is a group of packets treated the same way. In a basic provider network, a FEC is usually one IGP prefix, such as a PE loopback.
Roles at the edge and in the core:
- The ingress LSR (a PE router) receives an unlabeled IP packet and pushes a label.
- A transit LSR (a P router) swaps the incoming label for an outgoing label.
- The egress LSR pops the label, or the router before it does, and the packet continues as plain IP.
How labels get distributed
Labels have only local meaning. Each LSR picks a label for each prefix in its routing table and tells its neighbors. Label Distribution Protocol (LDP) does this over TCP port 646, after neighbors find each other with UDP hellos on port 646. Each router stores the result in the label forwarding information base (LFIB). CEF must be enabled first, as in the earlier configuration:
ip cef
mpls label protocol ldp
!
interface GigabitEthernet0/1
ip address 10.0.0.1 255.255.255.252
mpls ip
no shutdownThe mpls ip command on each core-facing interface enables LDP there. Check the result with show mpls ldp neighbor and show mpls forwarding-table.
Tracing a packet
Take a path PE1 → P1 → P2 → PE2. PE2 owns the loopback 10.255.255.2/32. Labels are assigned from the destination backward: each router advertises its chosen label to its upstream neighbor.
The steps:
- PE1 looks up 10.255.255.2 and finds the next hop P1 with label 17. It pushes 17.
- P1 looks up 17 in its LFIB. It swaps 17 for 24 and sends the packet to P2.
- P2 is the penultimate hop. PE2 advertised the implicit-null label (value 3), which tells P2 to pop the label. This is penultimate hop popping (PHP).
- PE2 receives a plain IP packet and does a normal IP lookup.
PHP saves PE2 from doing two lookups, one on the label and one on the IP address.
Common errors
- LDP neighbors never form. LDP picks its router ID from the highest loopback by default, and neighbors must be able to reach that address. If the IGP does not advertise it, the TCP session fails.
- Broken LSP after an IGP change. Labels follow IGP routes. A missing prefix in the IGP means no label for it, so traffic drops or falls back to a slower path.
- MTU problems. Each label adds 4 bytes. A full 1500-byte IP packet with one label becomes 1504 bytes and may be dropped on links with a 1500-byte MTU. Raise the MTU on core links.
- Summarized loopbacks. Summarizing PE loopbacks breaks the LSP, because LDP needs a label for the exact /32.
Exercise
A packet enters PE1 as plain IP. P1 receives it with label 17 and sends it onward with label 24. Name the operation at PE1, the operation at P1, and why the label values differ between hops.
Show answer
PE1 pushes label 17. P1 swaps 17 for 24. The values differ because labels have only local significance: each LSR allocates its own label for a prefix and advertises it to its upstream neighbor through LDP.
Exercise
Why can a link with a 1500-byte MTU drop packets after MPLS is enabled, and what is the fix?
Show answer
Each MPLS label adds 4 bytes, so a full 1500-byte IP packet becomes 1504 bytes and exceeds the link MTU. Increase the MTU on core links, for example to 1508 or higher to allow for several labels.