Understanding The MPLS Header

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.
MPLS Label Stack Header
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.
Understanding MPLS Header Topology
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:





!
hostname R1
!
interface Loopback0
ip address 192.168.1.1 255.255.255.255
!
interface Ethernet0/0
description Connection to R2
ip address 172.16.12.1 255.255.255.252
half-duplex
tag-switching ip
!
router ospf 100
router-id 192.168.1.1
log-adjacency-changes
network 172.16.12.0 0.0.0.3 area 0
network 192.168.1.1 0.0.0.0 area 0
!

!
hostname R2
!
interface Loopback0
ip address 192.168.2.1 255.255.255.255
!
interface Ethernet0/0
description Connection to R1
ip address 172.16.12.2 255.255.255.252
half-duplex
tag-switching ip
!
interface Ethernet0/1
description Connection to R3
ip address 172.16.23.1 255.255.255.252
half-duplex
tag-switching ip
!
router ospf 100
router-id 192.168.2.1
log-adjacency-changes
network 172.16.12.0 0.0.0.3 area 0
network 172.16.23.0 0.0.0.3 area 0
network 192.168.2.1 0.0.0.0 area 0
!

!
hostname R3
!
interface Loopback0
ip address 192.168.3.1 255.255.255.255
!
interface Ethernet0/0
description Connection to R2
ip address 172.16.23.2 255.255.255.252
half-duplex
tag-switching ip
!
interface Ethernet0/1
description Connection to R4
ip address 172.16.34.1 255.255.255.252
half-duplex
tag-switching ip
!
router ospf 100
router-id 192.168.3.1
log-adjacency-changes
network 172.16.23.0 0.0.0.3 area 0
network 172.16.34.0 0.0.0.3 area 0
network 192.168.3.1 0.0.0.0 area 0
!

!
hostname R4
!
interface Loopback0
ip address 192.168.4.1 255.255.255.255
!
interface Ethernet0/0
description Connection to R3
ip address 172.16.34.2 255.255.255.252
half-duplex
tag-switching ip
!
router ospf 100
router-id 192.168.4.1
log-adjacency-changes
network 172.16.34.0 0.0.0.3 area 0
network 192.168.4.1 0.0.0.0 area 0
!




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.


MPLS Label Header


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:




























Plain Layer 2 Frame

 Recommended Reading

  1. MPLS Fundamentals by Luc De Ghein

2 comments:

  1. How are the label tables defined. Are parameters set manually or do the routers analyse the network and define it

    ReplyDelete
  2. What happens with the TTL of layer 3 combined with MPLS TTL? which is the main or how they work together?

    ReplyDelete