This post covers how the MPLS protocol works. There are three relevant protocols used to label switch: LDP, RSVP and MP-BGP. They have clear distinct differences in their use cases. LDP is used for IGP label, MP-BGP is used for eBGP/iBGP label and RSVP is used for TE. This post focuses on LDP.

Label Distribution Protocol

LDP is used to automatically assign labels to IGP learned routes and exchange them between routers. A router assigns labels to prefixes independently (almost). The only other router that cares about the labels is the adjacent router. This means it's the responsiblity of the local router to choose the correct path. Downstream router "trusts" labels received are the best path.

As illustrated on the picture below, the same label can be reused by non-adjacent routers.

LDP has to establish neighbor adjacency to exchange labels. This process is very similar to the way BGP does it. TCP is used the same way as with BGP. LDP initiates this process with a hello message on the "all router" multicast address Because it uses an non-specific multicast address, it has to use an LDP specific port, which is UDP 646. When discovering each other, the routers exchange the LDP packet, which contains an LDP-ID and transport address. The router picks both the ID and transport address from the highest loopback interface IP, but they are separate fields in the packet. While the initial discovery is done using multicast, the continuous LDP communication is with unicast between the transport address. This means the routers need an IGP that routes the loopback interfaces, otherwise no LDP information will be exchanged.

Once the adjacency has been established, LDP will build the Label Information Base (LIB) and then the Label Forwarding Information Base (LFIB), the same process as RIB and FIB.

The following topology is used for the lab information:

To see the LIB, use show mpls ldp bindings:

The LIB contains the prefix and local/remote label. The prefix is taken from the routing information and if it doesnt exist in via internal routing, it won't be labelled. It'll still be installed in the LIB, but with no valid labels, it won't be put into the LFIB. Looking at the image below, I created a BGP route ( and a static route (

The BGP route will not receive a label, because LDP is used for IGP. The static route is a bit more interesting to the behavior of the label switching. To start with, I used the end switch as next-hop for the route. is routed in IGP and there is an LSP all the way. Label 21 is assigned the route, but the router is using label 19, because the label path used is based on the next-hop. If I have another route that uses 12.1.1.x/24 as next-hop, then the label used will be 21. The fact that label 19 is used on both hops in the trace is a coincidence.

Below is an illustration of whats happening between each router.

Now I change the next-hop to the network. I use R3, which is the router directly connected, instead of R6's loopback. The label changes to 17 and I can no longer reach the destination.

R3 receives this MPLS encapsulated packet and deencapsulate it, to figure out what to do next. R3 would IP forward the packet, but it doesn't have the network in the RIB.
To remedy this, I could add a static route on R3 (or just use IGP), which is what I did before the second traceroute. The process is illustrated below.

A slight backstep to take a look at some of the information presented in the LFIB, image below. I added an extra loopback on both R1 and R3, which is in VRF "user" and routed with BGP. "Pop Label" refers to the term PHP or Penultimate Hop Popping, which means the next-hop to the advertised prefix, is the owner of the network. The [V] means a VRF or BGP VPN routes.

The VPN routes are not presented with a label in the LFIB, but they do use labels. On the image below, I do a traceroute between 2 loopbacks through iBGP on R1 and R3. Getting into the specifics of this is another subject when looking at the routing in MPLS with BGP, OSPF and IS-IS.


Some useful, but not particularly concept-important things.

  • Using show mpls ldp discovery detail displays information such as hello and hold timer (default in the image below).

  • The LDP ID can be hardcoded, which is likely desirable using mpls ldp router-id lo1 [force]. The force command makes the router change the ID immediately.

  • The LFIB can contain LDP, BGP VPN and RSVP.

  • MPLS can be configured/activate several ways. One way is using the mpls ip on every interface desired. Another way is to use ldp autoconfig, which for OSPF, enables LDP for all links in that OSPF process/area.

  • When an LDP neighbor goes down, the labels are removed immediately. Both from the LFIB and LIB. Obviously, we don't want to keep labels in the LFIB, if the route is down, but it may be desirable to keep them in the LIB for faster convergence. Especially if the reconvergence is happening because of a flapping link. mpls ldp session protection configured in global enables this caching feature. It has to be configured on both routers and can be verified with a show command:

  • When manually configuring a label range for the router to use, it is required to reboot the device, if labels have already been assigned. Configure label range before establishing any adjacencies. Clearing the neighbor after configuring a label range, will not cause the labels to change.
More LDP design

If there are multiple links to the destination, it is important to keep in mind the IGP reachability. If MPLS is not enabled on all interfaces, the transport address may be reached through one of the non-MPLS interfaces. The command mpls ldp sync can be configured in the routing process to help with this issue. What it does, is removing routes from the RIB if LDP is not reachable/up. More specifically it increases the metric for the IGP route to such a high value that it's no longer considered. However, this feature doesn't work if there isn't an alternative MPLS path, as the IGP metric is simply very high, but not unreachable. If no alternative LDP exists, then the traffic will forward with IP. The synchronization can be verified with a show command:

Default LDP behavior is to assign labels to all IGP routes, but we only need labels on the LDP Transport addresses, as seen with the static route example. LDP can be configured to only assign labels to /32 interfaces (loopbacks). It's an LDP optimization feature that helps the router reduce the amount of memory used. Continuing down this road leads to a lot of options on optimization of label usages, which is better to look at when having more specific use cases. Also, GNS3 or the IOS I use lack a lot of these features.

Next is RSVP and TE along with designing a bigger network using MPLS and IGP (OSPF or IS-IS.