The basic understanding of MPLS starts with the concepts of MPLS header and some related information. Let us analyze what happens when a plain IP packet enters an MPLS enabled router. Before that, I would like to introduce some terms which are related to our discussion.
LSR: Label Switch Router is any router in the network which can process MPLS labels. Processing includes PUSH (add a new label to a frame), POP (remove a label from a frame), SWAP a label. An Edge LSR is a device which can process unlabelled packet, use Layer 3 lookup and assign a label.
FEC: Forwarding Equivalence Class is a set of packets which receive the same treatment in the forward direction. The treatment may be dependent on the destination IP address, source IP address, DSCP value etc.
LSP: Label Switched Path can be thought of as a virtual circuit from one end point (Edge LSR) to another end point (Edge LSR). A number of LSRs contribute to a full LSP. LSP is setup before the actual data flow.
Let us see what happens when a plain IP packet enters an MPLS enabled router. The router (Edge LSR) would analyze the packet and assign an FEC to the packet. Secondly the packet is assigned a label based on the FEC. So how does this change incoming frame? Following picture depicts the transformation which a Layer 2 frame undergoes.
It clearly shows that another label is inserted between Layer 3 datagram and Layer 3 Header. That is MPLS label. Sometimes, it is also called as Shim Header. Let us pay some more attention to MPLS label format. The total length of the MPLS header is 32 bits ( 4 bytes or octets ). The first 20 bits constitute a label, which can have 2^20 values. Next comes 3 bit value called Traffic Class. It was formerly called as experimental (EXP) field. Now it has been renamed to Traffic Class (TC). This field is used for QoS related functions. Ingress router can classify the packet according to some criterion and assign a 3 bit value to this filed. If an incoming packet is marked with some IP Precedence or DSCP value and the ingress router may use such a field to assign an FEC to the packet. Next bit is Stack bit which is called bottom-of-stack bit. This field is used when more than one label is assigned to a packet, as in the case of MPLS VPNs or MPLS TE. Next byte is MPLS TTL field which serves the same purpose as that of IP TTL byte in the IP header.
How does an MPLS enabled router distinguish between a labelled and unlabelled frame? To facilitate this, some more protocol types were defined above Layer 2. These protocols modify Layer 2 protocol’s protocol identifier. In case of Ethernet, Ethertype value is changed to 0x8847 or 0x8848. On a point to point link using PPP as layer 2 protocol, a new Network Control Protocol called MPLS Control Protocol (MPLSCP) was made. For MPLS packets, PPP protocol field value is changed to 0x8281. To better understand the changes happening in a Layer 2 frame, when it enters a MPLS router, let us consider a scenario as shown in the following diagram.
All the routers in the above diagram run OSPF as IGP with Loopback0 as router-id. All the interfaces are Ethernet Interfaces and are MPLS enabled. The relevant configuration is shown below:
Now let us see what happens when I ping the loopback interface of R1 from R4. Following diagram is the packet capture of such a ping request. The capture is taken from the segment R2 – R3 so that we can view the MPLS label.
You can clearly see the Modified Ethertype and MPLS label which is inserted in the ICMP packet. To make things easier, a frame without MPLS header is also shown below: