A Closer Look At Forward Equivalence Class (FEC)

Before I start anything on this topic, I would highly recommend you to read an excellent article by Jeff Doyle in NetworkWorld on the same subject. In conventional IP forwarding, two packets are said to be in be in same FEC if the Layer 3 longest prefix match lookup returns the same next hop. The case is different when some kind of load sharing exists, but Cisco routers by default uses per-destination (source/destination pair) based load sharing. So a stream of packets will have the same next hop and can be said to be in same FEC. What happens next? When the packet reaches the next hop router, it also does the same thing – does a Layer 3 Lookup, find the next hop and then send the packet to that router till it reaches its destination.

How does the above given process differ when you use MPLS? When you use MPLS, FEC assignment and next hop determination are done only once – at the ingress router. Once a label has been assigned to a router, the subsequent routers will not do a Layer 3 lookup and it will just ‘switch’ the packet from one interface to another. This is one of the advantages of using MPLS.
Advantages of MPLS FEC
  1. MPLS forwarding in the core can be done by switches capable of label lookup and swapping.
  2. Since FEC is assigned at the ingress point, it may use parameters other than that are present in the IP Header to select an FEC. Eg: Packets arriving on a particular interface may be assigned a different FEC.
  3. A packet entering one ingress point may be given a different treatment than the same packet entering another router. ISPs can use this feature so that they can terminate their premium customers on a different router or a switch. This combined with #2 can serve as a good method of classifying customers accordingly.
  4. Explicit paths for a particular FEC can be specified. This is simpler, compared to traditional methods where routing protocol determines the next hop and path. Any change if needed, will be CPU intensive and requires alteration of many parameters. In MPLS, this can be done using a Label.
FEC And Labels in Action
Let us consider the same topology which we considered in the last post also.  It is shown below:
A Closer Look At FEC
So I am going to ping the loopback interface and WAN IP of R4 from R1. So here it is:
Ping and Labels
 The diagram also shows the labels assigned with the destinations which we are pinging. So if I want to ping a destination it uses the label 19, while label 16 is used for a destination What this essentially means is that both the packets are assigned to different FECs although they are going to same router. The FEC and next hop is determined here. Let us see how the Layer 2 frame is organized for the both cases:
Packet to
Ping R4 Loopback
Packet to
Ping R4 WAN
You can see the corresponding labels assigned and stack bit is also set, since this is the only label.
Now let us see what happens at R2, when this packet arrives:
R2 Label Bindings
Packet to
Ping R4 WAN - Packet at R2
Packet to
Ping R4 Loopback - Packet at R2 out

R2 removes the label on packet when it is destined towards /30 network. This is very evident from the implicit null shown for that network in the above figure. For a packet destined towards, the label would be swapped and the new label would be 19 if the when the next LSR in question is R3. And there not much happening in R2 to forward this packet to next LSR. It just does a label swap and switching which is very evident from the next screenshot.
MPLS Processing at R2
 This was a topic which I needed to pay more attention when I studied MPLS. When I use debug ip packet command, it shows no output in R2. Even when MPLS is not used, debug ip packet does not display any output. Otherwise, we could see what is happening inside the router.

 Recommended Reading

  1. MPLS Fundamentals by Luc De Ghein