Professional Documents
Culture Documents
1 MPLS: 1.1 IP Forwarding
1 MPLS: 1.1 IP Forwarding
1.1 IP Forwarding
The host forwards the IP packet to the router if the destination IP address
does not belong to its local prefix.
Once the packet reaches the router, based on the destination IP address, the
router tries to match it with the prefix (address range) available in the Datagram
forwarding Table. The packet is forwarded to the next hop as per the matching
0.0.0.0/0 captures all IP addresses and is also called the default route.
Thus if the destination is not in the local network prefix, it is sent to the
router
Fast switching makes the routing of packets more efficient by caching the next
hop information of packets to a specific destination, so subsequent packets don’t
have to go through the lookup process to determine what the next hop is going to be.
Once the FIB and adjacency tables are created, the routing table is not used
anymore to route packets. With FIB routers the routing table can be used for
packets that require more complex processing, however for plain packet forwarding
only the FIB and adjacency tables are used. The routing table becomes a source of
routing data to build the FIB and adjacency table contents but no longer used to
route packets. At this point the routing table is referred to as the Routing Information
Base (RIB) it is the master copy of routing information from which the FIB and other
tables are populated.
Other protocols have their own internal routing tables called RIBs but these
are separate from the routers routing table and should not be confused with the RIB
in a FIB router.
Multi-layer switches and high end router platforms go further and store the FIB
and adjacency in the Ternary Content Addressable Memory (TCAM) to perform even
faster lookups.
Label Switch Router (LSR) is a router that supports MPLS. LSRs can learn
MPLS labels and exchange MPLS-labeled packets with each other at the data link
layer. The LSRs can be classified into the following types:
Note One FEC can contain multiple data flows, but each flow does not
definitely belong to an independent FEC.
For example, when a host is scanning a web page of Sina, a data flow is generated.
When the host is scanning the video of Sina, another data flow is generated. When
the two flows are sent from Sina to a remote host, they are forwarded through the
same path.
Label Switched Path (LSP): Indicates the path through which a labelled
packet traverses an MPLS network and reaches the destination. An MPLS network
assigns and learns labels using a label distribution protocol to establish a label
forwarding path for traffic. The LSP is unidirectional.
o Label The label field is of 20 bits, hence the label could take
values from 0 to 2^20–1, or 1,048,575. However, the first 16 label values i.e.,
from 0 to 15 are exempted from normal use as they have a special meaning.
o Experimental (Exp) The three bits are reserved as experimental
bits. They are used for Quality of Service (QoS).
o Bottom of Stack (S) A network packet can have more than one
MPLS labels which are stacked one over another. To ensure which MPLS
label is at the bottom of the stack, we have a BOS field which is of 1 bit. The
bit is high i.e., value is 1, when that particular label is at the bottom of the
stack.
o Time to Live (TTL) The last eight bits are used for time to live.
Its value is decreased by one at each hop. The job is to avoid the packet from
getting stuck in the network by discarding the packet when its value becomes
zero.
One or more MPLS labels can be added to an IP data packet. For example,
as shown in the preceding figure, three labels are added to an IP data packet. Each
label header contains the fields described in the preceding table. Each label header
contains the BoS field to indicate whether the label is at the bottom of the label stack.
If the label is at the bottom of the label stack, the part after this label is the IP header.
In this case, the value of BoS in the label header is set to 1; otherwise, the value of
BoS is set to 0.
How does a router determine whether a received packet is a common IP
packet or a labeled packet? An MPLS label header is added between the second-
layer packet header and the third-layer packet header. In addition, the frame header
at the data link layer also indicates the packet type. For example, the TYPE field at
the MAC layer of an Ethernet data frame will indicate whether the upper-layer data is
an MPLS-labeled frame. For an IPv4 packet, the field value is 0x0800. For a
labeled packet, the field value is 8847 (unicast) or 8848 (multicast).
When receiving a labelled packet, an LSR processes only the first label
regardless of the number of labels in the label stack of the packet. The label stack is
placed before the third-layer packet header, that is, before the transmit protocol
header. In addition, the label stack is placed after the second-layer packet header.
Let's discuss MPLS from the perspectives of control and data planes.
o Control plane Layer 3 routing information (OSPF, IS-IS, and
BGP) and labels (TDP, LDP, BGP, and RSVP) are exchanged.
o Data plane Data is forwarded based on labels.
When an IP packet or a label data packet (that is, a data packet carrying an
MPLS label stack) is processed by a label switching router (LSR), the following
actions may be performed:
After receiving this packet, R2 extracts label 200 from the packet, searches
for this label in the label forwarding information base (LFIB) table, and finds that the
packet needs to be forwarded to R3. R2 then swaps the incoming label 200 for label
300 and forwards the packet to R3. After receiving this packet, R3 extracts label
300 from the packet, searches for the incoming label in the LFIB table, and finds that
the outgoing label value corresponding to this label is 3. (Label 3 is a special and
reserved label. When the outgoing label value is 3, the top label needs to be
removed from the packet.) Therefore, label 300 is popped out of the packet. R3
then forwards the original IP packet with no label.
In this example, R1 is an ingress label edge router (LER) that connects to an
IP network on the left and connects to an MPLS network on the right. Here comes a
question: how can R1 process a received IP packet. R1 searches for the packet's
destination IP address in the FIB table. If an entry matches the destination IP
address and the entry indicates that the next hop is an IP device rather than an LSR,
the packet is directly routed. If the entry indicates that the next hop is an LSR and a
label needs to be pushed into the packet, R1 pushes the label allocated by the next
hop into the packet and forwards the packet. In this case, the IP packet begins its
travel on the MPLS network. When a labelled packet is transmitted over an MPLS
network, all LSRs care only about the top label in the label stack. That is, the LSRs
search for the top label in the LFIB table and swap the label for the label allocated by
the next-hop LSR without considering the IP header in the packet. In addition, if a
labelled packet carries multiple label headers, all the LSRs process only the
top label in the label stack.
The basic feature of MPLS is that all packets are labelled. MPLS can help
construct a network that can understand and process labels. The network can
process data more efficiently and supports various types of services (such as VPN
and traffic engineering). A label must be added to an IP data packet before the
packet is forwarded to an MPLS network. In addition, when a labelled packet is
forwarded along the label switching path (LSP) on the MPLS network, the label
switching router (LSR) checks only the label value and performs corresponding
operations such as searching for and replacing the label. What label will the ingress
LSR add to an IP data packet? What is the LSP? How can we ensure that an IP
data packet can smoothly traverse an MPLS network? These problems are related
to the control plane, and must be solved using protocols. In addition, all the data
forwarding preparations should be made before an IP data packet reaches the
ingress LSR.
A protocol is required to help establish LSPs for the traffic, assign labels to the
FECs (traffic flows with specific route prefixes), and transfer or distribute label
mappings to other LSRs.
OSPF, EIGRP, RIP, and IS-IS cannot be used to distribute labels. Therefore,
a new protocol that is independent from all routing protocols and can be used
together with all routing protocols, is required. In addition, this protocol can bind
labels to specific FECs and distribute labels to other LSRs. LDP is such a protocol.
Each LSR that runs LDP binds labels to the route prefixes in its routing table,
and then distributes the LDP-assigned labels to all its LDP peers. The LDP peers
consider these received labels as the outgoing labels or remote labels, and save the
labels together with their local labels into a special table. Typically, an LDP-enabled
router has multiple LDP peers. These peers assign labels to the routes and
distribute the labels to the LDP-enabled router.
An LSR may receive labels distributed by multiple LDP peers for the same
FEC at the same time. The router uses only one label as the outgoing label of the
prefix. The LSR obtains the next hop of the IPv4 prefix through the routing
information base (RIB) table, and uses the label distributed by the next-hop LSR as
the final outgoing label.
1.8.2 Binding and Distributing Labels and Maintaining the LIB Table
After LDP is enabled, each router assigns labels to the route prefixes in its
routing table. For example, all routers in the preceding figure assign a label to the X
route. Currently, all routers run IGP, so that each router has learned the route to the
X network segment. The router then saves the label bound to the X route into the
local label forwarding base (LIB) table. All the LDP routers then distribute the labels
bound to the X route prefix to their LDP peers. As shown in the figure, device B
distributes the bound label to devices A, E, and C.
Split horizon for label distribution is disabled on Huawei devices by default.
That is, although device B may learn route X from device C, device B still transfers
the label bound to the prefix X to device C. Device C saves the label from device B
into its LIB table. There is no label forwarding loop risk because LDP can leverage
IGP to prevent loops.
When an LDP router receives a label from its label, it saves the label mapping
into its LIB table. The LIB table contains the In Label that is assigned to a specific
route prefix, and Out Label that is assigned by its peer to the route prefix.
1.8.3 Maintaining the LFIB Table
The LDP router saves all the peer-assigned labels into the LIB table, selects a
possible outgoing label from all the labels in the LIB table, and places the selected
label into the label forwarding information base (LFIB) table. Based on the LIB table
and routing table, the LDP router constructs an LFIB table.
Note that device E receives label mappings from its LDP peers device B and
device C. Some label mappings are related to route X. Here comes a question,
which LDP peer does the Out Label that is related to the prefix X and is saved in the
LFIB table of device B is assigned by? The answer is device C, because device C is
the next hop of the route from device E to network X. Device E uses the RIB table to
determine which label is optimal.
After all LDP routers distribute label mappings to each other, they gradually
construct their own LFIB tables, as shown in the preceding figure.
When the LFIB tables are constructed and device A receives an IP data
packet that is destined for a node on the X network. Device A checks its FIB table.
(If an IP packet is received, device A checks the FIB table. If an MPLS-labelled
packet is received, device A checks the LFIB table.) Device A finds that a label
needs to be added to the packet and the next hop is device B. It then adds label 201
to the packet and forwards the packet to device B.
After receiving the packet, device B finds that it is a labelled packet and the
label field in the label header is 201. B then searches its LFIB table, and finds that
the Out Label corresponding to In Label 201 is 301 and the next hop is device C.
Therefore, device B replaces label 201 with label 301 and forwards the packet to
device C. When device C searches the LFIB table, it finds that the Out Label
corresponding to label 301 is 3 and the next hop is device D. Label 3 is a reserved
label, which is called an implicit null label. If the Out Label value is 3, device C
needs to pop out the top label. The original IPv4 data then is obtained, and device C
forwards the data packet to device D. Finally, device D routes the data packet to the
destination node.