Hi, it’s me again. After a two weeks pause, I am ready to rumble. Today’s topic is something very special. A lot of you might already have heard or even used MPLS, but what is MPLS and why was it invented in the first place? Come along to learn about the past and how it was molded to fit our current networking needs.
Facing problems
Imagine being a ISP in the late 1990s and you are just about to expand your little local network into a nationally available ISP. When creating such big networks, you suddenly have to think a bit more about the available ressources you’ve got at hand, because your network design might scale, but not exactly ressource friendly. You want to deploy the usual services in your network: voice, video and data communications. It is now that you realise, that putting a router capable of all the IP addresses you need inside your network in every location becomes quite expensive. You also have to completely rethink the way you handle priority traffic inside your networks.
You need a solution for all of this. And the answer is quite simple: you use the newly implemented MPLS, or Multi Protocol Label Switching.
But what exactly is MPLS?
MPLS allows you to make routing decisions not based on IP addresses but rather on a broader means of adressing, the so called Labels (hence the name Label Switching in MPLS). A label, or actually MPLS or SHIM header, is a new header inside your networking packets, which directly follows the layer 2 header, thus often being called the layer 2.5.
A SHIM header is not that complicated at all, it used 4 bytes of data (32 bit):
- 20 Bit for the Label, this is “just” a number (more on that in a little bit)
- 3 Bit for the Traffic Class, this is used to enable CoS
- 1 Bit known as the “Bottom of Stack” bit
- 8 Bit for the TTL
What are labels used for?

Lets make an analogy. Think about yourself as the router. You tell your buddy Alex, who hands you over little boxes, that if he wants you to hand them to Steve on your left, he should write 1234 on the box. If he however wants you to hand them to Mike on your right, he shall write 5678 on the box. These number represent the Labels in MPLS and you become the so called Label Switching Router (or LSR for short). You do not need to worry about where these boxes come from, you just look at the number and hand them along the line.
This gives you great speed improvements. It also allows you to reduce the number of people you need to know. You don’t care, whether Steve hands the boxes to Phillip or Josh. And this is basically how MPLS works.
The only thing that’s left to know about the working principle of MPLS is the following: How does Alex know, what he needs to write down on the box in order to reach Josh?
Label Distribution Protocol
The idea is simple, you just tell your neighbors, who you know and for each neighbor, you assign a number (that’s the label) a person needs to write on the box for you to hand it to the right person. Let’s make an example
- Steve knows about Phillip and Josh. He allocates label 1337 for Phillip and 420 for Josh. If he receives a packet with either label, he knows to who it needs to be handed.
- Steve tells this to You, so you write those numbers down. If someone wants you to send boxes to Phillip and Josh, you generate a number for both of them, 7331 and 24. You make note, that if someone gives you a packet with the number 7331, you replace (or swap) it with the number 1337. The same with 24 and 420. You also generate a number if someone wants to reach Steve, 1234.
- You learn about Mike and allocate the number 5678.
- You tell Alex about 7331 and 24 as well as 1234 and 5678.
Now Alex knows the following things:
- I want to reach Mike: Write 5678
- I want to reach Steve: Write 1234
- I want to reach Phillip: Write 7331
- I want to reach Josh: Write 24
The only thing different with this example and a real MPLS is, that you do not learn names but rather the IP-addresses of the routers.
One misconecption I want to clarify: those labels do not need to be unique. In fact, most of the times they are pretty similar. And that’s okay, because you only learn labels that mean something to your direct neighbor.
Functions inside the MPLS
We already learned about the LSR (Label Switching Router). If you want to talk about MPLS, you also need to learn about the Ingress LSR as well as the Egress LSR.
Ingress LSR
This router is the first router in the chain and the first one to encapsulate a packet with a SHIM header. He decided what the destination for this packet is and put’s the associated label on it.
Egress LSR
This router is the last router in the chain. But he is not always the one removing the SHIM header. In MPLS, there is a concept of Implicit and Explicit Null. This might sound complicated but it’s actually quite simple.
Suppose you are Steve and receive a box with label 1337. You know this box is destined to Phillip. But what do you replace this label with? Phillip didn’t tell you a label for himself. And he actually does not need to. You just hand the packet over to Phillip and he knows what to do with it – because it is his packet. So rather than swapping a label, you pop the label alltogether. To make this very clear for yourself, you assign the label 3 for Phillip, which actually means Pop the label (so you never write 3 on the label). This is called Implicit Null.
And what about Explicit Null? Suppose you receive a box with label 1337 and it says “Important Message” on the label. If you remove this label (pop it), then Phillip will never know this box was importan thus he might delay processing it. Sou you need a way to tell Phillip that this box is really really important. You swap the 1337 Label and write a special label on it: 0. It enables you to write “Important Message” right next to it and Phillip get’s to know this information. Although you do not need to tell Phillip this packet is for him, you still do so to be able for inform him about the importance of this packet. This is Explicit Null.
The note saying “Important Message” is handled via the Traffic Class Bits. You can create 8 different classes to prioritize different packets. Traffic Class 000 is know as Best Effort and the worst traffic Class. 111 however is known as Network Control and it is the most important Class.
Ressource reservation
You might think, that the Label Distribution Protocol might be a little bit ressource hungry in large networks. And you are absolutely right. It is the dumbest way to distribute labels. It is set up really quickly but it is not efficient.
For this reason, another Label Distribution Protocol got invented, it is called RSVP (or Ressource Reservation Protocol). The idea was to generate Label Switched Paths. These paths exactly tell the network, where a packet needs to be forwarded to and especially how it needs to be forwarded. It also gives us great mechanisms to reserve ressources along the way, making sure you always have enough bandwidth for your voice packets, for example.
The working principle of RSVP is a bit more complicated. First of all, you define a Label Switched Path by telling it your destination router and giving it a name. This is the simplest form to define one. Then, your router runs the so called CSPF (Constrained Shortest Path First) algorithm. This algorithms works more or less like OSPF, but is also capable to factor in specific routers you want to pass along the way and other information. If you only define your destination, however, it will most likely create the same path as OSPF would.
You then follow this path through your network and ask every routers on the way, whether there are enough ressources for this path. If no problems occur, you reach your destination router. Then, the real magic happens. The destination router sends the message back to you. However, each router on its way makes a note about who the previous router was, generates a label to reach this router and tells this information to the next router in the chain.
At the end, you have a list of all routers you traverse and each router in the path knows all the labels he needs to know for forwarding the packet.
If you want to get crazy, you can define some additional parameters in your RSVP LSP that impact the behavior:
- Explicit Route Object: You can define parts of the LSP that will be generated or even the complete LSP. CSPF will factor this information in its calculations and provide you with exactly what you need.
- Ressource Reservation: Suppose you want to create an LSP just for Voice Traffic and you want to always have 100 MBit/s free for this LSP. RSVP got you covered!
- Fast Reroute and Detour LSP: You want a highly available LSP? RSVP can create backup paths on its way which can cover a link or even a node failure, thus your impact is always reduced to the minimum.
How to make use of LSPs
Whether you create LSPs using RSVP or just use LDP, how does your Ingress LSR know it should use an LSP for Traffic? This is the real magic. With the invention of MPLS, we also got a load of different services that make use of it. You can create Ethernet Tunnels, which are instructed to use MPLS LSPs. You can create Virtual Routing and Forwarding (VRF) instances and make them use LSPs. You can create Broadcast or Multicast services, all of which can use LSPs. MPLS does not care what comes after the SHIM header, it just forwards packets in a really efficient way.
Why use MPLS in modern networks?
Modern networks are really capable. They do not care about the size of routing tables or hundreds or even thousands of labels. Reserving paths for bandwidth utilization is also a thing of the past in times of multi 100 GBit/s interfaces.
And although RSVP and LDP aren’t that common anymore and replaced by Segment Routing, MPLS still serves a very critical purpose in the creation of Software Defined Networks as it is flexible, fast and easy to implement.
If you enjoy a good read, I really recommend “MPLS in the SDN Era”. Although being several years old, this book still holds some valuable information about how MPLS can change our networking landscape.
Alright, we only touched the surface of MPLS and there is a lot more to come on here. But until then, I hope you had a great time and enjoyed the stay.