Detailed LDP basics

Overview:

The label distribution protocol LDP is a control protocol for multi-protocol label switching MPLS, which is equivalent to the signaling protocol in the traditional network. It is responsible for forwarding the classification of equivalent FEC (one route), the distribution of labels, and the establishment and establishment of the label switching path LSP. Maintenance and other operations. LDP specifies various messages and related processing procedures in the label distribution process.

LDP term:

  1. LDP peers
    LDP peers refer to two LSRs that have LDP sessions between each other and use LDP to exchange label messages. LDP peers obtain each other's label through the LDP session between them.
  2. LDP adjacency LDP adjacency is established
    when an LSR receives the Hello message from the opposite end. There are two types of LDP adjacencies:
    • Local Adjacency: The adjacency discovered by sending Hello messages (ie link Hello messages) in the form of multicast is called a local adjacency.
    • Remote Adjacency (Remote Adjacency): The adjacency found by sending the Hello message (ie the target Hello message) in unicast form is called the remote adjacency.
    LDP maintains the existence of peers through adjacency, and the type of peer depends on the type of adjacency that maintains it. A peer can be maintained by multiple adjacencies. If it is maintained by both a local adjacency and a remote adjacency, the peer type is the remote coexisting peer.
  3. LDP session
    LDP session is used to exchange information such as label mapping and release between LSRs. An LDP session can be established only when there is a peer. There are two types of LDP sessions:
    • Local LDP Session: The two LSRs that establish the session are directly connected.
    • Remote LDP Session (Remote LDP Session): The two LSRs that establish a session can be directly connected or indirectly connected.
    Local LDP sessions and remote LDP sessions can coexist.
  4. Label space
    One is the label space based on the interface: the label range advertised by each interface is unique, as shown in the figure, the labels advertised by LER1 on different interfaces for the same FEC are different; the
    Insert picture description here
    other is the label space based on the platform: Label allocation is not unique under each interface, but is allocated from the entire LSR. As shown in the figure, LER1 advertises a label for the same FEC:
    Insert picture description here
    Huawei devices use the platform method to allocate labels by default.

The value range of the label space is divided as follows:

  1. 0~15: Special label. For example, label 3, called the implicit empty label, is used for the second-to-last hop popup (detailed analysis later); label 0, called the display empty label, if the label is 0, the second-to-last hop LSR needs to set the value to 0 The label is normally pressed into the top of the label value of the message and forwarded to the node. When the outgoing node finds that the label value carried in the packet is 0, it will pop the label directly (the difference from the ordinary label is that there is no need to check the LFIB table for operation here, which saves the corresponding time). The purpose of using the display empty label is to do QoS .
  2. 16~1023: Static LSP and static CR-LSP (shared label space).
  3. 1024 and above: the label space of dynamic signaling protocols such as LDP, RSVP-TE, MP-BGP.

Message format analysis:

The LDP protocol mainly uses four types of messages:

  1. Discovery message: used to advertise and maintain the existence of neighbors in the network, such as Hello messages.
  2. Session messages: used to establish, maintain, and terminate sessions between LDP peers, such as Initialization messages and Keepalive messages.
  3. Advertisement message: used to create, change, and delete FEC label mapping, such as Address message and Label Mapping message.
  4. Notification message: Used to provide advisory messages and error notifications.

LDP PDU header format:
Insert picture description here
LDP message is based on TCP (Hello message is based on UDP), the port number is 646, and the message format is
encapsulated in the way of TLV, LDP message is divided into header and message content Two parts, the LDP header format is shown in the figure:
Insert picture description here
The fields are explained as follows:

  1. Version: 2Byte unsigned integer value, representing the version number of the LDP protocol. The current version number of the LDP protocol is Ox01.
  2. PDU Length: 2Byte integer value, which expresses the PDU length in bytes, excluding the version number and PDU length fields. The maximum length of the PDU is negotiated when the session is initialized, and the default maximum length is 4096 bytes.
  3. LDP ldentifier: 6Byte, which uniquely identifies the label space of the sending LSR to which the PDU belongs. The first 4 Bytes represent the LSR-ID address, and the last 2 Bytes specify the specific label space in the LSR.

The format of the LDP message is shown in the figure:
Insert picture description here
the fields are explained as follows:

  1. U: 1bit, unknown TLV bit, U=0 to return notification, U=1 to ignore the message.
  2. Message Type: 14bit, indicating the type of message.
  3. Message Length: 2Byte, the length of the message expressed in bytes, including the message identifier, mandatory parameters, and optional parameters.
  4. Message ID: message identifier, 4Byte, used to identify the message.
  5. Mandatory Parameters: Mandatory parameters have variable lengths, mandatory parameter sets. Option Parameters: Variable length of optional parameters, optional parameter set.

1. Hello message
LDP Hello message is used to discover neighbors and used to maintain the neighbor relationship in the later period. It is sent based on UDP and the destination address is 224.0.0.2. It will be sent periodically on the LDP-enabled interface (default Period = 5s). The format is as follows: The
Insert picture description here
Hello packet carries some common parameters, such as the hold time, and the transmission address of the sender. The hold time is the waiting time before deleting a neighbor. The default is 15s (Hello*3). If the hold time set by both parties is different, the shorter time will be used. The transport address is the address used to establish a TCP connection. The default is the same as the LSR-ID. Therefore, by default, if two LSRs can successfully establish an LDP neighbor session relationship, the respective LSR-ID must be reachable. The transport address can be modified to other addresses. The modification method of Huawei equipment is as follows:
[LSR1-GigabitEthernet0/0/0]mpls ldp transport-address interface

However, modifying the transport address will cause the LDP neighbor relationship to be interrupted, which will affect the upper-layer services, so it must be configured carefully. You can use the following methods to view the hold time and transmission address, as shown in the following output:
Insert picture description here
2. Initialization message
Initialization message is used to negotiate LDP neighbor session parameters, including label distribution mode, anti-loop mechanism and label space, as shown in the figure Note: The
Insert picture description here
label distribution method will be analyzed later.

3. Address message
Address message is used to advertise all the interface IP addresses of the local end to the LDP neighbor so that the neighbor can determine the outbound label through the next hop address in the IP forwarding table, as shown in the figure:
Insert picture description here
If an LDP router starts from Different neighbors receive the label mapping of the same FEC, and then it is necessary
to select the best out label for the FEC . At this time, it is necessary to comprehensively check the information of the IP forwarding table and the label table to determine the out label.

4. Label announcement message
Label announcement message is used to advertise the binding content of FEC and label to LDP neighbors. One label announcement can advertise multiple label information, as shown in the figure:
Insert picture description here
label announcement message also includes label request and label The revocation and label release messages are not described here.

5. Keepalive messages After the
LDP neighbor session is established, the two parties will periodically exchange KeepAlive messages for keepalive detection of the TCP session. The default detection period is 15s and the timeout period is 45s. The KeepAlive message has no specific content and the format is very simple, as shown in the figure:
Insert picture description here
6. Notification message
Notification messages are divided into error notifications or query notifications. A notification message will be sent out when the following events occur: the received data packet format is wrong, unrecognized TLV, session timeout, etc., the message will report the specific error type to the neighbor, as shown in the figure:
Insert picture description here
message usage flow chart as follows:
Insert picture description here

LDP neighbor relationship establishment process:

1. Neighbor discovery:
Local LDP Session: The two LSRs that establish the session are directly connected.
Insert picture description here
After the LDP protocol is started, the router sends out Hello packets, and neighboring routers exchange Hello packets to complete each other's "greet". Through the Hello packets, the neighbor's basic information, such as the address used to establish a session (transmission Address) etc.

LDP Hello messages are encapsulated in UDP. UDP is a connectionless protocol. In order to ensure the validity and reliability of neighbors, Hello messages are sent periodically with a sending period of 5s. The multicast 224.0.0.2 is used as the destination IP address, which means "sent to all routers in the network."

Then, the party with the larger address initiates a TCP connection and finally establishes a neighbor session. This type of LDP session is called a local session. If the neighbor address is specified manually, the established session is called a remote LDP session.

Remote LDP Session (Remote LDP Session): The two LSRs that establish a session can be directly connected or indirectly connected.
Insert picture description here
If the neighbor is a non-directly connected device, Hello will be exchanged in unicast mode to complete the establishment of a remote LDP session, as shown in the figure above.

2. Session establishment: After
LDP neighbors discover each other or directly specify the neighbor address, they start to establish a TCP connection. After the TCP connection is established, they send initialization messages to each other for parameter negotiation, as shown in the figure:
Insert picture description here
If you accept the other party's parameters, It will reply with a KeepAlive message to complete the establishment of the LDP session; if an error occurs during the period, a Notification message will be sent to report the corresponding error, which will eventually cause the connection to be closed. You can use the following command to check the establishment of an LDP session: the Insert picture description here
status is Operational, which means that the LDP session has been established successfully, and neighbors can exchange messages such as label announcements. After the session is established, both parties will periodically send Hello packets to detect the neighbor status, and also periodically send KeepAlive packets to detect the TCP connection status.

LDP state machine:

The LDP protocol has gone through four states from neighbor discovery to session establishment. The switching between states is shown in the following figure:
Insert picture description here

  1. Non Existent state: the initial state of the LDP protocol, similar to the IDLE state of BGP. At the beginning, both parties use the multicast address 224.0.0.2 to send Hello packets, and elect the active and passive parties (the one with the higher LSR IP address is selected as the active party). After receiving each other's Hello message, the two parties begin to establish a TCP connection, followed by the three-way handshake process of establishing a TCP connection. When the TCP session is successfully established, the two parties enter the Initialized state.
  2. Initialized state: In this state, the work of the active and passive parties is a bit different. The active party first sends the Initialization message, then it switches to the Opensent state, and waits for the passive party to respond to the Initialization message. In this state, the passive party will wait for the active party to send an Initialization message. If the parameters in the received Initialization message are acceptable, it will respond to the active party with the Initialization and KeepAlive messages, and then transfer to the Openrec state. In this state, the active and passive parties will jump to the Non Existent state when they receive non-Initialization packets or wait for a timeout.
  3. Opensent state: This state is the state after the active party sends an initialization message. In this state, it also waits for the neighbor's initialization and KeepAlive messages. If the parameters in the received initialization message can be accepted, it will respond to the neighbor with the KeepAlive message, and the state will jump to the Openrec state; if the parameters cannot be accepted or the waiting time expires, the TCP session connection will be disconnected and entered Non Existent status.
  4. Openrec state: Whether it is the active party or the passive party, it will enter this state after receiving the initialization message with the correct parameters. In this state, it has responded to the other party with the KeepAlive message and waiting for the neighbor to respond to the KeepAlive message. If the KeepAlive message is received from the neighbor on time, it will switch to the Operational state; if other messages are received or the waiting time expires, it will switch to the Non Existent state.
  5. Operational state: Reaching this state means that the LDP session has been successfully established and all other LDP packets can be sent and exchanged. In this state, the two parties maintain the neighbor session through the periodic KeepAlive message exchange. If the KeepAlive times out, the LDP session will be immediately disconnected and enter the Non Existent state; when an error notification message is received, the LDP session will also be disconnected and forwarded. Enter Non Existent state.

Establishment and maintenance of LSP:

The LSP establishment process actually binds the FEC and the label, and advertises this binding to the adjacent LSR on the LSP. This process is implemented through LDP. Take DU mode and ordered label control as an example. The main steps are as follows: The
Insert picture description here
topology is shown in the figure. The process of LDP dynamically establishing LSP is as follows:

  1. There is a host route of 100.1.1.1/32 on the RTD. Because the RTD is an egress node, it directly advertises the binding relationship between 100.1.1.1/32 and the label to its upstream neighbor RTC.
  2. After the RTC receives the binding relationship between 100.1.1.1/32 and the label allocated by the downstream neighbor RTD, it records the label in its LIB table and advertises the binding relationship between 100.1.1.1/32 and the label to the upstream neighbor RTB. RTC checks whether the next hop to 100.1.1.1/32 in its IP routing table is RTD. If the next hop in the IP routing table is RTD, RTC uses the label assigned by RTD to encapsulate the data reaching 100.1.1.1/32; If the next hop in the IP routing table is not an RTD, the RTC reserves the label assigned by the RTD as a backup label.
  3. After receiving the binding relationship between 100.1.1.1/32 and the label allocated by the downstream neighbor RTC, RTB performs the same actions as RTC.
  4. After RTA receives the binding relationship between 100.1.1.1/32 and the label allocated by the neighbor RTB, it checks whether the next hop to 100.1.1.1/32 in its IP routing table is RTB. If the next hop in the IP routing table is If the hop is RTB, RTA uses the label allocated by RTB to encapsulate the data reaching 100.1.1.1/32; if the next hop in the IP routing table is not RTB, RTA reserves the label allocated by RTB as a backup. Because RTA is an Ingress, the LSP that finally reaches 100.1.1.1/32 is established.

Session cancellation:

LDP judges the adjacency relationship by detecting Hello messages; it judges the integrity of the session by detecting Keepalive messages.

LDP uses different timers to maintain adjacency and LDP sessions:

  1. Hello retention timer: LDP peers periodically send Hello messages to indicate that they want to maintain this adjacency. If the Hello keep timer expires and no new Hello message is received, the Hello adjacency is deleted.
  2. Keepalive timer: LDP peers maintain LDP sessions through Keepalive messages sent over LDP session connections. If the session keep timer expires and no Keepalive message is received, the connection is closed and the LDP session is ended.

It can be seen that the Hello packet controls the neighbor relationship, and the Keepalive controls the session relationship.

The basic rules of LDP label distribution:

The establishment of LDP LSP is completed by receiving the label allocated by the downstream device for FEC (usually a routing table entry), and establishing the mapping relationship between FEC and MPLS label and outgoing interface. Therefore, to establish an FEC-based LSP, you must first assign a label to the corresponding FEC. The distribution of labels must comply with the following principles:

  1. The allocation of incoming labels is in the order of largest to smallest (minimum 1024), and the smallest label currently unallocated is allocated.
  2. The incoming label assigned to FEC by the downstream device on the same link must correspond to the outgoing label of the upstream device.
  3. There may be multiple outgoing labels received for the same FEC on a device (they can be the same or different), which come from different downstream peers, that is, one FEC can map multiple outgoing labels and outgoing interfaces .
  4. Only one incoming label is allocated for the same FEC on a device, that is, for incoming labels, each FEC is unique on the same device.
  5. On the node that is directly connected to the network segment for a certain FEC (the default is only a host route with a 32-bit mask, you can use the lsp-trigger command to modify, and follow-up notes supplement) will create only one LSP containing the incoming label for the FEC. This LSP has no outgoing label and no outgoing interface, because this is the end of the LSP tunnel.
  6. On other nodes, two LSPs will be created for the FEC of the non-directly connected network segment at the same time: one of them is the LSP used to guide the access from the local node to the destination host represented by the FEC, including only the outgoing label and outgoing interface; the other is The local node is the LSP of the transit node (Transit), which is used to guide the upstream device to access the destination host represented by the FEC, and includes the incoming label, outgoing label, and outgoing interface.

LDP label release and management:

1. Label publishing method:
DU (Downstream Unsolicited, downstream autonomous method): For a packet arriving at the same destination address, the LSR can perform label allocation and distribution without obtaining a label request message from the upstream.

DoD (Downstream on Demand, Downstream on Demand): For a packet arriving at the same destination address, the LSR performs label allocation and distribution after obtaining the label request message.
Insert picture description here
Topology as shown in the figure:

  1. The DU method is used to distribute labels. For packets with a destination address of 100.1.1.1/32, the downstream RTD (Egress) actively advertises the label of its host route 100.1.1.1/32 to the upstream RTC (Transit) through a label mapping message.
  2. Labels are distributed in DoD mode. For packets with a destination address of 100.1.1.1/32, the upstream RTC (Transit) sends a label request message to the downstream, and the downstream RTD (Egress) sends a label mapping message to the upstream after receiving the label request message. .

Huawei devices use the DU method to publish labels by default. The DU does not need to wait for upstream request messages and can directly assign labels to neighbors. When the network topology changes, the DU method can quickly respond to the distribution of labels for the new topology, and the convergence time is shorter than that of the DoD method.

2. Label distribution control mode:
Independent (independent label distribution control mode): The local LSR can autonomously assign a label to be bound to an IP packet and notify the upstream LSR without waiting for the downstream label.

Ordered (Ordered label distribution control method): Only when the LSR already has the label of the next hop of the IP packet, or the LSR is the outgoing node of the IP packet, the LSR can send the label of the IP packet upstream .
Insert picture description here
Topology as shown in the figure:

Using the Independent method:

  1. If the label distribution mode is DU and the label distribution control mode is Independent, RTC (Transit) does not need to wait for the label of the downstream RTD (Egress), and will directly distribute the label to the upstream RTB.
  2. If the label distribution mode is DoD and the label distribution control mode is Independent, the directly connected downstream RTC (Transit) of the RTB (Transit) that sends the label request will directly respond to the label without waiting for the label from the downstream RTD (Egress).

Using the Ordered method:

  1. If the label distribution mode is DU and the label distribution control mode is Ordered, RTC (Transit) will only distribute labels to the upstream RTB after receiving the label from the downstream RTD (Egress).
    2. If the label distribution method is DoD and the label distribution control method is Ordered, the direct downstream RTC (Transit) of the RTB (Transit) sending the label request will only send the label from the downstream RTD (Egress) to the upstream RTB. Distribute labels.

Huawei devices use the Ordered method to assign labels by default. In the Ordered mode, the label can be distributed upstream only when the LSR already has the label of the next hop of the IP packet. This is to prevent the label of the downstream IP packet from being unallocated or the convergence time is long, and the upstream label is allocated. Data loss caused by data starting to forward.

3. How to keep the label:

Liberal (free label retention mode): The label mapping received from the neighbor LSR is reserved regardless of whether the neighbor LSR is its next hop or not. (But when the LSP is finally formed, only the label sent from the next hop will be used)

Conservative (conservative label retention mode): The label mapping received from the neighbor LSR is reserved only when the neighbor LSR is its next hop.
Insert picture description here
The topology shown in the figure, when the network topology change causes the next hop neighbor to change:

  1. Using the free label retention method, the LSR can directly use the label sent by the original non-next-hop neighbor to quickly rebuild the LSP, but it requires more memory and label space.
  2. Using conservative label retention, LSR only retains labels from next-hop neighbors, saving memory and label space, but LSP reconstruction will be slower.

Huawei devices use the free label retention method to save labels by default.

Currently, Huawei settings support the following combinations:

  1. Downstream autonomous mode (DU) + ordered label distribution control mode (Ordered) + free label retention mode (Liberal), which is the default mode. That is, after receiving the downstream label mapping, the LSR can allocate labels to the upstream autonomously, and all the received labels are reserved. (Flexible but consumes more resources)
  2. Downstream on-demand mode (DoD) + ordered label distribution control mode (Ordered) + conservative label retention mode (Conservative). That is, after receiving the upstream label request and downstream label mapping at the same time, the LSR allocates labels to the upstream, and only retains the labels allocated by its next hop. (It consumes less resources but is not flexible)

Organize data sources: "HCIE Routing and Exchange Study Guide", Huawei HCIE training materials

Guess you like

Origin blog.csdn.net/tushanpeipei/article/details/112981926
ldp