MPLS Study Notes [Part 1]

** This topic is intended to be a refresher for all of us when we need a quick review for MPLS **

Recommended Readings MPLS Summary

## Acronyms For MPLS ##

1. LSR [Label Switch Router]: router that support MPLS
2. Ingress LSR: first hop PE, takes an IP packet and imposes a new label and forwards the packet.
3. Intermediate LSR: P router that SWAPS MPLS labels and forwards to next LSR
4. Egress LSR: last hop PE, POPS labels and forwards IP packet
5. LSP [Label Switched Path]: its unidirectional data plane for a labeled packet through the LSRs
6. Downstream/Data plane: the transit path to the network you are trying to reach.
7. Upstream/Control plane: it begins at the network that is being advertised, LDP is used to advertise labels.

## Overview ##
Quoted from MPLS Summary

1. MPLS stands for Multi-Protocol Label switching.
2. It defines a mechanism for the packet forwarding in the network routers.
3.It was originally developed to provide faster packet forwarding than traditional IP routing.
4. The flexibility of MPLS has led to it becoming the default way for modern networks to achieve Quality of Service (QoS), next generation VPN services, and optical signaling.
5. MPLS also uses IP addresses, either v4 or v6, to identify end points and intermediate switches and routers. This makes MPLS networks IP-compatible and easily integrated with traditional IP networks. However, unlike traditional IP, MPLS flows are connection-oriented and packets are routed along pre-configured Label Switched Paths (LSPs).
6. MPLS defines only the forwarding mechanism; it uses other protocols to establish the LSPs. Two separate protocols are needed to perform this task: a routing protocol (ISIS, OSPF) and a signaling protocol (LDP, TDP).

## MPLS Basics ##

1. Forwarding packets:
1.1. IP routers forward packets based on IP packet header, CEF and FIB table
1.2. MPLS routers forward packets based on MPLS labels and LFIB table

2. IP packet Switching
2.1. Process switching: look up every packet to decide a forwarding
2.2. Cache based switching: first packet is process witched and the info is cached for future packets in the flow.
2.3.Topology based switching (CEF): CEF uses the FIB and Adjacency table for forwarding decisions even before the first packet arrives

3. MPLS Basics
3.1. each router assigns a locally significant label for each IP route and advertise them to its neighbors
3.2. LDP is used to exchange labels
3.3. uses IP routing info to determine the direction of the next hop to forward a labeled packet

4. MPLS Forwarding
4.1. PE routers do IP lookup, if an LDP neighbor advertised a label for that IP network, the PE will PUSH the advertised label and forward the packet to the downstream neighbor
4.2. P routers swaps the local label and forward the packets to the downstream neighbor
4.3. Egress PE will POP remaining labels and forward the packet as an IP packet
4.4. MPLS enabled routers will prefer label forwarding over IP forwarding if available
4.5. If and LSR receives a labeled packet and it has no local label for labeled packet, the LSR will drop the packet.

## Control/Data Plane ##

1. IP Control Plane: Routing Protocols – RIB
2. MPLS Control Plane:  LDP – LIB
3. IP Data Plane: FIB (CEF forwarding information base)
4. MPLS Data Plane: LFIB (MPLS label forwarding information base)

How It Works:

1. IP routing protocols populate the RIB (control Plane)
2. RIB populates CEF and its FIB (data plane)
3. LDP populates the LIB (control plane)
4. LDP and RIB populate the LFIB (data plane)

## Labels ##

– exist at layer 2.5 of the OSI layer
– every IP route is assigned a locally significant label
– LDP is used to exchange labels between LDP neighbors
– FEC [Forwarding Equivalence Class]: packets that are destined to the same destination going through the same path

1. Label Details
1.1. Label size and specification
1.1.1. labels are 4-byte/32-bits long
1.1.2. 20-bits for the actual label
1.1.3. 3-bits for EXP
1.1.4. 1-bit for bottom-of-stack bit – identifies that this label is the last label
1.1.5. 8-bits for TTL

2. Implicit Null (label 3): the LDP neighbor advertising this label claims that he is the owner of this route.

3. Penultimate Hop Pop (PHP): whenever forwarding a packet with an implicit null label, you will have to POP the label out before forwarding it to the egress LSR, it saves the Egress LSR an extra LFIB lookup

4. Where is the labeled placed
4.1. In frame mode: between L2 and L3
4.2. In ATM mode: fields of the ATM header are used as the label

5. MPLS packet indication
5.1. L2 PID is changed in order to indicate that the packet is an MPLS packet
5.2. PID = 0x0800 – unlabeled IP unicast PID
5.3. PID = 0x8847 – labeled IP unicast PID
5.4. PID = 0x8848 – labeled IP multicast PID

6. Label stack is where you can assign more than one label to a packet and it is used for MPLS VPNs, TE, QoS and AToM

7. Label Distribution
7.1. Tag Distribution Protocol [TDP] legacy, it uses TCP:711
7.2. Label Distribution Protocol [LDP], it uses UDP/TCP:646, UDP for hello messages and TCP for the LDP session
7.3. Resource Reservation Protocol [RSVP], used for TE

8. How the labels build and work
8.1. IP routing protocols build the IP tables [RIB]
8.2. LSRs assigns local labels for each IP route they learn/posses
8.3. LSRs exchange labels via LDP
8.4. Labels from downstream LSRs are used as outgoing labels whenever forwarding to them
8.5. Then each LSR build and populate its own LIB,LFIB and FIB based on what they have learned from their LDP neighbor and remembers all the labels received through the advertisement
8.6. After an LSR locally assigns labels to all known routes it advertises them to all upstream and downstream LDP neighbors
8.7. LSRs calculate the best path based on IGP next hop and addresses that are owned by the LDP neighbor

9. LDP neighborship
1. Hello Messages
9.1. LSR send a multicast Hello message to 224.0.0.2 to UDP:646 every 5 seconds
9.2. Hello message includes the IP address to be used for peering, by default its the Router-ID (highest IP address of loopback/physical interface)
2. LDP Session
2.1. LDP session is TCP based on destination port 646
2.2. The router with the highest Router-ID will initiate the LDP TCP sessions
2.3. Keepalives are send periodically every 60 seconds

10. Label Space
10.1. System Wide Label Space:
10.1.1. To use the same label for the same network regardless the interface used
10.1.2. LDP neighbors with parallel connections use one of the paths
10.1.3. Default for Frame Mode
– LDP ID = A.B.C.D:0, where A.B.C.D is the IP address used for LDP neighborship and the :0 is the Label Space type (0 for System Wide)

10.2. Per Interface Label Space

11. Unsolicited Labels
11.1. LSRs that advertise their labels without being asked are downstream unsolicited label advertising

12. Liberal Label Retention
12.2. LSRs keeping track of all labels advertised both best and not best paths are called liberal label retention

## Loop Prevention – TTL ##

1. TTL is used as a loop prevention mechanism
2. If the IGP has loops, the MPLS TTL will run out eventually
3. Default TTL Mode: Initial MPLS TTL is copied from the original ingress IP packet TTL and the egress IP packet TTL is copied back from the MPLS TTL, by this the core routers are viewed by the customer through a trace route
4. No IP TTL Propagation Mode: MPLS wont copy the IP TTL and will use TTL=255, by this the core routers are hidden from the customer

## MPLS MTU ##

1. each MPLS label consumes 32-bits, you might need to adjust the MTU of your interfaces

## MPLS Configuration Steps ##

1. Requirements
1.1. CEF
1.2. IGP
1.3. Enable MPLS IP globally and on interfaces
1.4. Specify LDP/TDP (optional)
1.5. Specify LDP Router-ID (optional)
1.6. Specify transport IP address (optional)

2. Configurations Steps
2.1. check full IGP reachability between P/PEs
2.2. enable CEF
2.3. enable ‘mpls ip’ globally
2.4. enable ‘mpls ip’ on interfaces facing P/PEs (MPLS enabled neighbors only)
2.5. set the labels exchange protocol (LDP/TDP) ‘mpls label protocol ldp’
2.6. to limit the label advertisement to specific neighbors ‘mpls ldp advertise-labels [access-list, interface, vrf…]’

3. Verification Commands
3.1. show mpls interfaces
3.2. show mpls ldp neighbor
3.3. show control-plane host open-ports
3.4. show mpls ldp bindings
3.5. show mpls forwarding-table
3.5. show ip cef prefix/mask
3.6. show mpls ldp parameters
3.7. show mpls ldp discovery