Label Distribution Protocol
LDP
With LDP, LSPs are created automatically when we enable LDP on an interface.
Two routers form an LDP session (UDP/TCP port 646) and automatically exchange labels for each others loopback interfaces.
Junos devices advertise labels for the primary loopback IP as well as anything else learned by LDP.
Junos inet.3
table is populated with a full mesh of LSPs to every other LDP router.
LDP always follows the best path (based on the OSPF/IS-IS metric).
LDP uses penultimate hop popping (label 3
).
No traffic engineering (BW reservation, primary/secondary paths, admin groups) with LDP.
Forwarding Equivalence Class (FEC)
A set of traffic forwarded in the same way (using same LSP).
In the Label Mapping Message
of LDP, we can see the FEC object
and Generic Label Object
.
- Type: IPv4 Prefix FEC
- Prefix: 10.20.30.1/32 (Loopback IP)
- Generic Label (MPLS label for the FEC)
Both RSVP and LDP perform downstream label allocation, but the difference is that in RSVP it is downstream on demand
whereas in LDP it is downstream unsolicited
.
Egress router advertises a FEC for itself, without anyone asking for.
LDP Labels are advertised to all neighbors, including the neighbor that advertised it first, but it does not cause loops, because LDP always follows the best path.
Ordered Control vs Independent Control
Junos devices implement ordered control, means it only advertises a FEC when it has received a label downstream (ordered control).
With independent control, router generates labels even when it hasn’t received any. Also, a FEC is generated for every single prefix in IS-IS/OSPF. FECs are generated when that router itself does not have a FEC.
Independent control speeds up LSP creation but increases label usage and there is a danger that traffic will be dropped when LDP has not yet been established.
Label Retention Methods
- Liberal: routers keep all labels they receive; Speeds failure recovery.
- Conservative: routers keep only the best labels; saves memory but slows down recovery.
Juniper devices support only liberal label retention method.
Multipoint-to-point LSPs
RSVP LSPs are point to point where as LDP LSPs are like a tree routed at the egress device. In LDP, configuration at the tail-end triggers this egress device to advertise a FEC to its peers, who then advertise the FEC to their own peers and so on.
LDP Configuration in Junos
- Enable MPLS on core interfaces, in both control plane (
edit protocols mpls
) and data plane (family mpls
on interfaces) - Add core interfaces under
edit protocols ldp
- Loopback interface is not mandatory
- If control plane protection is in place, allow port
646
on bothtcp
andudp
LDP Basic Discovery Mechanism (directly connected)
LDP Hello Message
With this configuration, neigbors are discovered using hello
messages sent every 5
seconds to the all routers multicast address 224.0.0.2
.
Loopback IP address is advertised in the hello
message, as IPv4 Transport Address
.
When two neighbors discover each other, they establish a TCP session with each other using the loopback IP addresses.
LDP Header
- LDP Version: always
1
- Label Space Router ID: router’s loopback IP address
- Label Space ID: always
0
(means any label can be used)
LDP Initialization Message
After creating a TCP session to each other’s loopback IP, they send an initialization message which contains the common session parameters TLVs.
-
Lables: Downstream Unsolicited
-
Keepalive Time: 30s
-
Neighbor’s Label Space : X.X.X.X:Y (Label Space Router ID: Label Space ID, usually
0
)
As seen above, when a router sends this message, it includes it neighbor’s label space to confirm that it has understood the router’s label requirements.
If the initialization message succeeds in both directions, then they are ready to start exchanging FECs.
LDP Label Mapping Message
FECs are advertised in a series of Label Mapping messages. Each of these messages contain,
- FEC Type: IPv4 Prefix FEC
- Prefix: Loopback IP
- Generic Label : MPLS label
Multiple Label mapping messages can be sent in one LDP packet. Every label mapping message contains one IPv4 FEC and one MPLS label corresponding to that FEC.
Verifying LDP in Junos
To verify which interfaces are running LDP
root@juniper> show ldp interface
This command verifies accepted UDP hello messages. Each neigbor is listed by its physical IP.
root@juniper> show ldp neighbor
To verify successful TCP initialization messages
root@juniper> show ldp session
Operational
state and open
connection shows successful LDP session.
To verify received and advertised FECs. This database is split into two parts: Input label database
and Output label database
.
root@juniper> show ldp database
In inet.3
table, w see a full mesh of LSPs, automatically created. Each loopback IP is learned via [LDP/9]
root@juniper> show route table inet.3
In the routing table, we dont see the names of LSPs (unlike RSVP), instead we see a label value with Push operation.
If there are multiple links between two routers, there will be a neighborship on each physical interface but only one TCP session between them.
To verify outgoing traffic to all known FECs
root@juniper> show ldp traffic-statistics
This shows two lines, one for transit
and other for ingress
statistics.
To generate new outgoing lables,
root@juniper> clear ldp session
To reset everything related to LDP
root@juniper> clear ldp neighbor
LDP-IGP Synchronization
LDP LSPs always follow the best path suggested by IGPs so if LDP is not enabled on some intermediate devices or if LDP is not established yet, LDP will not find an alternative path. If there is no LDP on the best path, MPLS packets will be dropped. This is called LDP Traffic Blackholing.
We can not change the way how LDP works but we can change the IGP link matrix while LDP is down using the ldp-synchronization
command. This advertises a high value until LDP is operational. Once LDP is up for 10 seconds, metric changes back to actual values.
- IS-IS:
[edit] root@juniper# set protocols isis interface <interface-name> ldp-synchronization
- OSPF:
[edit] root@juniper# set protocols ospf area <area-id> interface <interface-name> ldp-synchronization
LDP LSP Metrics
By default, Junos gives all LDP LSPs a metric of 1
(in the inet.3
routing table). This is used only for BGP path selection process and has nothing to do with the hop-by-hop forwarding decision that each router takes.
There is an advantage with this default LDP metric behaviour, that is with LDP, we can load balance between unequal cost paths.
BGP multipath
can use both LDP paths for load balancing.
If we are not using multipath
, we can configure track-igp-metric
command to change the default behaviour. With this, LDP LSPs use the true IGP metric.
[edit]
root@juniper# set protocols ldp track-igp-metric
Session Protection
When all LDP neighborships to a router go down, the LDP session also goes down. All labels from the session are discarded. When LDP comes back up, labels must be re-advertised.
We can make use session-protection
to create an always up multihop LDP neighborship, from loopback to loopback. This stays up even if a physical link goes down. Also, it retains labels and speeds up convergence.
To do this, we need to enable ldp
on the lo0
interface as well.
[edit]
root@juniper# set protocols ldp interface lo0.0
[edit]
root@juniper# set protocols ldp session-protection
This establishes a targeted LDP session (even between two devices that are not directly connected).
All-zero Label Space (0.0.0.0:0
) indicates a problem!
LDP Egress Policies
LDP in Junos only generates a FEC fo the loopback’s primary IP. If we want other FECs (other IPs on the loopback interface or physical interface prefixes), we can create extra FECs using egress-policy
.
- Create a routing policy under
edit policy-options
- Apply it as an
egress-policy
underedit protocols ldp
This implies that the router will be an egress router fo all these FECs mentioned in the policy. All these prefixes share a single transport label, and aggregated int o a single FEC.
We can use deaggregate
to generate LDP labels for each egress IP. This needs to be done on the penultimate device.
[edit]
root@juniper# set protocols ldp deaggregate
LDP Import and Export Policies
Egress policies generate new FECs while import and export policies act on FECs that already exist.
Import policies
- tag a received FEC as
filtered
in the LDP database - prevent FEC from being imported to
inet.3
- prevent the router from re-advertising the FEC
Export policies
- prevent accepted FECs from being re-advertised
Steps to configure
- Create a routing policy under
edit policy-options
- Apply it as either
import
orexport
underedit protocols ldp