07 LDP Principles and Configuration
07 LDP Principles and Configuration
Page 1 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Foreword
• Multiprotocol Label Switching (MPLS) implements data forwarding based on short
and fixed-length labels carried in packets.
• A fundamental concept in MPLS is that two LSRs must agree on the meaning of the
labels used to forward traffic between them. The Label Distribution Protocol (LDP)
can be used by an LSR to send its label binding information to other LDP-capable
LSRs, helping implement correct forwarding of labeled packets.
• This course describes the principles, features, and basic configurations of LDP.
Page 2 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• LDP mentioned in this course refers to that defined in RFC 3036 for the first time. This
protocol has been replaced by RFC 5036.
• Other label distribution protocols include MP-BGP and RSVP.
Objectives
• On completion of this course, you will be able to:
▫ Understand LDP's basic concepts and working mechanisms.
Page 3 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Basic LDP Concepts
2. LDP Principles
Page 4 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
LDP Overview
• LDP is an MPLS control protocol, which is similar to a signaling protocol on a traditional network. LDP is responsible
for FEC classification, label distribution, and LSP establishment and maintenance. LDP defines the messages used in
label distribution as well as the message processing procedures.
2. Dynamic exchange of FEC-label mapping information between LSRs over LDP sessions, as well as LSP establishment based on
label information FEC: FEC:
192.168.3.0/24 192.168.3.0/24
Incoming label: Incoming label:
1024 1025
192.168.1.0/24 LDP session LDP session 192.168.3.0/24
R1 FEC: R2 FEC: R3
192.168.1.0/24 192.168.1.0/24
Incoming label: Incoming label: Question: LSRs exchange
1024 1026 incoming labels only. What
about outgoing labels?
Page 5 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
LDP Session, Adjacency, and Peer
• An LDP session must be established before LSRs can exchange label binding information. LDP sessions
are classified into the following types:
▫ Local LDP session: can be established between two LSRs that are directly connected.
▫ Remote LDP session: can be established between two LSRs that are directly or indirectly connected.
• An adjacency is established between two LSRs after they exchange Hello messages.
• After an adjacency is established between two LSRs, they exchange LDP session messages to establish
an LDP session. An LDP peer relationship is then established between them.
Label distribution
R1 R2 R3
Page 6 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
LSR ID and LDP ID
• Each LDP-capable LSR must have an LDP ID, in addition to an LSR ID.
▫ An LDP ID is 48 bits long and consists of a 32-bit LSR ID and a 16-bit label space ID.
▫ An LDP ID is presented in the format of "LSR ID:Label space ID", for example, 2.2.2.2:0.
GE0/0/0 GE0/0/0
R1 10.0.12.1/24 10.0.12.2/24 R2
Page 7 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Page 8 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• LDP messages are classified into four types by function: discovery, session,
advertisement, and notification.
▫ Session messages: establish, maintain, and terminate sessions between LDP peers.
Initialization and KeepAlive messages belong to this category.
▫ Advertisement messages: generate, change, and delete label mappings for FECs.
• LDP messages are carried over UDP or TCP, with the port number being 646. Discovery
messages, which are used to discover peers, are carried over UDP. Other LDP messages
must be transmitted in a reliable and ordered manner. Therefore, LDP uses TCP to
establish sessions. Session, advertisement, and notification messages are transmitted
over TCP.
LDP Packet Encapsulation
An LDP packet consists of an LDP header and an LDP message.
▫ An LDP header carries information such as the LDP version and packet length.
▫ An LDP message carries information such as the message type and message length.
10 bytes Variable length
Message
U Type Message ID Mandatory Parameters Optional Parameters
Length
Page 9 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• An LDP header is 10 bytes long. It consists of three parts: Version, PDU Length, and
LDP Identifier.
▫ The Version field occupies 2 bytes. It indicates the LDP version number. The current
version number is 1.
▫ The PDU Length field occupies 2 bytes. It indicates the packet length in bytes,
excluding the Version and PDU Length fields.
▫ The LDP Identifier field (that is, LDP ID) occupies 6 bytes. The first 4 bytes uniquely
identify an LSR, and the last 2 bytes identify the label space of the LSR.
• An LDP message consists of five parts.
▫ The U field occupies 1 bit, which is an unknown message. When an LSR receives an
unknown message, the LSR returns a notification message to the message
originator if the U field is 0, but ignores the message and does not respond with a
notification message if the U field is 1.
▫ Message Length occupies 2 bytes. It indicates the total length of Message ID,
Mandatory Parameters, and Optional Parameters, in bytes.
▫ Message ID occupies 32 bits. It identifies a message.
▫ Each of the Mandatory Parameters and Optional Parameters fields has a variable
length.
▫ Message Type indicates a specific message type. Currently, common messages
defined by LDP include Notification, Hello, Initialization, KeepAlive, Address, Address
Withdraw, Label Mapping, Label Request, Label Abort Request, Label Withdraw,
and Label Release.
Contents
1. Basic LDP Concepts
2. LDP Principles
▪ LDP Session Establishment
Page 10 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
LDP Session State Machine
LDP uses five states to describe the LDP session state machine.
1
A received message is not a Non-Existent
KeepAlive message, or no
A received message is not an Initialization
message is received. TCP connection message, or no message is received.
Action: Sends an NAK setup
message.
2 Active LSR
The passive LSR receives an acceptable Action: Sends an Initialization
Initialization message.
Initialized
message. A received message is not an
Action: Sends Initialization and Initialization message, or no
KeepAlive messages. message is received.
Action: Sends an NAK message.
3 3
OpenRec OpenSent
Page 11 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• The LDP session negotiation process can be described through the state machine. As
shown in the figure, there are five states. They are Non-Existent, Initialized, OpenRec,
OpenSent, and Operational.
▫ Non-Existent: It is the initial state of an LDP session. In this state, both LSRs send
Hello messages to elect the active LSR. After a TCP connection establishment
success event is received, the state changes to Initialized.
▫ Initialized: In this state, the active LSR sends an Initialization message to the passive
LSR, sets the session state to OpenSent, and waits for an Initialization message. The
passive LSR waits for the Initialization message sent by the active LSR. If the
parameters in the received Initialization message are accepted, the passive LSR
sends Initialization and KeepAlive messages, and sets the session state to OpenRec.
When the active and passive LSRs receive any non-initialization message or the
waiting period times out, both of them set the session state to Non-Existent.
▫ OpenSent: It is a state after the active LSR sends an Initialization message. In the
OpenSent state, the active LSR waits for the passive LSR to respond to the
Initialization and KeepAlive messages. If the parameters in the received
Initialization message are accepted, the active LSR sets the session state to
OpenRec. However, if the parameters are not accepted or the Initialization message
times out, the active LSR tears down the TCP connection and sets the session state
to Non-Existent.
▫ OpenRec: In this state, both the active and passive LSRs wait for a KeepAlive
message from the peer end after they send KeepAlive messages. An LSR sets the
session state to Operational state after receiving a KeepAlive message, but sets the
session state to Non-Existent if a non-KeepAlive message is received or the
KeepAlive message times out.
LDP Session Establishment: Peer Discovery
and TCP Session Establishment
R1 GE0/0/0 GE0/0/0
Discovery phase
R2
10.0.12.1 10.0.12.2 • An LSR periodically sends LDP Link Hello messages
to implement the basic LDP discovery mechanism.
Transport address: Transport address: • LDP Link Hello messages are encapsulated in UDP
1.1.1.1 2.2.2.2 packets, with the destination address being a
multicast address 224.0.0.2. If an LSR receives LDP
Hello (UDP) Link Hello messages on an interface, it indicates
10.0.12.1:646 -> 224.0.0.2:646 that this interface has established LDP peer
Discovery
relationships.
Phase Hello (UDP)
224.0.0.2:646 <-10.0.12.2 :646
Non-Existent
TCP SYN TCP Connection Establishment Phase
1.1.1.1:646 <- 2.2.2.2:22139
• A Hello message carries a transport address, which
TCP will be used to establish an LDP session.
connection TCP SYN ACK The LSR with a larger
• The LSR with a larger transport address is the
establishment 1.1.1.1:646 -> 2.2.2.2:22139 transport address initiates a
active LSR and initiates a TCP connection request.
phase TCP connection request.
• After the TCP three-way handshake, a TCP
TCP ACK connection will be established.
2.2.2.2:22139 -> 1.1.1.1:646
Initialized
Page 13 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• LDP transport addresses are used to establish TCP connections with peers.
▫ Before establishing an LDP session, two LSRs need to establish a TCP connection to
exchange LDP packets.
▫ After two LSRs discover each other and learn each other's transport address
through Hello messages, the LSRs attempt to perform the TCP three-way
handshake (based on the transport addresses), and exchange LDP Initialization
messages, Label Mapping messages, and so on. All these messages use the
transport addresses of the two ends as source and destination IP addresses.
▫ By default, the transport address for a device on a public network is the LSR ID of
the device, and the transport address for a device on a private network is the
primary IP address of an interface on the device.
▫ The mpls ldp transport-address command can be run in the interface view to
change a transport address.
LDP Session Establishment - Session
Establishment and Maintenance
R1 GE0/0/0 GE0/0/0 R2
• After a TCP connection is established, R2
10.0.12.1 10.0.12.2
(active LSR with a larger transport address)
sends an LDP Initialization message to
Transport address: Transport address: negotiate parameters related to LDP session
1.1.1.1 Completion of peer discovery 2.2.2.2 establishment.
and TCP three-way handshake
• These parameters include the LDP version,
label distribution mode, KeepAlive timer value,
Initialization
maximum PDU length, and label space.
Sends an Initialization message to
negotiate related parameters. • After R1 receives the Initialization message, it
OpenSent replies with a KeepAlive message if it accepts
Initialization + KeepAlive R2's parameters. To improve transmission
LDP session Replies with a KeepAlive message if the peer's efficiency, R1 also sends an Initialization
establishment parameters are accepted, message.
phase and initiates an Initialization message. • After R2 receives the Initialization message, it
KeepAlive replies with a KeepAlive message if it accepts
Sends a KeepAlive message if these R1's parameters.
parameters are accepted. • After both ends receive each other's KeepAlive
OpenRec
message, the session is established
The LDP session enters the Operational state. successfully. They periodically send KeepAlive
messages to maintain the session.
Page 14 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
LDP Peer State
LSR ID 1.1.1.1 LSR ID 2.2.2.2
Transport address: 1.1.1.1 Transport address: 2.2.2.2
GE0/0/0 GE0/0/0
R1 10.0.12.1/24 10.0.12.2/24 R2
Page 15 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
LDP Session States
LSR ID 1.1.1.1 LSR ID 2.2.2.2
Transport address: 1.1.1.1 Transport address: 2.2.2.2
GE0/0/0 GE0/0/0
R1 10.0.12.1/24 10.0.12.2/24 R2
Page 16 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
▫ NonExistent: initial state of an LDP session. In this state, the two ends send Hello
messages to each other. After the TCP connection establishment success event is
triggered, the session enters the Initialized state.
▫ OpenSent: The active LSR sends an Initialization message to the passive LSR and
waits for a reply.
▫ Open Recv: LDP peers at both ends of the LDP session wait for a KeepAlive
message from each other after the session enters the initialization state. If they
receive each other's KeepAlive message, the LDP session enters the Operational
state.
2. LDP Principles
▫ LDP Session Establishment
Page 17 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Label Advertisement and Management
• On an MPLS network, a downstream LSR determines the bindings between labels and FECs and advertises the
bindings to its upstream LSR.
• To establish LSPs, LDP sends Label Request and Label Mapping messages to advertise the bindings between labels
and FECs.
• Label advertisement and management are determined by the label advertisement mode, label distribution control
mode, and label retention mode.
Default Mode
Item Mode Description
(Yes/No)?
An LSR assigns and distributes labels to a FEC without receiving Label Request
Label Downstream unsolicited (DU) Yes
messages from its upstream LSR.
advertisement
mode An LSR assigns and distributes labels to a FEC only after receiving Label Request
Downstream on demand (DoD) No
messages from its upstream LSR.
A local LSR assigns and binds a label to a FEC and then advertises the binding to the
Independent No
Label upstream LSR, without waiting for the label distributed by the downstream LSR.
distribution
control mode An LSR sends the label mapping of a FEC to its upstream device only if the LSR has
Ordered Yes received Label Mapping messages from the next hop of the FEC or if the LSR is the
egress of the FEC.
An LSR retains all label mappings received from a peer, regardless of whether the
Label Liberal Yes
peer is its next hop.
retention
mode An LSR retains the label mappings received from a peer only if the peer is its next
Conservative No
hop.
Page 18 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Upstream and Downstream
• MPLS determines the upstream and downstream relationships based on the data forwarding
direction. Labeled packets are sent from an upstream LSR, and received and processed by a
downstream LSR.
• As shown in the figure, for the LSP to 192.168.3.0/24, R3 is the downstream LSR of R2, and
R1 is the upstream LSR of R2.
MPLS Domain
192.168.3.0/24
R1 R2 R3
Page 19 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Label Advertisement Mode — DU
DU mode
▫ An LSR assigns and distributes labels to a FEC without having to receive Label Request
messages from its upstream LSR.
▫ An LSR actively advertises the labels of a FEC to its upstream peer without having to
receive Label Request messages from the peer.
192.168.3.0/24
R1 R2 R3
Page 20 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• Label assignment: An LSR assigns a label from the local label space and binds it with a
FEC.
• Label distribution: An LSR notifies the upstream LSR of the binding between labels and
FECs.
• When the DU label advertisement mode is used, an LSR can assign labels to all its
peers by default. Specifically, each LSR can distribute label mappings to all its peers,
regardless of whether the LSR is an upstream or a downstream one. If an LSR
distributes labels only to upstream peers, it must identify its upstream and
downstream nodes based on routing information before sending Label Mapping
messages. An upstream node cannot send Label Mapping messages to its downstream
node.
Label Advertisement Mode — DoD
DoD mode
▫ An LSR assigns and distributes labels to a FEC only after receiving Label Request messages
from its upstream LSR.
192.168.3.0/24
R1 Requests R2 Requests R3
labels. labels.
R1 requires to access the
192.168.3.0/24 network segment.
Page 21 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• An LSR advertises label mappings to an upstream peer only after receiving Label
Request messages from the upstream peer.
Label Distribution Control Mode —
Independent
Independent mode
▫ A local LSR assigns and binds a label to a FEC and then advertises the binding to the
upstream LSR, without waiting for the label distributed by the downstream LSR.
Unordered
DU Advertises label mappings Advertises label mappings
to the upstream node. to the upstream node.
+
192.168.4.0/24
Independent
R1 R2 R3 R4
Unordered
Advertises label mappings Advertises label mappings
DoD to the upstream node. to the upstream node.
+
192.168.4.0/24
Independent
R1 Requests R2 Requests R3 R4
labels. labels.
Page 22 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• The label distribution control mode works with the label advertisement mode:
▫ If the network shown in the figure uses the DU label advertisement mode, R2 and
R3 can actively notify the upstream LSR of the label binding for the FEC
192.168.4.0/24 even if the upstream LSR does not send Label Request messages and
R2 and R3 do not receive label binding information from the downstream LSR.
▫ If the network uses the DoD label advertisement mode, R2 and R3 can notify the
upstream LSR of the label binding for the FEC 192.168.4.0/24 given that R2 and R3
have received Label Request messages from the upstream LSR, regardless of
whether R2 and R3 have received label binding information from the downstream
LSR.
Label Distribution Control Mode — Ordered
Ordered mode
▫ An LSR sends the label mapping of a FEC to its upstream device only if the LSR has received Label
Mapping messages from the downstream of the FEC or if the LSR is the egress of the FEC.
3 2 1
Advertises label mappings Advertises label mappings Advertises label mappings
DU to the upstream node. to the upstream node. to the upstream node.
+
192.168.4.0/24
Ordered
R1 R2 R3 R4
Egress LSR
6 5 4
Advertises label mappings Advertises label mappings Advertises label mappings
DoD to the upstream node. to the upstream node. to the upstream node.
+
192.168.4.0/24
Ordered
R1 Requests R2 Requests R3 Requests R4
labels. labels. labels. Egress LSR
1 2 3
Page 23 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• In ordered label distribution control mode, an LSR can send a Label Mapping message
to its upstream node only when the LSR receives Label Mapping messages of a FEC
from the downstream of the FEC or when the LSR is the egress of an LSP.
▫ If the network shown in the figure uses the DU label advertisement mode, an LSR
sends the label binding information of the FEC 192.168.4.0/24 to its upstream node
only after the LSR receives the label binding information of the FEC from its
downstream node, even if the upstream node has sent Label Request messages.
Therefore, the initiator for LSP establishment must be an egress LSR (R4 in this
example).
▫ If the network uses the DoD label advertisement mode, an LSR advertises the label
binding information of the FEC 192.168.4.0/24 to the upstream node only after the
LSR receives Label Request messages from the upstream node as well as the label
binding information of the FEC from the downstream node. Therefore, a Label
Request message can be initiated by the ingress LSR (R1) only. After a Label
Request is sent hop by hop to the egress LSR (R4), R4 advertises a Label Mapping
message to the upstream LSR to establish an LSP.
Label Retention Mode — Liberal
Liberal mode
▫ An LSR can receive label mappings from its next hop or non-next hop nodes.
▫ An LSR retains all label mappings received from a peer, regardless of whether the peer is
its next hop.
Advertises label mappings
to the upstream node.
R1 R2 R3 R4
192.168.1.0/24
Next hop
Page 24 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• In liberal mode, a new LSP can be quickly established when routes change, because all
received labels are retained, which is the biggest advantage of this mode. The
disadvantage is that unnecessary label mappings are distributed and maintained.
▫ In DoD label advertisement mode, if the liberal label retention mode is used, an
LSR requests labels from all LDP peers. However, the DoD label advertisement
mode is generally used together with the conservative label retention mode.
Label Retention Mode — Conservative
Conservative
▫ An LSR retains the label mappings received from a peer only if the peer is its next hop.
Not retained
R5
Page 25 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• The advantage of the conservative mode is that only the labels that will be used to
forward data are retained and maintained, thereby saving the label space.
▫ In DU label advertisement mode, an LSR may receive Label Mapping messages for
the same network segment (FEC) from multiple LDP peers. As shown in the figure,
R3 receives Label Mapping messages for the network segment 192.168.1.0/24 from
both R2 and R5. If the conservative label retention mode is used, R3 retains only
the label sent by the next hop R2 and discards the label sent by the non-next hop
R5.
▫ In DoD label advertisement mode, an LSR uses routing information to determine its
next hop and requests labels only from the next hop.
• If the next hop of a FEC changes, either of the following situations occurs:
▫ In liberal label retention mode, the LSR can use an existing label advertised by a
non-next hop LSR to quickly establish an LSP. The liberal mode requires more
memory and label space.
▫ In conservative label retention mode, the LSR retains the labels advertised by the
next hop only. This mode saves memory and label space but consumes more time
to reestablish the LSP.
▫ An LSR that has a limited label space usually uses the conservative mode and DoD
mode.
PHP
Label IP Packet
To To To To
1033
192.168.3.3 192.168.3.3 192.168.3.3 192.168.3.3
192.168.3.0/24
192.168.3.0/24 192.168.3.0/24
R1 Label=1033 R2 Label=3 R3
MPLS Domain
Penultimate hop popping (PHP): If PHP is enabled, an egress assigns a special label (3), to a local route.
This label is called an implicit null label. When an LSR forwards a labeled packet and finds that the
outgoing label value is 3, the LSR removes the top label from the packet and forwards the inner data to
the downstream LSR.
Page 26 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• During label advertisement, R3 is the egress of the FEC 192.168.3.0/24. During label
distribution, R3 assigns label 3 to the FEC and advertises the label binding information
to R2.
• During data forwarding, R2, as the penultimate hop to 192.168.3.0, finds that the
outgoing label value is 3. Then, R2 removes the label header and forwards the IP
packet to R3. R3 only needs to query the FIB once to obtain the corresponding
forwarding information, improving the forwarding efficiency.
Implicit Null Label and Explicit Null Label (1)
• By default, an egress assigns implicit null labels, that is, label 3, to the penultimate hop.
• However, if QoS is deployed, after the label is popped out, the priority in the label is lost.
R1 R2 R3 R4
10.0.12.2/24 10.0.23.3/24 10.0.34.4/24
192.168.1.0/24 192.168.4.0/24
10.0.12.1/24 10.0.23.2/24 10.0.34.3/24
200 To 300 To To
EXP 192.168.4.4 EXP 192.168.4.4 192.168.4.4
Page 27 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Implicit Null Label and Explicit Null Label (2)
• In the explicit null label mechanism, an egress assigns label 0 to the penultimate hop.
• When R3 forwards a labeled packet of which the outgoing label is 0, R3 does not pop out the label
header, and therefore QoS information is retained. When R4 receives a packet with label 0, it directly
pops out the label without searching for an ILM entry.
• By default, an egress assigns implicit null labels. You can run the label advertise explicit-null
command to enable the egress to assign explicit null labels to the penultimate hop.
QoS information
is retained.
R1 R2 R3 R4
10.0.12.2/24 10.0.23.3/24 10.0.34.4/24
192.168.1.0/24 192.168.4.0/24
10.0.12.1/24 10.0.23.2/24 10.0.34.3/24
200 To 300 To To
EXP 192.168.4.4 EXP 192.168.4.4 192.168.4.4
Page 28 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
▫ explicit-null: If this parameter is set, an egress assigns an explicit null label with
the value of 0 to the penultimate hop. The explicit-null parameter can be set if
MPLS QoS attributes need to be used.
▫ non-null: If this parameter is set, an egress assigns a common label with a value
greater than or equal to 16 to the penultimate hop.
Contents
1. Basic LDP Concepts
2. LDP Principles
▫ LDP Session Establishment
Page 29 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Networking Overview
• OSPF has been deployed on the network, and devices can learn routes from each other.
• MPLS and LDP have been enabled on devices and interfaces, and local LDP sessions have been
established between neighboring devices.
• All LSRs use the DU + Independent + Liberal modes.
R2 Destination/Mask Proto Cost NH
192.168.4.0/24 OSPF 2 R2
R1 R4
OSPF
LDP 192.168.4.0/24
192.168.4.0/24 Direct 0 -
Destination/Mask Proto Cost NH
R3
192.168.4.0/24 OSPF 10 R4
Page 30 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• For a packet that enters the MPLS domain from R1 and is destined for 192.168.4.0/24,
R1 is the ingress LSR, and R4 is the egress LSR.
Label Distribution — Egress LSR
R4 is directly connected to the network segment 192.168.4.0/24. R4 actively assigns labels, such
as 1041, to routes destined for this network segment and advertises label mapping information
to its LDP peers (R2 and R3) through LDP packets.
Destination/Mask Proto Cost NH
192.168.4.0/24 OSPF 1 R4
R2
R1 R4
OSPF
LDP 192.168.4.0/24/24
Page 31 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• Note: By default, 32-bit host IP routes are used to trigger LSP establishment. You can
manually trigger the establishment of an LSP with non-32-bit host IP routes.
Label Distribution — Transit LSR
Take R2 as an example. In its routing table, the next hop of the route 192.168.4.0/24 is R4. When R2
receives a Label Mapping message for the route 192.168.4.0/24 from R4, R2 assigns label 1021 to the
route because the message is sent by a downstream LDP peer, and advertises the label mapping to the
LDP peer, for example, R1. This process also applies to R3.
Destination/Mask Proto Cost NH
R2 192.168.4.0/24 OSPF 1 R4
R1 R4
OSPF
LDP 192.168.4.0/24
Page 32 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Label Distribution — Ingress LSR
After R1 receives the label mappings for the route 192.168.4.0/24 advertised by R2 and R3, R1 stores both
of the label mappings. However, R1 only uses label 1021 advertised by R2, because the next hop of the
route to 192.168.4.0/24 is R2, as shown in R1's routing table.
R2
Destination/Mask Proto Cost NH
192.168.4.0/24 OSPF 2 R2
R1 R4
OSPF
LDP 192.168.4.0/24
Page 33 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• Note: If R2 fails, OSPF routes re-converge. The next hop of the route 192.168.4.0/24 in
the routing table of R1 is switched to R3. In this case, R1 uses the label advertised by
R3 for 192.168.4.0/24.
Label-based Forwarding — Ingress LSR
As an ingress LSR, R1 pushes a label into each received IP packet, and forwards packets
based on labels.
Routing table of R1
NHLFE 3 1
table of R1
To 192.168.4.1
Tunnel ID Out intf OPER NH Out Label
Page 34 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• When R1 receives an IP packet destined for 192.168.4.1, it searches the FIB for a
forwarding entry matching the destination IP address of the packet, and finds that the
tunnel ID in the matching entry is not 0. As such, R1 continues to search for an NHLFE
matching the tunnel ID, pushes a label to the IP packet, and forwards the packet. The
outbound interface is GE 0/0/0, the next hop is R2, and the outgoing label is 1021.
Therefore, R1 adds a label header to the packet and forwards the packet.
Label-based Forwarding — Transit LSR
As a transit LSR, R2 needs to swap labels in received IP packets and forward
the packets.
1 4
ILM table of R2 2 R2
In Label Tunnel ID
1021 0x12
R1 R4
NHLFE table 3 OSPF
192.168.4.0/24
of R2 LDP
R3
LSP
Page 35 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• When R2 receives a packet with label 1021, it searches for a matching ILM entry and
an NHLFE matching the ILM entry. Then, R2 changes the label of the packet to 1041
and forwards the packet through the matching outbound interface.
Label-based Forwarding — Egress LSR
As an egress LSR, R4 needs to perform the pop operation on received IP packets to
remove labels and forward the packets through IP.
ILM table of R4 2 1
Out R2
In Label Tunnel ID Out intf OPER NH
Label
1041 0x12 GE0/0/0 Pop - Null
R1 R4
OSPF
192.168.4.0/24
LDP
GE0/0/0
3 To 192.168.4.1
R3
LSP
Page 36 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• When R4 receives a packet with label 1041, it searches for a matching ILM entry and
finds that the operation type is pop. R4 then performs a pop operation to remove the
outer label from the packet. The packet then becomes a standard IP packet, and
• When R4 forwards the packet, it searches the LFIB and FIB. How can the forwarding
efficiency be improved on the egress LSR (R4)?
Summary of an LDP-Capable LSR's Operations on
an MPLS Network
• An LSR runs an IGP (such as OSPF or IS-IS) to construct a routing table and FIB.
• LDP assigns labels to route prefixes (FECs) in the routing table based on the label
assignment mode it uses.
• LDP advertises the labels assigned to the route prefixes to LDP peers through LDP Label
Mapping messages based on the label advertisement mode it uses.
• An LSR stores the labels that it assigns to route prefixes and the labels that LDP peers
advertise to the route prefixes, and associates the labels with information such as outbound
interfaces and next-hop addresses (label forwarding entries).
• When an LSR forwards a labeled packet destined, the LSR always uses the outgoing label
advertised by the downstream LDP peer. The downstream peer is the next-hop device to the
destination network in the routing table.
Page 37 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Basic LDP Concepts
2. LDP Principles
Page 38 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Basic LDP Configuration Commands (1)
1. Enable LDP.
The mpls ldp command enables LDP and displays the LDP view.
[Huawei-GigabitEthernet0/0/0] mpls ldp
Enable LDP on an interface. Before running this command, enable LDP globally.
The mpls ldp remote-peer command creates a remote peer and displays the remote peer view.
[Huawei-mpls-ldp-remote-PeerName] remote-ip ip-address
Set the remote-ip ip-address parameter to the IP address of a remote LDP peer.
Page 39 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Basic LDP Configuration Commands (2)
3. Configure a policy for triggering LSP establishment.
The lsp-trigger command configures the routes (static and IGP routes) that are used to trigger LSP establishment, which are
IP routes with a 32-bit mask by default.
• all: All static and IGP routes are used to trigger LSP establishment. If this parameter is set, a significant of LSPs will be
established, consuming label resources excessively and slowing down network-wide LSP convergence. Therefore, setting this
parameter is not recommended.
• host: IP routes with a 32-bit mask are used to trigger LSP establishment.
• ip-prefix ip-prefix-name: Routes matching a specified IP prefix list are used to trigger LSP establishment.
• none: LSP establishment cannot be triggered.
4. Configure a label advertisement mode.
[Huawei-GigabitEthernet0/0/0] mpls ldp advertisement { dod | du }
The default label advertisement mode is downstream unsolicited (DU).
• If the label advertisement mode is DU, the label retention mode is liberal.
• If the label advertisement mode is DoD, the label retention mode is conservative.
Page 40 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
• BGP routes can also be used to trigger LDP LSP establishment. This trigger policy is not
covered in this course.
Basic LDP Configuration Commands (3)
5. Configure an LDP label distribution control mode.
6. Configure PHP.
[Huawei-mpls] label advertise { explicit-null | implicit-null | non-null }
By default, an egress distributes implicit null labels to a penultimate hop.
• explicit-null: An egress assigns explicit null label to the penultimate hop.
• implicit-null: An egress assigns implicit null labels to the penultimate hop.
• non-null: An egress assigns common labels to the penultimate hop.
Page 41 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Configuration Examples
R1 GE0/0/0 R2 GE0/0/1 R3 GE0/0/1 R4
10.0.12.1/24 10.0.23.2/24 10.0.34.3/24
GE0/0/0 GE0/0/0 GE0/0/0
10.0.12.2/24 10.0.23.3/24 10.0.34.4/24
Page 42 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Configuration Procedure (1)
R1 GE0/0/0 R2 GE0/0/1 R3 GE0/0/1 R4
10.0.12.1/24 10.0.23.2/24 10.0.34.3/24
GE0/0/0 GE0/0/0 GE0/0/0
10.0.12.2/24 10.0.23.3/24 10.0.34.4/24
Enable basic MPLS and LDP functions on the devices. The following example uses R1.
[R1]mpls
[R1-mpls]quit
[R1]mpls ldp
[R1-mpls-ldp]quit
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]mpls
[R1-GigabitEthernet0/0/0]mpls ldp
[R1-GigabitEthernet0/0/0]quit
Page 43 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Configuration Procedure (2)
R1 GE0/0/0 R2 GE0/0/1 R3 GE0/0/1 R4
10.0.12.1/24 10.0.23.2/24 10.0.34.3/24
GE0/0/0 GE0/0/0 GE0/0/0
10.0.12.2/24 10.0.23.3/24 10.0.34.4/24
Page 44 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Checking the Configuration - Checking LSP Information
Page 45 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Quiz
1. (Single) Which of the following commands can be used to display a label distributed for a
specific FEC? ( )
A. display mpls ldp
B. display mpls ldp interface
C. display mpls lsp
D. display mpls ldp session
2. (Single) What is the default combination of label advertisement mode, label distribution
control mode, and label retention mode on Huawei devices?
A. DU + Independent + Conservative
B. DU + Ordered+ Liberal
C. DoD + Independent+ Liberal
D. DoD + Ordered + Conservative
Page 46 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
1. C
2. B
Summary
• MPLS supports multiple label distribution protocols, among which LDP is widely used.
• LDP is a process in which LSRs negotiate the meaning of labels. LDP uses discovery, session,
advertisement, and notification packets to establish sessions and distribute labels.
• LDP determines label advertisement and management based on the label advertisement
mode, label distribution control mode, and label retention mode. By default, Huawei
datacom devices use the DU label advertisement mode + ordered label distribution control
mode + liberal label retention mode.
• LDP can directly map network-layer routing information to label information in order to
establish LSPs. LSRs are connected according to the incoming label, next hop, and outgoing
label corresponding to a specified FEC in the local forwarding table. In this manner, the LSP
crossing the entire MPLS domain can be formed.
Page 47 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
谢 谢You
Thank
www.huawei.com
Page 48 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.