How packets are forwarded through an MPLS domain
In an MPLS domain, packets are forwarded from one MPLS-enabled router to another along a predetermined path, called an LSP.
An MPLS domain consists of a group of MPLS-enabled routers, called Label Switching Routers (LSRs). LSPs are one-way paths between MPLS-enabled routers on a network. To provide two-way traffic, you must configure LSPs in each direction.
The LSRs at the head end and tail end of an LSP are known as Label Edge Routers (LERs). The LER at the head end, where packets enter the LSP, is known as the ingress LER . The LER at the tail end, where packets exit the LSP, is known as the egress LER. Each LSP has one ingress LER and one egress LER. Packets in an LSP flow in one direction: from the ingress LER toward the egress LER. Between the ingress and egress LERs, there may be zero or more transit LSRs. A device that is enabled for MPLS can perform the role of an ingress LER, transit LSR, or egress LER in an LSP. Furthermore, a device can serve simultaneously as an ingress LER for one LSP, transit LSR for another LSP, and an egress LER for some other LSP.
The figure titled "Label switching in an MPLS domain" depicts an MPLS domain with a single LSP consisting of three LSRs: an ingress LER, a transit LSR, and an egress LER.
Label switching in an MPLS domain works as described below.
- The Ingress LER receives a packet and pushes a label onto it.
When a packet arrives on an MPLS-enabled interface, the device determines to which LSP (if any) the packet is assigned. Specifically, the device determines to which Forwarding Equivalence Class (FEC) the packet belongs. An FEC is simply a group of packets that are all forwarded in the same way, typically represented by a prefix in the routing table. FECs are mapped to LSPs. When a packet belongs to an FEC and an LSP is mapped to that FEC, the packet is assigned to the LSP.
When a packet is assigned to an LSP, the device, acting as an ingress LER, applies (pushes) a tunnel label onto the packet. A label is a 32-bit, fixed-length identifier that is significant only to MPLS. Refer to the MPLS label header encoding information for specific information about the contents of a label. From this point until the packet reaches the egress LER at the end of the path, the packet is forwarded by using information in its label, not information in its IP header. The IP header of the packet is not examined again as long as the packet traverses the LSP.
On the ingress LER, the label is associated with an outbound interface. After receiving a label, the packet is forwarded over the outbound interface to the next router in the LSP.
- A transit LSR receives the labeled packet, swaps the label, and forwards the packet to the next LSR.
In an LSP, zero or more transit LSRs can exist between the ingress and egress LERs. A transit LSR swaps labels on an MPLS packet and forwards the packet to the next router in the LSP.
When a transit LSR receives an MPLS packet, it looks up the label in its MPLS label table. This table maps the label and inbound interface to a new label and outbound interface. The transit LSR replaces the old label with the new label and sends the packet out the outbound interface that is specified in the table. This process repeats at each transit LSR until the packet reaches the next-to-last LSR in the LSP (for signaled LSPs).
The following figure illustrates an example of the label-swapping process on a transit LSR.
In this example, a packet comes into interface 2/1 with label 123. The transit LSR then looks up this interface-label pair in its MPLS label table. The inbound interface-label pair maps to an outbound interface-label pair - in this example, interface 3/1 with label 456. The LSR swaps label 123 with label 456 and forwards the packet out interface 3/1.
- The egress LER receives the labeled packet, pops the label, and forwards the IP packet.
When the packet reaches the egress LER, the MPLS label is removed (this is called popping the label), and the packet can then be forwarded to its destination by using standard hop-by-hop routing protocols. On signaled LSPs, the label is popped at the penultimate (next to last) LSR, rather than the egress LER.