Enhance your Career in Networking With IPinBits!!!​

MPLS LDP

This article will give you insights on what is ldp, how labels are dynamically assigned, why we use LDP, LDP neighborship, ldp label generation and allocation, LDP config. So let’s get started.

Label Distribution Protocol : LDP

  • As we know MPLS technology is based on labels push , pop and swap which we saw in the previous article. LDP is the protocol that generates the labels automatically for Routers to use MPLS. 
  • LDP is an open standard protocol similar to Cisco’s TDP, LDP is ported on UDP port 646, and uses multicast address 224.0.0.2 for Sending Hello Packets.
  • Like BGP, LDP also requires TCP as transport, if we have two links between A–B, only one LDP session will be formed unlike IGP.
  • As soon we enable LDP on router, for every destination in the Routing Table (RIB), label will be generated in local information base (LIB)
  • All routers will follow this and will generate labels in ad-hoc manner. 
  • Only the labels in the forwarding direction (Downstream routers) are sent, LDP takes help of IGP for best path.
  • Down Stream Routers: A next-hop router in forwarding path , Upstream Router : An adjacent router which is not a next-hop router. Example from below Topology for R-2 , R-3 is forwarding path router for reaching R-5-PE2 so its will be downstream router , while R1-PE1 is just an adjacent peer and not next hop for 5.5.5.5, so its will be termed as upstream Router.
  • After the labels are exchanged, depending upon the best path provided by IGP labels will be taken into consideration and best labels will be placed in the LFIB table.

Let’s Check in Lab, how it looks, once we enable LDP what goes in background, topology will be same throughout.

We are Running MPLS inside the ISP Domain , LDP is running between R-1PE1—–R-2—–R-3—-R-4——R5-PE2, for simplicity, we will check the LDP between R1-PE1 and R-2

On R-1-PE1, we will capture LDP packet, as you can see the LDP Hello packet, the highlighted part in packet capture are important things to remember.

Multicast UDP Hello’s sent to 224.0.0.2 for neighbor discovery, once the neighbor is discovered, it will try to establish TCP session to use as its transport ( Like BGP).

R-1-PE1#
R-1-PE1#show tcp brief | in 646
0EE343E0  1.1.1.1.646                2.2.2.2.65526               ESTAB
R-1-PE1#
R-1-PE1#

Each and Every router will have unique LSR ID its similar to RID in OSPF as seen above in the capture, R-1PE1 has 1.1.1.1 as the LSR ID. LDP is by default auto enabled on most of the vendors as soon we add the interface in mpls, we can turn this off as well. As soon we enable LDP on the router, it will automatically form LDP neighborship with peers running LDP as well of course. Lets verify few LDP commands and output to better understand:

To enable LDP, we just need to add the interface inside MPLS and LDP will be send UDP multicast Hellos on 224.0.0.2,  "mpls ip "at interface level that's it.

To check if LDP is running on the interface:

R-1-PE1#show mpls  interfaces 
Interface              IP            Tunnel   BGP Static Operational
GigabitEthernet0/0     Yes (ldp)     No       No  No     Yes        


R-2-P#show mpls interfaces 
Interface              IP            Tunnel   BGP Static Operational
GigabitEthernet0/0     Yes (ldp)     No       No  No     Yes        
GigabitEthernet0/2     Yes (ldp)     No       No  No     Yes    

To check LDP neighbors:

R-1-PE1#show mpls ldp neighbor 
    Peer LDP Ident: 2.2.2.2:0; Local LDP Ident 1.1.1.1:0
        TCP connection: 2.2.2.2.65526 - 1.1.1.1.646
        State: Oper; Msgs sent/rcvd: 36/36; Downstream
        Up time: 00:21:05
        LDP discovery sources:
          GigabitEthernet0/0, Src IP addr: 192.168.0.2
        Addresses bound to peer LDP Ident:
          2.2.2.2         192.168.1.1     192.168.0.2     
R-1-PE1#    
R-2-P#show mpls ldp  neighbor 
    Peer LDP Ident: 3.3.3.3:0; Local LDP Ident 2.2.2.2:0
        TCP connection: 3.3.3.3.13337 - 2.2.2.2.646
        State: Oper; Msgs sent/rcvd: 84/81; Downstream
        Up time: 00:59:00
        LDP discovery sources:
          GigabitEthernet0/2, Src IP addr: 192.168.1.2
        Addresses bound to peer LDP Ident:
          192.168.2.1     3.3.3.3         192.168.1.2     
    Peer LDP Ident: 1.1.1.1:0; Local LDP Ident 2.2.2.2:0
        TCP connection: 1.1.1.1.646 - 2.2.2.2.65526
        State: Oper; Msgs sent/rcvd: 36/36; Downstream
        Up time: 00:21:21
        LDP discovery sources:
          GigabitEthernet0/0, Src IP addr: 192.168.0.1
        Addresses bound to peer LDP Ident:
          1.1.1.1         192.168.0.1     
R-2-P#

labels are auto populated, but if you want to assign specific range for labels, we can manually configure.

Lets check this manual label assignment, verify the same with control plane for LDP:

LDP Manually Label assignment, RIB , LIB and LFIB info for LDP

As you can see below we have manually configured the label space for all the routers in MPLS domain.

R-1-PE1#show configuration | inc range
mpls label range 100 200

R-2-P#show configuration | inc range
mpls label range 200 300

Lets check the RIB, LIB and LFIB, 

RIB : 
R-1-PE1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        1.1.1.0/24 is directly connected, Loopback0
L        1.1.1.1/32 is directly connected, Loopback0
      2.0.0.0/32 is subnetted, 1 subnets
O        2.2.2.2 [110/2] via 192.168.0.2, 00:27:25, GigabitEthernet0/0
      3.0.0.0/32 is subnetted, 1 subnets
O        3.3.3.3 [110/3] via 192.168.0.2, 00:27:25, GigabitEthernet0/0
      4.0.0.0/32 is subnetted, 1 subnets
O        4.4.4.4 [110/4] via 192.168.0.2, 00:27:25, GigabitEthernet0/0
      5.0.0.0/32 is subnetted, 1 subnets
O        5.5.5.5 [110/5] via 192.168.0.2, 00:27:25, GigabitEthernet0/0
      192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.0.0/24 is directly connected, GigabitEthernet0/0
L        192.168.0.1/32 is directly connected, GigabitEthernet0/0
O     192.168.1.0/24 [110/2] via 192.168.0.2, 00:27:25, GigabitEthernet0/0
O     192.168.2.0/24 [110/3] via 192.168.0.2, 00:27:25, GigabitEthernet0/0
O     192.168.3.0/24 [110/4] via 192.168.0.2, 00:27:25, GigabitEthernet0/0
R-1-PE1#

LIB:

R-1-PE1#
R-1-PE1#show mpls ldp bindings
  lib entry: 1.1.1.0/24, rev 4
        local binding:  label: imp-null
  lib entry: 1.1.1.1/32, rev 50
        remote binding: lsr: 2.2.2.2:0, label: 205
  lib entry: 2.2.2.0/24, rev 49
        remote binding: lsr: 2.2.2.2:0, label: imp-null
  lib entry: 2.2.2.2/32, rev 42
        local binding:  label: 100
  lib entry: 3.3.3.3/32, rev 40
        local binding:  label: 101
        remote binding: lsr: 2.2.2.2:0, label: 202
  lib entry: 4.4.4.4/32, rev 38
        local binding:  label: 102
        remote binding: lsr: 2.2.2.2:0, label: 201
  lib entry: 5.5.5.5/32, rev 36
        local binding:  label: 103
        remote binding: lsr: 2.2.2.2:0, label: 200
  lib entry: 192.168.0.0/24, rev 34
        local binding:  label: imp-null
        remote binding: lsr: 2.2.2.2:0, label: imp-null
  lib entry: 192.168.1.0/24, rev 48
        local binding:  label: 104
        remote binding: lsr: 2.2.2.2:0, label: imp-null
  lib entry: 192.168.2.0/24, rev 46
        local binding:  label: 105
        remote binding: lsr: 2.2.2.2:0, label: 204
  lib entry: 192.168.3.0/24, rev 44
        local binding:  label: 106
        remote binding: lsr: 2.2.2.2:0, label: 203
R-1-PE1#

LFIB:

R-1-PE1#show mpls forwarding-table 
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop    
Label      Label      or Tunnel Id     Switched      interface              
100        No Label   2.2.2.2/32       0             Gi0/0      192.168.0.2 
101        202        3.3.3.3/32       0             Gi0/0      192.168.0.2 
102        201        4.4.4.4/32       0             Gi0/0      192.168.0.2 
103        200        5.5.5.5/32       0             Gi0/0      192.168.0.2 
104        Pop Label  192.168.1.0/24   0             Gi0/0      192.168.0.2 
105        204        192.168.2.0/24   0             Gi0/0      192.168.0.2 
106        203        192.168.3.0/24   0             Gi0/0      192.168.0.2 
107        No Label   11.11.11.0/24[V] 0             Gi0/1      10.0.0.2    
108        No Label   100.100.100.0/24[V]   \
                                       0             Gi0/1      10.0.0.2    
R-1-PE1#

And if you want to verify the labels assigned are working as expected we can do a traceroute :

R-1-PE1#traceroute 5.5.5.5   
Type escape sequence to abort.
Tracing the route to 5.5.5.5
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.0.2 [MPLS: Label 200 Exp 0] 37 msec 41 msec 52 msec
  2 192.168.1.2 [MPLS: Label 302 Exp 0] 25 msec 65 msec 38 msec
  3 192.168.2.2 [MPLS: Label 403 Exp 0] 18 msec 26 msec 32 msec
  4 192.168.3.2 22 msec 20 msec 22 msec
R-1-PE1#

Just remember for every prefix in routing table a label will be created in label table (LIB), and the best label depending upon the IGP path will be added in LFIB table for forwarding mpls packets.

LDP LSP Tunnel / PATH :

This is just nothing but the path that IGP (OSPF/ ISIS) provides as the best path for destination, in LDP we say it forms a tunnel and that Tunnel is coined as LDP LSP or LDP tunnel.

This is just basic overview on LDP, we have many more upcoming articles on MPLS Stay Tuned. !!!!!

Related blog posts