In the traditional IP forwarding, physical layer receives a packet from a port on the router, then sends to data link layer.
Data link layer removes link layer encapsulation, then sends to corresponding network layer according to protocol field of the packet.
The network layer will check whether the packet is sent to this device, if it is, it will remove network layer encapsulation, and send to its up-level protocol. If it is not, it will lookup routing table according to packet’s destination IP address, if the route is matched, the packet will be sent to data link layer of the corresponding port, after encapsulated by data link layer, it will be transmitted. If it is not matched, the packet will be discarded.
The traditional IP forwarding adopts hop-by-hop forwarding, each router that packet passed through should implement the process (as the figure shows, RTA receives a data packet whose destination IP address is 10.2.0.1, RTA will lookup routing table and forward according to matched route item, RTB, RTC, RTD will also do like this), So the efficiency is low. And all the routers need to know all routes in the entire network or default route.
Besides, the traditional IP forwarding is connectionless oriented, so it is hard to deploy Qos.
MPLS is a kind of label forwarding technology, it adopts connectionless control plane and connection oriented data plane, connectionless control plane implements routing transmission and label distribution, connection oriented data plane implements packet transmission along LSP (label switch path) established before.
In MPLS network domain, router does not need to analyze every packet’s destination IP address, just forwards by label that added before the IP header (as the figurer shows that RTB receives labeled packet from RTA, then forwards by label, RTC is similar). Comparing to traditional IP forwarding, MPLS label forwarding greatly improves forwarding efficiency.
However, with the development of ASIC technology, routing lookup speed is not bottleneck of network development any more. Improving forwarding speed is no longer the obvious advantage of MPLS.
MPLS integrates the advantage of the two forwarding technologies, powerful layer 3 routing function of IP network and high efficiency forwarding mechanism of traditional layer 2 network, its forwarding plane adopts connection oriented, it is very similar to layer 2 network forwarding method in existence.
It makes MPLS easy to implement seamless combination of IP and ATM, frame relay and other layer 2 network, and provide better solution for TE (Traffic Engineering), VPN (Virtual Private Network), QoS (Quality of Service) and other applications.
VPN based on MPLS can combine different embranchment of private network, form a uniform network, VPN based on MPLS also supports communication control between different VPN. As the figure shows, CE is user edge device; PE is service provider edge router, which is located in backbone network. P is backbone router in the service provider network, it does not directly connect with CE. VPN data is transmitted along LSP (label switch path) encapsulated with MPLS label.
MPLS TE integrates MPLS technology and TE, reserves resource via establishing LSP tunneling towards appointed path, makes traffic steer clear of congestion node, reaches the objective that balance network traffic.
As shown in the figure, 70% traffic from Network A to Network B is transmitted via the path of RTB-RTC-RTD, 30% traffic is transmitted via the path of RTB-RTG-RTHRTD. The traffic from Network B to Network C is similar.
The typical structure of MPLS network is shown in this slide: the router and ATM switch located inside of MPLS domain are called LSR, router and ATM switch located at the edge of MPLS domain that used to connect IP network or other kinds of network are called LER.
In IP network, it implements traditional IP forwarding; in MPLS domain, it implements label forwarding.
Both of LER and LSR have the ability of label forwarding, but they are located in different position, the packet processing is different. LER’s charge is to receive IP packet from IP network and insert label into the packet, then transmit it to LSR, whereas, its charge is also to receive labeled packet from LSR and remove label, transmit it to IP network; LSR’s charge is to forward according to the label.
The path that packet passes through in MPLS domain is called Label Switch Path (LSP), this path is already confirmed and established by kinds of protocols before packet forwarding, packet will be transmitted along the specified LSP.
MPLS network forwards packet according to the label. But how does label be generated? What mechanism does MPLS adopt to implement data forwarding?
MPLS includes two plane: control plane and data plane. Control plane’s charge is to generate and maintain routing information and
label information. Data plane’s charge is conventional IP packet forwarding and labeled packet forwarding. In control plane, routing protocol module is used to transmit routing information, generate routing table; label distribution protocol is used to complete exchange of label and establish label switch path. Data plane includes IP forwarding table and label forwarding table, when receiving conventional IP packets, if it is conventional IP forwarding, it should lookup routing table and forward, if it is label forwarding, it should forward by the label forwarding table; when receiving labeled packets, if it needs to forward by label, it should forward by label forwarding table, if it needs to transmit to IP network, it should remove label and forward by IP routing table.
MPLS labels are used to transmit MPLS information. Routers exchange labels to transmit data on the established label forwarding paths
The length of MPLS header is 32 bits, it includes 20-bit label field, this field is used for data forwarding; 3-bit EXP is used to carry precedence of IP packet; 1-bit S is at the bottom of stack and is used to indicate whether it is the last label (MPLS label can be multiple nesting); 8-bit TTL, its function is similar to TTL of IP header, it is used to prevent data from looping
The protocol filed PID in layer 2 header specifies that payload starts with packet with label encapsulated or IP header. For example, in Ethernet protocol, PID=0x8847 identifies that the frame payload is a multicast MPLS packet. PID=0x8848 identifies that the frame payload is a unicast MPLS packet. PID=0x0800 identifies that the frame payload is a unicast IP packet. In PPP protocol, PID=0x8281 identifies that the frame payload is a unicast MPLS packet. PID=0x8283 identifies that the frame payload is a multicast MPLS packet.
S bit in MPLS header indicates whether the next header is another label or a layer 3 IP header.
Usually MPLS only allocates one label for a packet. But some advanced applications of MPLS use multiple labels. For example, MPLS VPN will use 2 layers of labels (in complex situation, it even uses 3 layers of labels), out-label is used for public network forwarding, in-label is used to indicate that which VPN the packet belongs to; MPLS TE also uses two or more labels, the outmost label is used to indicate TE tunneling, in-label indicates the destination of packet.
Note: The Label1, Label2, Label3 all mean 4 Bytes MPLS header in last slide, it includes 20-bit label information.
FEC (Forwarding equivalence class) means a group of IP packets which are forwarded in the equipollence method, for example, a group of IP packets with same destination IP prefix will be allocated a unique label. In this case, the packet that destination IP prefix is 10.2.0.0/24 belongs to a FEC, the label allocated for this FEC is 1030.
NHLFE is used when forwarding a labeled packet, It contains the following information:
1. the packet's next hop;
2.the operation to perform on the packet's label stack (it contains pushing
new label, popping label, replacing the original label with new label). It may also contain other information, such as the data link encapsulation to use when transmitting the packet. In this case, next hop is 10.1.1.2, label operation is “push”.
FEC represents the same kind of packets, NHLFE contains next hop, label operation and other information. Only associating FEC with NHLFE, it can implement particular label forwarding for same kind of packets, FTN can implement this function, FTN (FEC-to-NHLFE) indicates the mapping for an FEC to NHLFE, if there are multiple cost-equal paths, one FEC maybe map to multiple NHLFE.
When a IP packet enters MPLS domain, ingress LER (RTA) will analyze packet, determine which label to encapsulate packet according to packet characteristic (generally by prefix analysis of destination IP address), and determine to transmit to which next hop from which interface.
On the ingress, the NHLFE table is queried to guide packet forwarding.
On the transit node LSR (RTB) receives message with MPLS label 1030 from RTA, and forwards it according to MPLS label. It will find the next hop 10.1.1.6, use outgoing label to swap incoming label, and then continue forwarding. (this case is special, outgoing label and incoming label are the same.)
ILM maps each incoming label to a set of NHLFE, It is used when forwarding packets that arrive as labeled packets. If there are multiple equal-cost paths, one incoming label maps to multiple NHLFE
Similar to RTB, when RTC receives message with label 1030, it forwards packet by label, and uses new outgoing label to swap original label.
In this case, RTC uses outgoing label 1032 to swap incoming label, then transmits packet from outgoing interface Serial3, the next hop is 10.1.1.10.
Egress LSR (RTD) receives message with label 1032, Pops the label, lookups IP routing table and forwards it.
In the case, RTD pops label 1032 and forwards the message to the next hop 10.2.0.2.