Theoretical foundations and architecture
LDP supports multiple protocol operational modes: 1. Label Advertisement: Downstream Unsolicited (DU) automatically pushes label mappings to all peers without waiting for a request (universal standard in carrier backbones); Downstream on Demand (DoD) distributes labels only when explicitly requested by an upstream router. 2. Label Retention: Liberal Retention retains received label bindings from ALL neighbors in the LIB, regardless of whether they represent the best IGP next hop (enabling faster recovery upon link failover); Conservative Retention stores only labels from the active next hop (minimizing memory utilization). 3. Label Distribution Control: Ordered Control mandates that an LSR advertises a label for a FEC only after receiving a mapping from its downstream next hop or if it is the egress LSR (the LSP is built egress-to-ingress, so no label points to a missing tail); Independent Control allows an LSR to advertise labels autonomously before downstream synchronization, which is fast but may create transient black holes (Cisco IOS default; Junos uses ordered control).
Three independent axes of LDP behavior
RFC 5036 describes three orthogonal choices that must not be confused: how labels are distributed (Downstream Unsolicited or Downstream on Demand), what to do with received labels (liberal or conservative retention) and when you may allocate your own label (independent or ordered control). Each vendor implementation picks a combination; in an Ethernet carrier core it is almost always DU + liberal, while the control mode differs between platforms.
Downstream Unsolicited and Downstream on Demand
In DU the downstream node (the one that provides a label for forwarding towards it) sends Label Mapping to all neighbors without a request as soon as it has a binding for the FEC. The upstream simply accepts. In DoD the upstream first sends a Label Request (0x0401) for a specific FEC, and the downstream answers with a Label Mapping; the label is issued only on request, and when the next hop changes the request is repeated. DoD is needed where labels are expensive (ATM, Frame Relay, label-controlled interfaces) or where labels should be issued only when needed. The mode is negotiated in Initialization (the A flag): if one node proposes DU and the other DoD, the session uses DoD. For Ethernet DU is natural and saves one round trip per FEC, so DoD is rare in IP/MPLS cores (Huawei lets you choose the mode explicitly per interface with mpls ldp advertisement).
Label retention: liberal and conservative
Liberal retention keeps in the LIB the bindings from all neighbors, even if the neighbor is not currently the next hop for the FEC. The gain is instant switchover to a backup path: after the primary link fails LDP takes the label of the new next hop that is already in the LIB, without waiting for a Label Mapping, and the LFIB is recomputed in milliseconds. The price is memory: N neighbors multiply the LIB size; with 5000 FECs and 4 neighbors that is 20 000 entries, which is insignificant for modern platforms. Conservative retention keeps only the binding from the current next hop and discards the others (with DoD it requests the label of the new next hop again via Label Request). It saves memory, but after a next-hop change convergence goes through message exchange, and traffic is lost for that time.
Label distribution control: independent and ordered
With independent control an LSR allocates a local label for a FEC as soon as the prefix appears in its RIB and advertises it without waiting for a binding from the next hop. The advantage is a fast start and independence from ordering; the drawback is possible transient black holes: the upstream has already received a label while the downstream part of the LSP is not yet built, and a labeled packet runs into a dead end. With ordered control a node allocates a label only when it is the egress for the FEC (for example, it is its own loopback) or has already received a binding from the next hop. The LSP is built strictly from egress to ingress, so every allocated label guarantees a working tail. The price is build time: the label travels sequentially through every node, and a break in the middle of the path silences everything upstream. Per documentation, Cisco IOS in frame mode uses independent control and Junos uses ordered; on a platform where the behavior matters it should be checked manually (see review).
Implicit null, explicit null and PHP
The egress for a FEC can issue three variants: implicit null (label 3, PHP: the penultimate LSR pops the label and the egress receives a clean packet), explicit null (label 0 for IPv4, 2 for IPv6: the label stays until the egress and the TC/EXP field is preserved) or non-null (an ordinary label, the LSP ends with an ordinary lookup). Implicit null saves one lookup on the egress, while explicit null is needed for end-to-end QoS classification by TC on the last hop. On Cisco mpls ldp explicit-null can apply to a list of FECs and a list of neighbors, on Junos it is protocols mpls explicit-null, on Huawei label advertise explicit-null in the MPLS view, on MikroTik use-explicit-null=yes.
Who receives which labels: controlling distribution
Labels can be restricted separately for sending (Cisco mpls ldp advertise-labels for <FEC-ACL> to <PEER-ACL>, Junos export policy) and for receiving (accept/import: Cisco inbound label filtering, Junos import, MikroTik accept-filter). This turns into a precise forwarding model: with liberal retention a received label that does not match the next hop stays in the LIB "in reserve". If the required binding is missing on an ordered node, it does not send a label up the chain and the LSP is not built; on an independent node the label exists but the LSP tail is empty and packets are lost. If a distribution restriction is applied by mistake to a FEC needed by a BGP next hop, L3VPN breaks.