So let’s have a look at MPLS labels, LSPs, and FECs. So what is one MPLS label?
One MPLS label is basically a field of 32 bit. The first 20 bits are reserved for the label value itself. So 20 bits means we have a value which is in a range of zero to one million and a little bit. But that’s a lot of labels that we can have. Then the next three bits are the experimental bits but they have been renamed more recently to traffic class bits. These bits are solely used for quality of service. Then we have the bottom-of-stack bit, it’s just one bit. If this bit is set, it means that this label is at the bottom of the stack. So basically you will have a stack of labels, it could be one label,
We have more than one label, they’re just stacked on top of each other, and only the bottom label has the bottom-of-stack bit set to one to indicate that whatever follows is the payload. The payload could be an IPv4, IPv6 packet, or a Layer 2 frame. Note that there is not protocol identifier, no protocol field in here, so basically by just looking for example at a Wireshark capture, it’s not possible to figure out what the payload would be if you would look at a protocol field because there is no protocol field in the label stack.
There is, however, inside the Layer 2 header, an MPLS protocol identifier. This is typically a field what identified the protocol that follows the Layer 2 header. Usually, it’s the IP protocol field and so on. But here we’re not carrying an IP packet anymore, we are carrying an MPLS packet. So for the different encapsulation types like PPP, Ethernet, HDLC, Frame Relay and so on, we now have an ethertype value or a protocol identifier which indicates that the protocol following the Layer 2 header is actually MPLS. So the ethertype or protocol identifier typically is 8847, indicating that we are carrying an MPLS packet. So we’ll have an MPLS label stack, and behind the MPLS label stack is then the transported protocol which could be IPv4, IPv6, or a Layer 2 frame.
Let’s have a look at an LSR or label switch router. When a packet comes in unlabeled it’s an IP packet, it might be switched out, out of the router, as a labeled packet, so it has one or more labels. We call that an ingress LSR or an imposition LSR. On the other hand, the packet can come in through the LSR already labeled and be switched out as an IP packet so there are no more labels. We call that an egress LSR or a disposition LSR. Finally, we can have intermediate LSRs. Typically these are the LSRs that receives a packet which is labeled and they forward out to the packet also a label, so they will just do a label swap of the top label. A label switched path is really an ordered list of routers.
So a label switched path is a path through the network from one LSR to the other one. Those LSRs are forwarding the packets labeled. Now we can have one LSP end to end through the MPLS network or we can have back-to-back LSPs. It is possible that the router in the middle here connecting the two LSPs actually does an IP lookup as well. Another possibility is nested LSPs. That means that we might have one LSP inside another LSP. The packets will be forwarded as labeled packets end to end, but here for the nested LSPs, the packets will receive an additional label in the label stack. That additional label identifies the nested LSP.
What is a FEC? Well, a FEC is a forwarding equivalence class. It’s basically a group or flow of packets that are forwarded along the same way, the same path, through the MPLS network. All those packets are also treated the same way when they are forwarded. Typically when you look at a FEC, all those packets, they will have the same label because they need to be forwarded along the same path. But it could be more than just the same label. Since they need to be treated in the forwarding path, in the same way, it also means that those packets, they will have the same quality of service. So all those packets that follow the same FEC, they will also have the same experimental bit value in the top label, that’s basically what a FEC is. All those packets belong to the same group or flow of packets, and they are forwarded along the same path and the forwarding treatment is the same.
What are some examples of a FEC? Well, a FEC would just be all packets forwarded towards the same Layer 3 destination IP address, so the same prefix. So all the packets that are forwarded after an IP lookup in the routing table will receive the same FEC, they will receive the same label. Another example of a FEC is a multicast group. So basically all the packets which are multicast packets forwarded for a certain multicast group. But it could also be a group of packets forwarded towards the same destination and also having the same DiffServe Code or quality of service field. The fourth example is, it could be that a FEC is also all the Layer 2 frames forwarded in the same way through the MPLS network. Finally, it could be that a FEC are all the packets not necessarily the same destination but all the packets forwarded towards the same BGP next hop. This means that we could have a bunch of prefixes that all share the same BGP next hop IP address in the routing table. Well, all those packets will be forwarded according to the same FEC, the same way, through the MPLS network.