The Function of Labels in MPLS Networks
Multi-Protocol Label Switching (MPLS) converts your routed network to something closer to a switched network. Instead of forwarding packets on a hop-by-hop basis, paths are established for particular source-destination pairs. These predetermined paths are called label-switched paths (LSPs). The routers that make up a label-switched network are called label-switching routers (LSRs).
As packets are forwarded in a label-switching framework, MPLS routers encapsulate the packets with special headers called labels. A label basically tells the router which LSP it belongs to. The router can then use the ingress port and the LSP information to determine where the next hop in the LSP is.
The MPLS packet arrives via port 1. The router examines the label and sees that it has a numeric identifier that associates the packet with a particular LSP. Based on the input port and the label value, the router can look up in its MPLS routing table where the next hop in the LSP is.
In this case, the lookup reveals that the outbound port is port 4. The packet forwards the traffic out the correct port, and the process repeats at the next LSR.
An LSR’s responsibilities extend beyond just looking at the label and forwarding the packet to wherever it needs to go. LSRs are also responsible for managing and assigning the label on the packet.
For example, when the packet arrives at the ingress router for a particular LSP, that ingress router is responsible for examining the packet so that it can send the packet through the LSP. However, it must also add the MPLS label so that the next hop in the LSP can process the packet correctly.
The act of adding an MPLS label is called pushing. The following three label operations form the basis of all MPLS forwarding:
Push: Adds a new MPLS label to a packet. When a normal IP packet enters an LSP, the new label is the first label on the packet.
Pop: Removes the MPLS label from a packet. This is typically done at either the penultimate or the egress router.
Swap: Replaces the label with a new label. When an LSR performs an MPLS lookup, that lookup yields the LSP next hop information as well as the numeric identifier for the next segment in the LSP.
Two other label operations — multiple push and swap and push — are really just extensions of the first three operations. Because you’re unlikely to need these operations, they aren’t described in detail here. Suffice it to say that they perform multiple operations at once.