Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 19

1 MPLS

1.1 IP Forwarding

 Forwarding is the process of handling the packets when it arrives on the


determined route whereas routing is the determining of the route among very many
available paths so that the packets can be forwarded when it arrives.
 IP addresses on one network belong to the same prefix.
 Node uses a table that lists the next hop for IP prefixes (Range of continuous
IP addresses).

 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

prefix in the table.


 Prefixes in the table might overlap. In that case we need some protocol to
decide upon the next hop.
 Longest Matching Prefix is the forwarding rule which we apply
o For each packet, find the longest prefix that contains the destination
address, i.e., the most specific entry
o Forward the packet to the next hop router for that prefix.

1.1.1 Host forwarding Table

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

 Longest Matching prefix can have the following advantages


o Can provide default behaviour, with less specific prefixes as to send
traffic going outside an organisation to a border router.
o Can accommodate special cases with more specific prefixes for
performance, economics, security etc..

1.1.2 Step by step processes in packet forwarding (Process Switching)

IP Forwarding or IP routing is the function of a network device receiving an IP


packet, making a decision of where to send the packet next, and then forwarding the
packet. Here is the internal forwarding logic used when an IP packet is received:
o (1) Router receives a frame and checks the received FCS, if errors
are found the frame is discarded. The router does not try to recover the lost
packet.
o (2) If no errors are found, the router checks the Type field and
extracts the packet from the Frame. The Data Link header and trailer are
discarded.
o (3) Assuming an IPv4 packet, the header checksum is verified, if
the IP header checksum shows a mismatch the packet is discarded. IPv6
packets skip this step as IPv6 headers do not contain a checksum.
o (4) If the IP header checksum passed, the router checks the
destination IP address to see if it is one of the locally configured networks on
the router. If the packet destination matches an IP on the router the packet
has arrived at its destination. The router analyzes the protocol field in the IP
header, identifying the upper layer protocol and hands the packets data
payload over to the relevant upper protocol driver.
o (5) If the destination address DOES NOT match an IP configured
on the router, the packet must continue to be routed to its destination. The
router verifies if the TTL is greater than 1, if not the packet is dropped and an
ICMP Time Exceeded message is sent to the packet’s sender. (Source IP)
o (6) The router checks its IP routing table for the most specific prefix
match of the packets destination IP address.
o (7) A matched entry includes the outgoing interfaces and next hop
router, this information is used by the router to look up the next hop routers
layer 2 address in the appropriate mapping table such as ARP, IP/DLCI,
dialler maps, etc… This lookup is needed to build a new Data Link frame and
optionally dial the proper number.
o (8) Before creating a new frame, the router updates the IP header
TTL or Hop Count field require a re-computation of the IPv4 header
checksum.
o (9) The router encapsulates the IP packet in a new Data Link
header and trailer to create a new frame.

1.1.3 IP Forwarding: Fast Switching

 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.

 Fast switching accomplishes this by processing the first packet received to an


unknown destination with Process switching. When process switching the first
packet, this allows Fast switching to save the next hop information by caching the
next hop information in the CPU. Cache entries are timed out quickly to prevent the
CPU from being overloaded with cache information for multiple destinations.
Likewise the initial process switched lookup can also be cpu intensive if there are an
influx of packets destined for addresses not found in cache. At the time of its
inception Fast switching was an enormous improvement to the process switched
problem.

1.1.4 IP Forwarding: CEF

 Cisco Express Forwarding is the most efficient method of switching packets to


date, to understand how it works you must first understand the most crucial part of
routing a packet through a router is defining how to construct the layer 2 frame
header to allow the packet to be properly encapsulated toward its next hop, and then
forwarding that frame out the correct interface.
 This crucial part is referred to as the layer 2 frame rewrite. Something to
consider is that the routing table itself can hold thousands of prefix entries, but any
specific router will only ever have a handful of neighbours (next hop to any particular
destination). All destinations through a specific next hop will use the same layer 2
rewrite information and must be encapsulated with the same header before it’s
transmitted to that next hop to reach those destinations. CEF makes this layer 2
rewrite step more efficient by pre-constructing the layer 2 headers and saving them
to memory in an adjacency table.
 The adjacency table uses the routing table’s IP address and next hops as well
as the ARP tables Layer 3 to Layer 2 mapping tables to create and cache the layer 2
headers for each neighbour (adjacency)
 Once this is completed and packets are destined to those neighbours, the
router will simply use the pre-constructed next hop layer 2 frame to forward packets
to that next without needing to visit the ARP table or the Routing table to make a
forwarding decision.
 Something else to consider is that the routing table itself is not optimized for
rapid lookups. It contains important information needed to build the routing table
such as Administrative Distance, or route metrics, age, etc… Routing table entries
may require recursive lookups, once a destination network entry is matched in a
routing table, the next hop information might contain only the IP address of the next
hop but NOT the egress interface. So at that point the next hops IP address must be
looked up in the routing table, these recursive lookups can theoretically go on
forever. Even when it finds the final routing entry that contains an egress next hop
interface, the routing table doesn’t have any information needed to rewrite the layer 2
headers to forward the packet. This last hop address with an interface must have an
ARP entry for the egress interface to know how to rewrite the layer 2 frame header.
 CEF improves upon this lookup by storing the destination prefixes in a
separate data structure called the Forward Information Base (FIB). The FIB is
cached in router memory and contains pointers toward the appropriate
adjacency entry that contains the prepared layer 2 header and egress information
toward the next hop.

 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.

1.1 Generic Routing Encapsulation (GRE)

 Allow to have virtually point-to-point tunnel


 Is used when packets need to be sent from one network to another over
Internet or an insecure network.
 Tunnelling protocol developed by Cisco
 Support a wide variety of network layer protocols inside point-to-point links.
(multicast and IPv6)
 A GRE tunnel is not encrypted.
 GRE tunnels are much easier to configure.

1.2 MPLS definition

 Multiprotocol Label Switching (MPLS) is data forwarding technology that


increases the speed and controls the flow of network traffic. With MPLS, data is
directed through a path via labels instead of requiring complex lookups in a routing
table at every stop.
 Multiprotocol Label Switching (MPLS) enables Enterprises and Service
Providers to build next-generation intelligent networks that deliver a wide variety of
advanced, value-added services over a single infrastructure. This economical
solution can be integrated seamlessly over any existing infrastructure, such as IP,
Frame Relay, ATM, or Ethernet. Subscribers with differing access links can be
aggregated on an MPLS edge without changing their current environments, as
MPLS is independent of access technologies.
 When data enters a traditional IP network, it moves among network nodes
based on long network addresses. With this method, each router on which a data
packet lands must make its own decision, based on routing tables, about the
packet’s next stop on the network. MPLS, on the other hand, assigns a label to each
packet to send it along a predetermined path.
1.3 MPLS network environment

 The MPLS categorises the various routers in terms of Internet Service


Provider (ISP) and customer networks. Accordingly, we have
o Provider (P) routers are the routers maintained by ISP
o Provider Edge (PE) routers are those provider routers which are at the
edge of ISP network towards customer networks
o Customer Edge (CE) routers are those customer routers which are at
the edge of the customer network towards the ISP network.

 The provider routers are label switching routers (LSRs).


 The provider edge (PE) routers are where the MPLS labels are either
o Pushed
o Swapped
o Popped
 Labels are distributed using a protocol called Label Distribution Protocol
(LDP).
 The LSR pushes an MPLS header in between the layer2 and layer3 headers
and uses them to forward the packets using these labels.
1.3.1 Label Switch Router

 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:

o Ingress LSRs. As shown in the preceding figure, R1, R2, and R3


construct an MPLS domain. R1 and R3 are at the border of the MPLS
domain. R1 and R3 connect to the MPLS domain at one side and connect to
the IP network at the other side. When an IP data packet from the left IP
network reaches R1, R1 will forward the packet to the MPLS network. In this
case, R1 is called the ingress LSR that is responsible for adding MPLS labels
to received IP packets and forwarding the packets to the MPLS network.
o Intermediate LSRs. R2 is an intermediate LSR that does not
connect to any IP network, resides only on the MPLS network, and is
responsible only for labelled packet exchange.
o Egress LSRs. As shown in the preceding figure, when a data
packet is sent from the left IP network to the right IP network, R1 adds an
MPLS label to the packet and forwards the packet to R2. R2 then forwards the
packet to R3. R3 needs to forward the packet from the MPLS network to the
right IP network. Before doing so, R3 first removes the label stack from the
packet and then forwards the packet to the destination address 30.0. R3 is
called an egress LSR.
1.3.2 Forward Equivalence Class

 Forwarding Equivalence Class (FEC) is a data flow that is processed in the


same mode during forwarding. It can be identified by address, tunnel, or Class of
Service (CoS). Typically, a device assigns the same label to one FEC.
 The traffic of one FEC is forwarded in the same mode and through the same
path. However, not all packets with the same label belong to the same FEC. The
EXP values of the packets may be different. Therefore, they are processed in
different ways and belong to different FECs.
 Because the ingress LSR needs to classify packets and add labels to the
packets, it is responsible for determining the FEC to which packets belong.

Here come some FEC examples.

o Packets whose destination IP addresses match the same prefix.


o Multicast packets belonging to a specific multicast group.
o Packets processed in the same mode based on the process or the IP
DSCP field.

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.

1.3.3 Label Switched 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.

1.4 MPLS header

1.4.1 MPLS Header structure

 The MPLS header is of 32 bits. It contains the following information.

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.

1.4.2 Label Stack and Layer 2 Encapsulation

 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.

1.5 MPLS Architecture

 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.

 First, let's look at the control plane.

o An LSR runs a routing protocol, such as OSPF. The routing protocol is


used to exchange IP route prefixes between LSRs. An LSR uses such
information to construct its own routing information base (RIB) table and the
forwarding information base (FIB) table. The FIB table changes according to
the changes of the RIB table.
o The LSR then runs LDP. Two most important functions of LDP are to
assign labels to route prefixes and to transfer labels assign to prefixes to
neighbour LSRs. LSRs use the label switching information to construct their
own label information base (LIB) tables. Combining the FIB tables, the LSRs
construct their own label forwarding information base (LFIB) tables. The
LSRs can search the LFIB tables for labelled packet forwarding.

 Let's then look at the data layer.


Since information on the control plane is ready, here comes data
forwarding. When receiving a labelled packet, an LSR searches the LFIB
table. When receiving an IP data packet, an LSR searches the FIB table. An
LSR-forwarded packet may be a common IP data packet or a labelled packet
in different situations.

1.6 Processing of MPLS 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:

o Push The LSR adds an MPLS label to an IP packet or to a


packet that already has a label stack.
o Swap After receiving a labelled packet, the LSR swaps the label
at the top of the label stack in the packet for the label allocated by the next
hop according to the label forwarding table.
o Pop The top label is removed from the label stack. The
packet then is forwarding depending on the remaining labels in the label
stack. Alternatively, if the packet carries no label after the top label is
removed, the packet is forwarded as an unlabelled packet.
Here comes an example:

As shown in the preceding figure, after receiving an IP packet destined for


30.0, R1 queries the forwarding information base (FIB) table and finds that the
packet needs to be forwarded to R2. R1 then pushes label 200 into the packet and
forwards it to R2.

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.

1.7 Label Distribution Protocol (LDP)

 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.

After LDP finishes its work, an LSP is established.

1.8 Multi Protocol Label Switching (MPLS)

1.8.1 Constructing an IP Routing Table


First, all routers run routing protocols such as OSPF and IS-IS, so that
network-wide routers can communicate with each other. After LDP is enabled on the
router interfaces, an LDP peer relationship is established between every two routers.

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.

You might also like