Within this article, we will look into the basics of MPLS.
To understand the need for MPLS, let us first review the process of IP packet forwarding.

IP Packet Process

When a router needs to forward a packet to another router, there are 3 basic steps:

  1. The router looks within its routing table for the longest match for the destination route.
  2. The router checks if there is any special treatment that must be applied to the traffic (i.e transmission priority, queuing etc).
  3. The router will send the packet to the necessary next-hop IP address via the appropriate interface.

The packet is then forwarded across the network (hop by hop), with each router performing the steps above i.e an IP lookup.

However, this isn't always the most optimal method of packet forwarding. Especially when it comes to service providers, that have extremely large routing tables.

So, What is MPLS?

MPLS is a switching mechanism based on labels. This switching works by an MPLS label being pushed (inserted) into the packet, between the L2 and L3 headers (shown below). Each router along the path then switches the packet based upon the label, relating to the information it has within its Label Information Base (LIB). This, in turn, negates any hop by hop IP lookups from occurring, that we have within traditional IP routing.

The key point about the LIB, is that it is precalculated, and simply contains the input label, along with the output label and interface. Therefore with MPLS,

.. the computation/overhead required to forward the packet is greatly reduced compared to that of IP.

Figure 1 - MPLS header.[1]

Router Types

Within MPLS there are 3 main types of router. They are:

  • Customer Edge (CE) - This is the router that is that connects the customer to the service provider cloud. This router typically will forward the packet onto the PE via IP, therefore the CE does NOT perform any MPLS actions.
  • Provider Edge (PE) - The PE connects the customer to the provider cloud, i.e the MPLS begins at the PE; IP packets go in and MPLS packets come out. Note: The PE is also known as the LER (Label Edge Router).
  • Provider (P) - The main backbone routers are known as the Provider routers. Their role is to take MPLS in and send MPLS out. Note: The P router is also known as the LSR (Label Switch Router).

Figure 2 - MPLS Router Types.

Label Switched Path (LSP)

Let us now look at the LSP and FEC. Let us walk through an example to best explain these terms:

  1. A native (IP) traffic arrives at the PE.
  2. The FEC (Forward Equivalence Class) table is checked. The FEC binds/groups a set of packets with similar or identical characteristics (such as IP destination) which may be forwarded the same way; that is, they may be bound to the same MPLS label.[2]
  3. This results in an MPLS label of 100 being pushed (inserted) into the packet and sent out of the corresponding interface.
  4. The provider router will then receive the packet, check its LIB for the against the incoming label and then swap the label accordingly (in our case to 200). Once done the packet is sent out of the corresponding interface.
  5. This process is then performed on each provider router until the packet reaches the PE.
  6. The PE will then check its FEC. As it's the end of the MPLS switching the label is popped (removed) before being sent out the interface, towards the destination.

The path set up across the network in this way is called the LSP (Label Switched Path).

Figure 3 - MPLS FEC and LSP.

Label Distribution

The LIB and FEC tables are built dynamically using LDP (Label Distribution Protocol). LDP works in conjunction with the IGP (typically OSPF or ISIS).

At the point, the destination PE learns of an IP (in our example The IGP updates the neighbouring routers Label Tables with the IP. At the same time, label assignment is performed by LDP. This process continues all the way to the far end router until the final label binding (ingress FEC) is made.

Note: CEF builds an optimized version of the LIB, the FLIB (Forwarding Label Information Base), within the forwarding plane. This is then used by the router to make forwarding decisions based on the labels. The LIB, LFIB can be thought of as a label version of the RIB and FIB within CEF, used for layer 3 packet forwarding.

Penultimate Hop Pop (PHP)

PHP prevents the PE from having to perform the LIB lookup when it receives a packet in order to pop the label. Instead, the provider router, penultimate (last-hop) removes (pops) the label and passes it onto the PE. Therefore saving the PE from an additional LIB lookup.


  1. "In MPLS VPN, Which one become first? MPLS Label tag or VPN ...." 5 Nov. 2015, Accessed 1 Jun. 2018. ↩︎

  2. "Forwarding equivalence class - Wikipedia." Accessed 31 May. 2018. ↩︎

Want to Learn Network Automation?
Join our membership and get access to:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Tech demos and sessions

Join Now ➜