Why MPLS ?
The traditional IP forwarding adopts hop-by-hop forwarding. When a data packet passes through each router, it must be decapsulated to check the network layer information of the packet, and then look up the routing table to guide the packet forwarding according to the longest route matching principle. Each router repeats the process of decapsulating the routing table and re-encapsulating, so the forwarding performance is low.
Features of traditional IP routing and forwarding:
- All routers need to know the routes of the entire network.
- The length of the IP header is not fixed, and the processing efficiency is low.
- Traditional IP forwarding is connectionless and cannot provide better end-to-end QoS guarantee.
MPLS (Multiprotocol label switching)
MPLS originated from IPv4 (Internet Protocol version 4), and its core technology can be extended to a variety of network protocols, including IPv6 (Internet Protocol version 6), IPX (Internet Packet Exchange), Appletalk, DECnet, CLNP (Connectionless Network Protocol), etc. “Multiprotocol” in MPLS refers to supporting multiple network protocols.
MPLS replaces IP forwarding with label switching. A tag is a short, fixed-length identifier that has only local significance. By adding an extra MPLS header between the data link layer and the network layer, fast data forwarding is realized based on the MPLS header.
The figure above shows a simple forwarding process by MPLS. The edge router who runs both IP and MPLS add a MPLS Header on the origin IP packet and pass it to other MPLS routers. MPLS routers don’t need to look into IP header anymore to determine the forwarding path. Instead, the MPLS header points out the correct path.
Terminologies in MPLS
- MPLS Domain: A series of consecutive network devices running MPLS constitute an MPLS domain.
- LSR (Label Switching Router): A router that supports MPLS (actually it also refers to a switch or other network device that supports MPLS). The LSR located at the edge of the MPLS domain and connected to other networks is called the Label Edge Router (LER), and the LSR inside the area is called the Core LSR .
- Ingress LSR: LSR that pushes MPLS headers into IP packets and generates MPLS packets.
- Transit LSR: LSR that performs label replacement operations on MPLS packets and continues to forward the packets in the MPLS domain.
- Egress LSR: Routers who remove the MPLS header from the MPLS packet and restore it to the LSR of the IP packet.
- FEC (Forwarding Equivalence Class): A set of data flows with some commonality, and these data flows are processed in the same way by network nodes during the forwarding process.
- LSP (Label Switched Path): The path that label packets take to traverse the MPLS network to the destination.
MPLS forwarding process
Before an IP packet enters the MPLS domain, it will be pushed into the MPLS header (also called MPLS label) by the inbound LSR to form an MPLS label packet. A label packet can contain one or more MPLS labels.
When an IP packet enters the MPLS domain, the MPLS border device inserts a new label between the Layer 2 header and the IP header of the packet; MPLS intermediate devices can also add a new label to the top of the label stack as required.
When the packet is forwarded in the MPLS domain, the top-of-stack label of the MPLS packet is replaced with the label assigned by the next hop according to the label forwarding table.
When the packet leaves the MPLS domain, the label of the MPLS packet is removed.
When LSR processes packets, it mainly bases on FTN, NHLFE, and ILM.
- FTN (FEC-to-NHLFE): It is used when the LSR receives IP packets and needs to forward MPLS packets. FTN only exists in the Ingress. FEC includes: Tunnel ID, mapping information from FEC to NHLFE.
- NHLFE (Next Hop Label Forwarding Entry): LSR is used when MPLS forwarding packets (MPLS or IP packets), NHLFE exists in Ingress and Transit. NHLFE includes information such as Tunnel ID, outgoing interface, next hop, outgoing label, and label operation type.
- ILM (Incoming Label Map): It is used to guide the forwarding of MPLS packets (MPLS or IP forwarding). ILM only exists in Transit and Egress. ILM includes information such as Tunnel ID, incoming label, incoming interface, and label operation type.
When IP packets enter the MPLS domain:
- The Ingress LSR checks the FIB table to check whether the Tunnel ID value corresponding to the destination IP address is 0x0 (if the Tunnel ID value is 0x0, it enters the normal IP forwarding process).
- If the Tunnel ID value is not 0x0, find the corresponding NHLFE entry according to the Tunnel ID in the FIB table, and associate the FIB entry with the NHLFE entry.
- View the NHLFE entry to obtain the outgoing interface, next hop, outgoing label, and label operation type.
- The IP packet is pressed into and out of the label, and the TTL is processed at the same time, and then the encapsulated MPLS packet is sent to the next hop.
When MPLS packets are forwarding in the MPLS domain:
- Transit LSR checks the corresponding ILM table according to the MPLS label value, and obtains the Tunnel ID.
- Find the corresponding NHLFE entry according to the Tunnel ID in the ILM table.
- Check the NHLFE entry to obtain the outgoing interface, next hop, outgoing label, and label operation type. If the label operation type is Swap, the label is exchanged.
When MPLS packets need to leave the MPLS domain:
- According to the ILM query, Egress finds that the operation corresponding to the label is Pop, indicating that the label needs to be stripped.
- The next step is processed according to the next-layer packet header of the current label header