In the last article, we began looking at a basic configuration of MPLS to see how packets are routed across an MPLS network using labels. In this article, we will focus on the Label Distribution Protocol (LDP), one of the protocols used in MPLS networks to distribute labels. We will also discuss the different data structures used by MPLS routers: LIB and LFIB. Our network diagram is as shown below:

LDP Operation

A router will send LDP hello messages frequently on its MPLS-enabled interfaces. These hello messages are sent to the multicast address on UDP 646. Below, you can see an LDP packet I captured off PE1’s Fa0/0 interface.

When an LSR on the other end receives the hello packets, both routers attempt to establish a TCP session over port 646. The LSR with the higher LDP ID (the active LSR) is the one that initiates the TCP session to the passive LSR. For example, between PE1 and P1, P1 ( will be the one to initiate the TCP session to PE1 (

Once the TCP connection is formed, the active LSR sends an initialization message to the passive LSR containing parameters to use for the LDP session.

If the parameters are acceptable, the passive LSR also sends an initialization message to propose the parameters it wishes to use; else it sends an error notification message. Following this initialization message, the passive LSR also sends a keepalive message to the active LSR.

If the active LSR accepts the parameters specified by the passive LSR, it will also reply with its own keepalive message and the LDP session is now active. If the parameters are unacceptable, the active LSR will send an error notification message to the passive LSR and the connection will be closed.

When the LDP session has successfully formed, the LDP neighbors can then exchange label/prefix information via label mapping messages.

Note: There are two types of label advertisement modes: Downstream unsolicited and Downstream on Demand which are beyond the scope of this article.

Below is an example of the contents of a label mapping message sent by P1 to PE2 containing the label (0x11, which is equivalent to 17 in decimal) assigned to a particular prefix (

We can see from the output below that 17 is indeed the label P1 assigned for prefix

Before we move on to the next session, I want to quickly highlight a requirement for LDP neighbors to form an LDP session. For an LDP session to form between two LDP routers, the LDP router ID of the peer must be present in the routing table of the other peer. For example, PE1 has formed an LDP session with P2 only because it has a route for in its routing table.

If P2 were to stop advertising that IP address, the LDP session will eventually be terminated (it won’t go down immediately until the keepalive expires).

If you check the neighbors on PE1, P2 will no longer be listed.

However, the show mpls ldp discovery detail command can give you more insight into what is causing the neighbor relationship not to form.

This shows us clearly that LDP relies on the routing table and we will see this reliance on a greater level in the next section where we will be talking about LIB and LFIB.

Relationship among the RIB, FIB, LIB and LFIB

While studying MPLS, you will come across terms that play different roles such as FIB, LIB and LFIB. It can be a bit confusing to understand what each of these terms does so we will try to explain the relationships between each.

CCNA Training – Resources (Intense)

The Routing Information Base (RIB) is basically the routing table that is populated with static routes, routing protocols and connected routes. We use the show ip route command to view the RIB.

CEF uses information from the RIB to populate the Forwarding Information Base (FIB) which is what the router actually uses to forward packets. The FIB contains a next-hop router and an outgoing interface for each destination IP prefix in the RIB. We can view the CEF FIB using the show ip cef command.

Note: While the RIB functions in the control plane, the FIB operates in the data plane. CEF also uses another table called the Adjacency table which helps the router with Layer 2 rewrite of packets.

When LDP is enabled on a router, the router will assign a local label to each IP prefix in its routing table. This label/prefix mapping on the router is called a local binding. The router will then advertise this label and prefix mapping out to its neighbors. The router’s LDP neighbors will also do the same with the prefixes in their own routing table and advertise the binding to their neighbors. The received label/prefix mapping from LDP neighbors then becomes remote bindings on the router. The local bindings and remote bindings are stored in the Label Information Base (LIB). We can view the LIB using the show mpls ldp bindings command.

A route may be learned from different IGP neighbors; however, an IGP selects the best path to use (or paths, in the case of load balancing) to reach a particular destination. In the same way, the LIB can contain more than one remote binding for a particular prefix but must select the best path (label and outgoing interface) to use.

LDP relies on the best path(s) specified in the routing table and populates the Label Forwarding Information Base (LFIB) with this best path information. The FIB is also populated with this best label information for the particular destination prefix. The command to view the LFIB is show mpls forwarding-table.

Example of Relationship among RIB, FIB, LIB and LFIB

Let’s use an example to see how all these different data structures fit together. We will use PE2 as our reference router and as our reference route. The first thing we will do is check the routing table (RIB) of PE2 for the route.

Since that prefix is in PE2’s routing table, it will assign a local label for the route. Also, PE2 would have received remote bindings for that prefix from its LDP neighbors. We will check the LIB for this information.

The first thing we notice from the output above is the local label that PE2 has assigned to that prefix – 21. Also, we see that PE1 has received two remote bindings from its LDP neighbors: one from (P1) and another from (P2).

To decide which of the remote bindings to use, PE2 looks at the routing table for the best path that the routing protocol has chosen. Looking at our routing table output above, we see that PE2 is using as the next-hop but PE2 has not received remote bindings from “”. When an LDP session is formed between neighbors, they also inform themselves of all the IP addresses with which they have been assigned. These are called bound addresses.

Therefore, PE2 knows that the next-hop address belongs to its LDP neighbor. At this point, PE2 will populate the entry for in its LFIB with the label in the remote binding received from, i.e. label 20.

The FIB will also have this label information for the particular prefix.

The question then becomes: when is the FIB used instead of the LFIB and vice versa? Find out in the next article.


Let’s stop here for now. In this article, we have discussed the operation of LDP and also looked at the different data structures used in MPLS, including LIB and LFIB.

We will talk about how these labels are used and the various functions that LSRs perform on labels in the next article. We will also see how packets are routed through an MPLS network. I hope you have found this article insightful.

References and further reading

  1. MPLS Configuration on Cisco IOS Software by Lancy Lobo
  2. MPLS Fundamentals by Luc De Ghein
  3. RFC 5036: LDP Specification: