RFC 3036

LDP Specification

๐Ÿ“… published January 2001, from ietf

RFC 3036: LDP Specification ๐ŸŽ€

Okay bestie, let's get into it. This is RFC 3036, and it's the LDP Specification ๐Ÿ’–

  • Network Working Group, so it's an IETF doc ๐ŸŒธ
  • Authors: L. Andersson (Nortel Networks Inc.), P. Doolan (Ennovate Networks), N. Feldman (IBM Corp), A. Fredette (PhotonEx Corp), and B. Thomas (Cisco Systems, Inc.) ๐Ÿซถ
  • Category: Standards Track โœจ
  • Date: January 2001 ๐Ÿฆ‹
  • Obsoletes and updates: nothing is listed in this part of the title block ๐Ÿ™ˆ

Status of this Memo ๐Ÿ“

Okay so this document is an Internet standards track protocol spec for the whole Internet community, and it's literally asking people to talk about it and suggest improvements ๐Ÿ’… Go check the current edition of the "Internet Official Protocol Standards" (STD 1) for where this protocol actually stands, because that's the source of truth ๐Ÿ‘‘ And the distribution of this memo is unlimited, so share it with everyone ๐Ÿงš

Copyright (C) The Internet Society (2001). All Rights Reserved. ๐Ÿ”ฅ

Abstract ๐ŸŒˆ

Okay, the big picture ๐Ÿฆ‹ MPLS, which is Multi Protocol Label Switching, has its architecture written up in RFC 3031 โœจ The core idea is that two Label Switching Routers (LSRs) must agree on what the labels mean if they're going to forward traffic between and through each other ๐Ÿซถ That shared understanding comes from a set of procedures called a label distribution protocol, where one LSR tells another about the label bindings it has made ๐Ÿ’…

So this document is the one that defines LDP (for Label Distribution Protocol) ๐ŸŽ€ It's the set of procedures that LSRs use to distribute labels, so MPLS forwarding works along normally routed paths. It's giving "the glue that holds the whole MPLS vibe together" ๐Ÿ’– โœจ

Table of Contents โœจ

Okay bestie, here's the whole map of what's coming up ๐Ÿ—บ๏ธ๐Ÿ’œ

Table of Contents

   1          LDP Overview  .......................................   5
   1.1        LDP Peers  ..........................................   6
   1.2        LDP Message Exchange  ...............................   6
   1.3        LDP Message Structure  ..............................   7
   1.4        LDP Error Handling  .................................   7
   1.5        LDP Extensibility and Future Compatibility  .........   7
   1.6        Specification Language  .............................   7
   2          LDP Operation  ......................................   8
   2.1        FECs  ...............................................   8
   2.2        Label Spaces, Identifiers, Sessions and Transport  ..   9
   2.2.1      Label Spaces  .......................................   9
   2.2.2      LDP Identifiers  ....................................  10
   2.2.3      LDP Sessions  .......................................  10
   2.2.4      LDP Transport  ......................................  11
   2.3        LDP Sessions between non-Directly Connected LSRs  ...  11
   2.4        LDP Discovery   .....................................  11
   2.4.1      Basic Discovery Mechanism  ..........................  12
   2.4.2      Extended Discovery Mechanism  .......................  12
   2.5        Establishing and Maintaining LDP Sessions  ..........  13
   2.5.1      LDP Session Establishment  ..........................  13
   2.5.2      Transport Connection Establishment  .................  13
   2.5.3      Session Initialization  .............................  14
   2.5.4      Initialization State Machine  .......................  17
   2.5.5      Maintaining Hello Adjacencies  ......................  20
   2.5.6      Maintaining LDP Sessions  ...........................  20
   2.6        Label Distribution and Management  ..................  21
   2.6.1      Label Distribution Control Mode  ....................  21
   2.6.1.1    Independent Label Distribution Control  .............  21
   2.6.1.2    Ordered Label Distribution Control  .................  21
   2.6.2      Label Retention Mode  ...............................  22
   2.6.2.1    Conservative Label Retention Mode  ..................  22
   2.6.2.2    Liberal Label Retention Mode  .......................  22
   2.6.3      Label Advertisement Mode  ...........................  23
   2.7        LDP Identifiers and Next Hop Addresses  .............  23
   2.8        Loop Detection  .....................................  24
   2.8.1      Label Request Message  ..............................  24
   2.8.2      Label Mapping Message  ..............................  26
   2.8.3      Discussion  .........................................  27
   2.9        Authenticity and Integrity of LDP Messages  .........  28
   2.9.1      TCP MD5 Signature Option  ...........................  28
   2.9.2      LDP Use of TCP MD5 Signature Option  ................  30
   2.10       Label Distribution for Explicitly Routed LSPs  ......  30
   3          Protocol Specification  .............................  31
   3.1        LDP PDUs  ...........................................  31
   3.2        LDP Procedures  .....................................  32
   3.3        Type-Length-Value Encoding  .........................  32
   3.4        TLV Encodings for Commonly Used Parameters  .........  34
   3.4.1      FEC TLV  ............................................  34
   3.4.1.1    FEC Procedures  .....................................  37
   3.4.2      Label TLVs  .........................................  37
   3.4.2.1    Generic Label TLV  ..................................  37
   3.4.2.2    ATM Label TLV  ......................................  38
   3.4.2.3    Frame Relay Label TLV  ..............................  38
   3.4.3      Address List TLV  ...................................  39
   3.4.4      Hop Count TLV  ......................................  40
   3.4.4.1    Hop Count Procedures  ...............................  40
   3.4.5      Path Vector TLV  ....................................  41
   3.4.5.1    Path Vector Procedures  .............................  42
   3.4.5.1.1  Label Request Path Vector  ..........................  42
   3.4.5.1.2  Label Mapping Path Vector  ..........................  43
   3.4.6      Status TLV  .........................................  43
   3.5        LDP Messages  .......................................  45
   3.5.1      Notification Message  ...............................  47
   3.5.1.1    Notification Message Procedures  ....................  48
   3.5.1.2    Events Signaled by Notification Messages  ...........  49
   3.5.1.2.1  Malformed PDU or Message  ...........................  49
   3.5.1.2.2  Unknown or Malformed TLV  ...........................  50
   3.5.1.2.3  Session KeepAlive Timer Expiration  .................  50
   3.5.1.2.4  Unilateral Session Shutdown  ........................  51
   3.5.1.2.5  Initialization Message Events  ......................  51
   3.5.1.2.6  Events Resulting From Other Messages  ...............  51
   3.5.1.2.7  Internal Errors  ....................................  51
   3.5.1.2.8  Miscellaneous Events  ...............................  51
   3.5.2      Hello Message  ......................................  51
   3.5.2.1    Hello Message Procedures  ...........................  54
   3.5.3      Initialization Message  .............................  55
   3.5.3.1    Initialization Message Procedures  ..................  63
   3.5.4      KeepAlive Message  ..................................  63
   3.5.4.1    KeepAlive Message Procedures  .......................  63
   3.5.5      Address Message  ....................................  64
   3.5.5.1    Address Message Procedures  .........................  64
   3.5.6      Address Withdraw Message  ...........................  65
   3.5.6.1    Address Withdraw Message Procedures  ................  66
   3.5.7      Label Mapping Message  ..............................  66
   3.5.7.1    Label Mapping Message Procedures  ...................  67
   3.5.7.1.1  Independent Control Mapping  ........................  67
   3.5.7.1.2  Ordered Control Mapping  ............................  68
   3.5.7.1.3  Downstream on Demand Label Advertisement  ...........  68
   3.5.7.1.4  Downstream Unsolicited Label Advertisement  .........  69
   3.5.8      Label Request Message  ..............................  69
   3.5.8.1    Label Request Message Procedures  ...................  70
   3.5.9      Label Abort Request Message  ........................  72
   3.5.9.1    Label Abort Request Message Procedures  .............  73
   3.5.10     Label Withdraw Message  .............................  74
   3.5.10.1   Label Withdraw Message Procedures  ..................  75
   3.5.11     Label Release Message  ..............................  76
   3.5.11.1   Label Release Message Procedures  ...................  77
   3.6        Messages and TLVs for Extensibility  ................  78
   3.6.1      LDP Vendor-private Extensions  ......................  78
   3.6.1.1    LDP Vendor-private TLVs  ............................  78
   3.6.1.2    LDP Vendor-private Messages  ........................  80
   3.6.2      LDP Experimental Extensions  ........................  81
   3.7        Message Summary  ....................................  81
   3.8        TLV Summary  ........................................  82
   3.9        Status Code Summary  ................................  83
   3.10       Well-known Numbers  .................................  84
   3.10.1     UDP and TCP Ports  ..................................  84
   3.10.2     Implicit NULL Label  ................................  84
   4          IANA Considerations  ................................  84
   4.1        Message Type Name Space  ............................  84
   4.2        TLV Type Name Space  ................................  85
   4.3        FEC Type Name Space  ................................  85
   4.4        Status Code Name Space  .............................  86
   4.5        Experiment ID Name Space  ...........................  86
   5          Security Considerations  ............................  86
   5.1        Spoofing  ...........................................  86
   5.2        Privacy  ............................................  87
   5.3        Denial of Service  ..................................  87
   6          Areas for Future Study  .............................  89
   7          Intellectual Property Considerations  ...............  89
   8          Acknowledgments  ....................................  89
   9          References  .........................................  89
   10         Authors' Addresses  .................................  92
   Appendix A LDP Label Distribution Procedures  ..................  93
   A.1        Handling Label Distribution Events  .................  95
   A.1.1      Receive Label Request  ..............................  96
   A.1.2      Receive Label Mapping  ..............................  99
   A.1.3      Receive Label Abort Request  ........................ 105
   A.1.4      Receive Label Release  .............................. 107
   A.1.5      Receive Label Withdraw  ............................. 109
   A.1.6      Recognize New FEC  .................................. 110
   A.1.7      Detect Change in FEC Next Hop  ...................... 113
   A.1.8      Receive Notification / Label Request Aborted  ....... 116
   A.1.9      Receive Notification / No Label Resources  .......... 116
   A.1.10     Receive Notification / No Route  .................... 117
   A.1.11     Receive Notification / Loop Detected  ............... 118
   A.1.12     Receive Notification / Label Resources Available  ... 118
   A.1.13     Detect local label resources have become available  . 119
   A.1.14     LSR decides to no longer label switch a FEC  ........ 120
   A.1.15     Timeout of deferred label request  .................. 121
   A.2        Common Label Distribution Procedures  ............... 121
   A.2.1      Send_Label  ......................................... 121
   A.2.2      Send_Label_Request  ................................. 123
   A.2.3      Send_Label_Withdraw  ................................ 124
   A.2.4      Send_Notification  .................................. 125
   A.2.5      Send_Message  ....................................... 125
   A.2.6      Check_Received_Attributes  .......................... 126
   A.2.7      Prepare_Label_Request_Attributes  ................... 127
   A.2.8      Prepare_Label_Mapping_Attributes  ................... 129
   Full Copyright Statement  ...................................... 132

1. LDP Overview โœจ

okay so the MPLS architecture [RFC3031] describes a label distribution protocol as a set of procedures where one Label Switched Router (LSR) tells another what the labels mean. those labels are what get used to forward traffic between and through them ๐Ÿฆ‹

the MPLS architecture does not assume there's just one label distribution protocol. there are actually a bunch being standardized ๐Ÿ’… some existing protocols got extended so label distribution can ride along on them, and some brand new protocols were made for the sole purpose of distributing labels. the architecture also talks about the things you should consider when picking a label distribution protocol for a particular MPLS application, like Traffic Engineering [RFC2702] ๐Ÿงš

the Label Distribution Protocol (LDP) in this document is a new protocol built for distributing labels. it's the set of procedures and messages that Label Switched Routers (LSRs) use to set up Label Switched Paths (LSPs) through a network. the vibe is mapping network-layer routing information directly onto data-link layer switched paths ๐ŸŒธ these LSPs can end at a directly attached neighbor (kind of like IP hop-by-hop forwarding), or they can end at a network egress node, which lets traffic get switched through all the intermediary nodes ๐Ÿ’œ

LDP links a Forwarding Equivalence Class (FEC) [RFC3031] to each LSP it creates. the FEC for an LSP says which packets get "mapped" to that LSP. LSPs stretch across a network because each LSR "splices" the incoming labels for a FEC onto the outgoing label assigned to the next hop for that FEC โœจ

if you want more on where LDP fits, check out [RFC3037] ๐ŸŽ€

this document assumes you already know the MPLS architecture [RFC3031]. just a heads up, [RFC3031] has a glossary of MPLS terminology (ingress, label switched path, and so on) that's super handy ๐Ÿ“–

1.1. LDP Peers

two LSRs that use LDP to swap label/FEC mapping information are called "LDP Peers" for that information, and we say there's an "LDP Session" between them ๐Ÿซถ one LDP session lets each peer learn the other's label mappings. so the protocol goes both ways, bi-directional energy all the way ๐Ÿ”ฅ

1.2. LDP Message Exchange

there are four categories of LDP messages ๐Ÿ‘‘

  1. Discovery messages, used to announce and maintain the presence of an LSR in a network.
  2. Session messages, used to establish, maintain, and terminate sessions between LDP peers.
  3. Advertisement messages, used to create, change, and delete label mappings for FECs.
  4. Notification messages, used to provide advisory information and to signal error information.

discovery messages are how LSRs say "hey, I'm here" in a network, by sending a Hello message periodically ๐Ÿฆ‹ it goes out as a UDP packet to the LDP port, sent to the `all routers on this subnet' group multicast address. when an LSR decides to set up a session with another LSR it found through that Hello message, it uses the LDP initialization procedure over TCP transport. once that initialization finishes successfully, the two LSRs are LDP peers and can swap advertisement messages ๐Ÿ’–

whether to request a label or advertise a label mapping to a peer is mostly a local decision the LSR makes for itself ๐Ÿ’… usually, an LSR requests a label mapping from a neighboring LSR when it needs one, and it advertises a label mapping to a neighbor when it wants that neighbor to use a label โœจ

LDP needs messages to arrive reliably and in order, or everything gets messy ๐Ÿ˜ญ so LDP uses TCP transport for session, advertisement and notification messages. basically that's everything except the UDP-based discovery mechanism ๐ŸŒˆ

1.3. LDP Message Structure

every LDP message has the same basic structure, which uses a Type-Length-Value (TLV) encoding scheme (see Section "Type-Length-Value" encoding). the Value part of a TLV-encoded object, aka a TLV for short, can itself hold one or more TLVs. TLVs inside TLVs, we love a nested queen ๐Ÿ‘‘๐Ÿซถ

1.4. LDP Error Handling

LDP errors and other events worth knowing about get signaled to an LDP peer through notification messages ๐Ÿšจ

there are two kinds of LDP notification messages:

  1. Error notifications, used to signal fatal errors. if an LSR gets an error notification from a peer for an LDP session, it ends that session by closing the TCP transport connection for it and throwing out every label mapping it learned through that session. ngl this one is dramatic ๐Ÿ’€
  2. Advisory notifications, used to pass an LSR information about the LDP session or the status of some previous message it received from the peer ๐ŸŽ€

1.5. LDP Extensibility and Future Compatibility

new functionality might get added to LDP later on ๐Ÿ”ฎ future features will probably use new messages and object types (TLVs). sometimes you'd want to run those new messages and TLVs inside a network that still has older implementations that don't recognize them. it's not possible to make every future enhancement backwards compatible, but a little planning ahead can make new capabilities way easier to roll out ๐ŸŒธ so this specification sets out rules for handling unknown message types and unknown TLVs, just for that reason ๐Ÿงš

1.6. Specification Language

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119] ๐Ÿ“–โœจ

2. LDP Operation ๐ŸŒˆ

2.1. FECs

it's really important to be precise about which packets can get mapped to each LSP ๐Ÿ’… so every LSP gets a FEC specification. the FEC names the set of IP packets that may be mapped to that LSP.

each FEC is written as a set of one or more FEC elements. each FEC element picks out a set of packets that may be mapped to the matching LSP. when several FEC elements share one LSP, that LSP ends at (or before) the node where those FEC elements can no longer share the same path ๐Ÿฆ‹

these are the FEC element types defined right now. new element types may get added whenever they're needed ๐Ÿ‘‘

  1. Address Prefix. this element is an address prefix of any length from 0 to a full address, inclusive.
  2. Host Address. this element is a full host address.

(we'll see below that an Address Prefix FEC element which is a full address does something different from a Host Address FEC element with that same address ๐Ÿ‘€)

we say a particular address "matches" a particular address prefix if and only if that address begins with that prefix. we also say a particular packet matches a particular LSP if and only if that LSP has an Address Prefix FEC element that matches the packet's destination address. for a particular packet and a particular LSP, any Address Prefix FEC element that matches the packet is called the "matching prefix" ๐Ÿ’œ

the procedure for mapping a packet to an LSP follows these rules. each rule gets applied in turn until the packet can be mapped to an LSP ๐Ÿซถ

  • if there is exactly one LSP with a Host Address FEC element identical to the packet's destination address, the packet is mapped to that LSP.
  • if there are multiple LSPs, each with a Host Address FEC element identical to the packet's destination address, the packet is mapped to one of those LSPs. the procedure for choosing one of those LSPs is beyond the scope of this document.
  • if a packet matches exactly one LSP, the packet is mapped to that LSP.
  • if a packet matches multiple LSPs, it's mapped to the LSP whose matching prefix is the longest. if no single LSP has the longest matching prefix, the packet is mapped to one from the set of LSPs whose matching prefix is longer than the others. the procedure for choosing one of those LSPs is beyond the scope of this document.
  • if it's known that a packet must traverse a particular egress router, and there's an LSP with an Address Prefix FEC element that is an address of that router, the packet is mapped to that LSP. the procedure for getting that knowledge is beyond the scope of this document.

the procedure for figuring out that a packet must traverse a particular egress router is beyond the scope of this document. (as an example, if you're running a link state routing algorithm, you might be able to get this info from the link state data base. as another example, if you're running BGP, you might be able to get it from the BGP next hop attribute of the packet's route ๐Ÿง )

some consequences of these rules are worth pointing out ๐Ÿ’…

  • a packet may be sent on the LSP whose Address Prefix FEC element is the address of the packet's egress router ONLY if there is no LSP matching the packet's destination address. ๐Ÿ™ˆ
  • a packet may match two LSPs, one with a Host Address FEC element and one with an Address Prefix FEC element. in that case the packet always gets assigned to the former ๐Ÿ‘‘
  • a packet that does not match a particular Host Address FEC element may not be sent on the corresponding LSP, even if that Host Address FEC element identifies the packet's egress router ๐Ÿ’€

2.2. Label Spaces, Identifiers, Sessions and Transport

2.2.1. Label Spaces

the idea of a "label space" is super useful when you're talking about how labels get assigned and distributed ๐Ÿงš there are two types of label spaces:

  • Per interface label space. interface-specific incoming labels are used for interfaces that use interface resources for labels. examples of these interfaces are a label-controlled ATM interface that uses VCIs as labels, or a Frame Relay interface that uses DLCIs as labels ๐Ÿฆ‹

a per interface label space only makes sense when the LDP peers are "directly connected" over an interface, and the label is only going to be used for traffic sent over that interface ๐ŸŒธ

  • Per platform label space. platform-wide incoming labels are used for interfaces that can share the same labels ๐Ÿ’–

2.2.2. LDP Identifiers

an LDP identifier is a six octet quantity used to identify an LSR label space ๐Ÿ”ฅ the first four octets identify the LSR and must be a globally unique value, such as a 32-bit router Id assigned to the LSR. the last two octets identify a specific label space inside the LSR. for platform-wide label spaces, the last two octets of the LDP Identifier are always both zero ๐ŸŒˆ this document uses the following print representation for LDP Identifiers:

<LSR Id> : <label space id>

e.g., lsr171:0, lsr19:2 ๐ŸŽ€

note that an LSR that manages and advertises multiple label spaces uses a different LDP Identifier for each one ๐Ÿ‘‘

one situation where an LSR would need to advertise more than one label space to a peer, and so use more than one LDP Identifier, is when the LSR has two links to the peer and both are ATM (and use per interface labels) ๐Ÿ’… another situation would be where the LSR has two links to the peer, one of which is ethernet (and uses per platform labels) and the other of which is ATM โœจ

2.2.3. LDP Sessions โœจ

okay so LDP sessions exist between LSRs so they can swap labels with each other ๐Ÿ’– literally that's the whole vibe

When an LSR uses LDP to advertise more than one label space to another LSR, it uses a separate LDP session for each label space. ๐ŸŽ€

2.2.4. LDP Transport ๐Ÿฆ‹

LDP uses TCP as its reliable transport for sessions. TCP is giving dependable, no drama ๐Ÿ’…

When multiple LDP sessions are required between two LSRs, there is one TCP session for each LDP session. ๐ŸŒธ

2.3. LDP Sessions between non-Directly Connected LSRs ๐Ÿงš

ngl LDP sessions between LSRs that aren't directly connected at the link level can be super useful in some situations ๐Ÿ‘‘

picture a "traffic engineering" app. LSRa wants to send certain traffic over an LSP to LSRb, which is not directly connected to it, instead of letting that traffic follow its usual routed path. iconic move ๐Ÿ˜ญ

The path between LSRa and LSRb goes through one or more middle LSRs (LSR1,...LSRn). An LDP session between LSRa and LSRb lets LSRb label switch the traffic that shows up on the LSP from LSRa, because LSRb can advertise labels for this purpose to LSRa. ๐Ÿซถ

So in this setup LSRa puts two labels on the traffic it forwards on the LSP to LSRb:

  • a label learned from LSR1, used to forward the traffic along the LSP path from LSRa to LSRb; and
  • a label learned from LSRb, which lets LSRb label switch the traffic arriving on the LSP.

Here's the order of operations, bestie ๐Ÿ’œ LSRa first adds the label it learned through its LDP session with LSRb to the packet label stack. If the packet arrives already labeled, that label goes in by replacing the label on top of the stack. If the packet arrives unlabeled, it gets pushed on. Then LSRa pushes the label for the LSP, the one learned from LSR1, onto the label stack. ๐ŸŽ€

2.4. LDP Discovery ๐Ÿ”ฅ

LDP discovery is the mechanism that lets an LSR find potential LDP peers. The best part is that it means nobody has to manually configure an LSR's label switching peers. no more typing them all in by hand ๐Ÿ™Œ

There are two variants of the discovery mechanism:

  • A basic discovery mechanism, used to find LSR neighbors that are directly connected at the link level.
  • An extended discovery mechanism, used to locate LSRs that are not directly connected at the link level.

2.4.1. Basic Discovery Mechanism ๐ŸŒˆ

To do LDP Basic Discovery on an interface, an LSR periodically sends LDP Link Hellos out that interface. LDP Link Hellos are sent as UDP packets addressed to the well-known LDP discovery port for the "all routers on this subnet" group multicast address. ๐Ÿ“ก

An LDP Link Hello that an LSR sends carries the LDP Identifier for the label space the LSR plans to use for the interface, and possibly some extra info too โœจ

When an LDP Link Hello arrives on an interface, it identifies a "Hello adjacency" with a potential LDP peer that's reachable at the link level on that interface. It also tells you which label space the peer plans to use for the interface. main character energy for discovery ๐Ÿ’…

2.4.2. Extended Discovery Mechanism ๐Ÿฆ‹

LDP sessions between non-directly connected LSRs are supported by LDP Extended Discovery. ๐Ÿซถ

To do LDP Extended Discovery, an LSR periodically sends LDP Targeted Hellos to a specific address. LDP Targeted Hellos are sent as UDP packets addressed to the well-known LDP discovery port at that specific address. ๐ŸŽฏ

An LDP Targeted Hello that an LSR sends carries the LDP Identifier for the label space the LSR intends to use, and possibly additional optional information. ๐Ÿงš

Extended Discovery is different from Basic Discovery in a few ways:

  • A Targeted Hello is sent to a specific address, instead of to the "all routers" group multicast address for the outgoing interface.
  • Basic Discovery is symmetric, but Extended Discovery is asymmetric. One LSR starts Extended Discovery with another targeted LSR, and the targeted LSR decides whether to respond to or ignore the Targeted Hello. A targeted LSR that chooses to respond does so by periodically sending Targeted Hellos back to the initiating LSR. ๐Ÿ‘€

When an LDP Targeted Hello arrives, it identifies a "Hello adjacency" with a potential LDP peer that's reachable at the network level, along with the label space the peer intends to use. ๐Ÿ’œ

2.5. Establishing and Maintaining LDP Sessions ๐Ÿ’–

2.5.1. LDP Session Establishment ๐ŸŽ€

The exchange of LDP Discovery Hellos between two LSRs is what triggers LDP session establishment. Session establishment is a two step process:

  • Transport connection establishment.
  • Session initialization.

Here's the setup for this part: we're looking at how an LDP session gets established between LSR1 and LSR2, from LSR1's point of view. It assumes the Hellos have been exchanged, with LSR1 using label space LSR1:a and LSR2 using label space LSR2:b. ๐ŸŒธ

2.5.2. Transport Connection Establishment ๐Ÿ”ฅ

The exchange of Hellos creates a Hello adjacency at LSR1. That adjacency binds the link (L) and the label spaces LSR1:a and LSR2:b together ๐Ÿ”—

  1. If LSR1 doesn't already have an LDP session for exchanging label spaces LSR1:a and LSR2:b, it tries to open a TCP connection for a new LDP session with LSR2.

LSR1 figures out the transport addresses for its end (A1) and LSR2's end (A2) of the LDP TCP connection. Address A1 is worked out like this:

a. If LSR1 uses the Transport Address optional object (TLV) in the Hellos it sends to LSR2 to advertise an address, then A1 is the address LSR1 advertises through that optional object;

b. If LSR1 doesn't use the Transport Address optional object, then A1 is the source address used in the Hellos it sends to LSR2.

Address A2 is figured out in a similar way:

a. If LSR2 uses the Transport Address optional object, then A2 is the address LSR2 advertises through that optional object;

b. If LSR2 doesn't use the Transport Address optional object, then A2 is the source address in the Hellos received from LSR2.

  1. LSR1 decides whether it plays the active or passive role in session establishment by comparing addresses A1 and A2 as unsigned integers. If A1 > A2, LSR1 plays the active role. Otherwise, it's passive. ๐Ÿซถ

The procedure for comparing A1 and A2 as unsigned integers goes like this:

  • If A1 and A2 aren't in the same address family, they're incomparable, and no session can be established. ๐Ÿ’€
  • Let U1 be the abstract unsigned integer you get by treating A1 as a sequence of bytes. The byte that shows up earliest in the message is the most significant byte of the integer, and the byte that shows up latest is the least significant byte.

Let U2 be the abstract unsigned integer you get from A2 in a similar way.

  • Compare U1 with U2. If U1 > U2, then A1 > A2. If U1 < U2, then A1 < A2. โœจ
  1. If LSR1 is active, it tries to set up the LDP TCP connection by connecting to the well-known LDP port at address A2. If LSR1 is passive, it waits for LSR2 to set up the LDP TCP connection to its well-known LDP port. ๐Ÿงš

Quick note, because it matters ๐Ÿ‘€ When an LSR sends a Hello, it picks the transport address for its end of the session connection. It advertises that address in one of two ways: either explicitly, by including it in an optional Transport Address TLV, or implicitly, by leaving out the TLV and using the address as the Hello source address.

An LSR MUST advertise the same transport address in all Hellos that advertise the same label space. This requirement makes sure that two LSRs linked by multiple Hello adjacencies using the same label spaces play the same connection establishment role for each adjacency. ๐Ÿ”’๐Ÿ’…

2.5.3. Session Initialization โœจ

okay so once LSR1 and LSR2 have their transport connection up, they negotiate session parameters by swapping LDP Initialization messages ๐Ÿ’Œ The stuff they agree on includes the LDP protocol version, the label distribution method, timer values, VPI/VCI ranges for label controlled ATM, DLCI ranges for label controlled Frame Relay, etc. ๐ŸŽ€

When the negotiation succeeds, the LDP session between LSR1 and LSR2 is officially set up for advertising label spaces LSR1:a and LSR2:b ๐Ÿฆ‹

Here's the session initialization from LSR1's point of view ๐Ÿ‘€

After the connection is established, if LSR1 is playing the active role, it kicks off the negotiation by sending an Initialization message to LSR2. if LSR1 is passive, it just waits for LSR2 to start the parameter negotiation ๐Ÿงš

Now the tricky part ๐Ÿ˜ญ If there are multiple links between LSR1 and LSR2, and each one has multiple label spaces to advertise, the passive LSR has no way of knowing which label space to use on a brand new TCP connection until the LDP Initialization message actually shows up. That message carries both the LDP Identifier for the sender's (active LSR's) label space and the LDP Identifier for the receiver's (passive LSR's) label space.

So the passive LSR waits for that Initialization message, then matches the peer's label space (based on the LDP Identifier in the PDU header of the Initialization message) with a Hello adjacency that was already made when the Hellos got exchanged. ๐Ÿ’…

  1. When LSR1 plays the passive role:
    • a. If LSR1 receives an Initialization message, it tries to match the LDP Identifier carried by the message PDU with a Hello adjacency.
    • b. If there's a matching Hello adjacency, the adjacency specifies the local label space for the session.

Next, LSR1 checks whether the session parameters proposed in the message are acceptable. If they are, LSR1 replies with an Initialization message of its own to propose the parameters it wants to use, plus a KeepAlive message to signal that it accepts LSR2's parameters. If the parameters are not acceptable, LSR1 responds by sending a Session Rejected/Parameters Error Notification message and closing the TCP connection. ๐Ÿ™…โ€โ™€๏ธ

  • c. If LSR1 cannot find a matching Hello adjacency, it sends a Session Rejected/No Hello Error Notification message and closes the TCP connection.
  • d. If LSR1 receives a KeepAlive in response to its Initialization message, the session is operational from LSR1's point of view. ๐Ÿ”ฅ
  • e. If LSR1 receives an Error Notification message, LSR2 has rejected its proposed session, and LSR1 closes the TCP connection.
  1. When LSR1 plays the active role:
    • a. If LSR1 receives an Error Notification message, LSR2 has rejected its proposed session, and LSR1 closes the TCP connection.
    • b. If LSR1 receives an Initialization message, it checks whether the session parameters are acceptable. If so, it replies with a KeepAlive message. If the session parameters are unacceptable, LSR1 sends a Session Rejected/Parameters Error Notification message and closes the connection.
    • c. If LSR1 receives a KeepAlive message, LSR2 has accepted its proposed session parameters. ๐Ÿฅน
    • d. When LSR1 has received both an acceptable Initialization message and a KeepAlive message, the session is operational from LSR1's point of view. ๐Ÿ‘‘

It's possible for a pair of incompatibly configured LSRs that disagree on session parameters to get stuck in an endless sequence of messages, with each one NAKing the other's Initialization messages using Error Notification messages. ๐Ÿ’€

An LSR MUST throttle its session setup retry attempts with an exponential backoff whenever Initialization messages are getting NAK'd. It is also RECOMMENDED that an LSR that detects such a situation take action to notify an operator. ๐Ÿšจ

The session establishment setup attempt that follows a NAK'd Initialization message MUST be delayed by no less than 15 seconds, and subsequent delays MUST grow to a maximum delay of no less than 2 minutes. The specific session establishment action that MUST be delayed is the attempt, by the LSR playing the active role, to open the session transport connection. โณ

The throttled sequence of Initialization NAKs is unlikely to stop until an operator reconfigures one of the LSRs. After that configuration action, there's no further need to throttle subsequent session establishment attempts (until their Initialization messages get NAK'd). ๐Ÿงน

Because session establishment is asymmetric, reconfiguring the passive LSR will go unnoticed by the active LSR unless some further action is taken. Section "Hello Message" describes an optional mechanism an LSR can use to signal potential LDP peers that it has been reconfigured. ๐Ÿ“ฃ

2.5.4. Initialization State Machine ๐Ÿง 

It's convenient to describe LDP session negotiation behavior in terms of a state machine. We define the LDP state machine to have five possible states, and we present the behavior as a state transition table and as a state transition diagram. ๐Ÿฆ‹

               Session Initialization State Transition Table

      STATE         EVENT                               NEW STATE

      NON EXISTENT  Session TCP connection established  INITIALIZED
                    established

      INITIALIZED   Transmit Initialization msg         OPENSENT
                          (Active Role)

                    Receive acceptable                  OPENREC
                          Initialization msg
                          (Passive Role )
                      Action: Transmit Initialization
                              msg and KeepAlive msg

                    Receive Any other LDP msg           NON EXISTENT
                      Action: Transmit Error Notification msg
                              (NAK) and close transport connection

      OPENREC       Receive KeepAlive msg               OPERATIONAL

                    Receive Any other LDP msg           NON EXISTENT
                      Action: Transmit Error Notification msg
                              (NAK) and close transport connection

      OPENSENT      Receive acceptable                  OPENREC
                          Initialization msg
                      Action: Transmit KeepAlive msg

                    Receive Any other LDP msg           NON EXISTENT
                      Action: Transmit Error Notification msg
                              (NAK) and close transport connection

      OPERATIONAL   Receive Shutdown msg                NON EXISTENT
                      Action: Transmit Shutdown msg and
                              close transport connection

                    Receive other LDP msgs              OPERATIONAL

                    Timeout                             NON EXISTENT
                      Action: Transmit Shutdown msg and
                              close transport connection
               Session Initialization State Transition Diagram

                                 +------------+
                                 |            |
                   +------------>|NON EXISTENT|<--------------------+
                   |             |            |                     |
                   |             +------------+                     |
                   | Session        |    ^                          |
                   |   connection   |    |                          |
                   |   established  |    | Rx any LDP msg except    |
                   |                V    |   Init msg or Timeout    |
                   |            +-----------+                       |
      Rx Any other |            |           |                       |
         msg or    |            |INITIALIZED|                       |
         Timeout / |        +---|           |-+                     |
      Tx NAK msg   |        |   +-----------+ |                     |
                   |        | (Passive Role)  | (Active Role)       |
                   |        | Rx Acceptable   | Tx Init msg         |
                   |        |    Init msg /   |                     |
                   |        | Tx Init msg     |                     |
                   |        |    Tx KeepAlive |                     |
                   |        V    msg          V                     |
                   |   +-------+        +--------+                  |
                   |   |       |        |        |                  |
                   +---|OPENREC|        |OPENSENT|----------------->|
                   +---|       |        |        | Rx Any other msg |
                   |   +-------+        +--------+    or Timeout    |
      Rx KeepAlive |        ^                |     Tx NAK msg       |
         msg       |        |                |                      |
                   |        |                | Rx Acceptable        |
                   |        |                |    Init msg /        |
                   |        +----------------+ Tx KeepAlive msg     |
                   |                                                |
                   |      +-----------+                             |
                   +----->|           |                             |
                          |OPERATIONAL|                             |
                          |           |---------------------------->+
                          +-----------+     Rx Shutdown msg
                   All other  |   ^            or Timeout /
                     LDP msgs |   |         Tx Shutdown msg
                              |   |
                              +---+

2.5.5. Maintaining Hello Adjacencies ๐ŸŒธ

An LDP session with a peer has one or more Hello adjacencies. ๐Ÿ’–

An LDP session has multiple Hello adjacencies when a pair of LSRs is connected by multiple links that share the same label space. For example, that happens with multiple PPP links between a pair of routers. In this situation, the Hellos an LSR sends on each of those links carry the same LDP Identifier. ๐Ÿ”—

LDP includes mechanisms for monitoring whether an LDP session and its Hello adjacencies are still needed. ๐Ÿ”

LDP uses the regular receipt of LDP Discovery Hellos to indicate a peer's intent to use the label space identified by the Hello. An LSR keeps a hold timer with each Hello adjacency, and it restarts that timer whenever it receives a Hello that matches the adjacency. If the timer expires without a matching Hello arriving from the peer, LDP concludes that the peer no longer wants to label switch using that label space for that link (or target, in the case of Targeted Hellos), or that the peer has failed. The LSR then deletes the Hello adjacency. ๐Ÿฅ€

When the last Hello adjacency for an LDP session is deleted, the LSR terminates the LDP session by sending a Notification message and closing the transport connection. ๐Ÿšช

2.5.6. Maintaining LDP Sessions ๐Ÿฆ‹

okay so LDP has a whole checkup system to make sure the session is still alive ๐Ÿฉบ it's giving "are you still there?" energy

LDP uses the regular receipt of LDP PDUs on the session transport connection to monitor the integrity of the session. An LSR keeps a KeepAlive timer for each peer session, and it resets that timer whenever it gets an LDP PDU from the session peer. If the KeepAlive timer expires without receiving an LDP PDU from the peer, the LSR concludes that the transport connection is bad or that the peer has failed, and it terminates the LDP session by closing the transport connection ๐Ÿ’€

After an LDP session has been established, an LSR must arrange that its peer receives an LDP PDU from it at least every KeepAlive time period, so the peer restarts the session KeepAlive timer โœจ The LSR may send any protocol message to meet this requirement. In circumstances where an LSR has no other information to share with its peer, it sends a KeepAlive message ๐Ÿ’–

An LSR may choose to terminate an LDP session with a peer at any time. If it does, it tells the peer with a Shutdown message ๐Ÿซถ

2.6. Label Distribution and Management ๐ŸŽ€

okay so the MPLS architecture [RF3031] lets an LSR hand out a FEC label binding when another LSR explicitly asks for it. This is called Downstream On Demand label distribution ๐Ÿ™‹โ€โ™€๏ธ It also lets an LSR send label bindings to LSRs that never asked. [RFC3031] calls this Unsolicited Downstream, but this document calls it Downstream Unsolicited ๐ŸŒธ

Both of these techniques can be used in the same network at the same time ๐Ÿฆ‹ However, for any given LDP session, each LSR must be aware of the label distribution method its peer is using, so that one peer using Downstream Unsolicited label distribution doesn't assume its peer is doing the same thing ๐Ÿ˜ญ See Section "Downstream on Demand label Advertisement".

2.6.1. Label Distribution Control Mode ๐Ÿง 

how an LSP gets set up at the start depends on whether the LSR is running independent or ordered LSP control. An LSR may support both types of control as a configurable option โš™๏ธ

2.6.1.1. Independent Label Distribution Control โœจ

with independent LSP control, each LSR can advertise label mappings to its neighbors whenever it wants ๐Ÿƒโ€โ™€๏ธ For example, in independent Downstream on Demand mode, an LSR can answer requests for label mappings right away, without waiting for a label mapping from the next hop. In independent Downstream Unsolicited mode, an LSR can advertise a label mapping for a FEC to its neighbors whenever it's ready to label-switch that FEC ๐Ÿ”ฅ

A consequence of independent mode is that an upstream label can be advertised before a downstream label is received ๐Ÿซ 

2.6.1.2. Ordered Label Distribution Control ๐Ÿ“‹

with LSP ordered control, an LSR may start sending a label mapping only for a FEC where it already has a label mapping for the FEC's next hop, or where the LSR is the egress. For each FEC where the LSR is not the egress and no mapping exists, the LSR MUST wait until it receives a label from a downstream LSR before mapping the FEC and passing the corresponding labels to upstream LSRs ๐Ÿšฆ An LSR can be an egress for some FECs and a non-egress for others ๐Ÿ‘‘ An LSR may act as an egress LSR, for a particular FEC, under any of the following conditions:

  1. The FEC refers to the LSR itself (including one of its directly attached interfaces).
  2. The next hop router for the FEC is outside of the Label Switching Network.
  3. FEC elements are reachable by crossing a routing domain boundary, such as another area for OSPF summary networks, or another autonomous system for OSPF AS externals and BGP routes [RFC2328] [RFC1771].

Note that whether an LSR is an egress for a given FEC can change over time, depending on the state of the network and the LSR's configuration settings ๐ŸŒˆ

2.6.2. Label Retention Mode ๐Ÿงบ

the MPLS architecture [RFC3031] brings in the idea of label retention mode, which says whether an LSR keeps a label binding for a FEC it learned from a neighbor that isn't its next hop for that FEC ๐Ÿซฃ

2.6.2.1. Conservative Label Retention Mode ๐ŸŒฟ

in Downstream Unsolicited advertisement mode, label mapping advertisements for all routes may be received from all peer LSRs. With conservative label retention, advertised label mappings are kept only if they'll be used to forward packets (that is, if they came from a valid next hop according to routing). If operating in Downstream on Demand mode, an LSR will request label mappings only from the next hop LSR according to routing. Since Downstream on Demand mode is mainly used when label conservation matters (for example, an ATM switch with limited cross connect space), it's typically paired with conservative label retention ๐ŸŽ€

the big win of conservative mode is that only the labels needed for forwarding data get allocated and maintained ๐Ÿ’… This matters a lot on LSRs where the label space is inherently limited, like an ATM switch. The downside is that if routing changes the next hop for a destination, a new label has to be obtained from the new next hop before labeled packets can be forwarded ๐Ÿ˜ค

2.6.2.2. Liberal Label Retention Mode ๐Ÿ“

in Downstream Unsolicited advertisement mode, label mapping advertisements for all routes may be received from all LDP peers. With liberal label retention, every label mapping received from a peer LSR is kept, no matter whether the LSR is the next hop for the advertised mapping ๐Ÿงƒ When operating in Downstream on Demand mode with liberal label retention, an LSR might choose to request label mappings for all known prefixes from all peer LSRs. Note, though, that Downstream on Demand mode is typically used by devices like ATM switch-based LSRs, for which the conservative approach is recommended ๐Ÿ™ˆ

the main perk of liberal mode is that reacting to routing changes can be quick, because the labels already exist โšก The main drawback is that unneeded label mappings get distributed and maintained ๐Ÿฅฒ

2.6.3. Label Advertisement Mode ๐Ÿ“ฃ

each interface on an LSR is configured to operate in either Downstream Unsolicited or Downstream on Demand advertisement mode ๐ŸŽง LSRs exchange advertisement modes during initialization. The big difference between Downstream Unsolicited and Downstream on Demand is which LSR takes responsibility for starting mapping requests and mapping advertisements ๐Ÿ’œ

2.7. LDP Identifiers and Next Hop Addresses ๐Ÿ—บ๏ธ

an LSR keeps the labels it learns in a Label Information Base (LIB) ๐Ÿ“š In Downstream Unsolicited mode, the LIB entry for an address prefix links a collection of (LDP Identifier, label) pairs to that prefix, with one pair for each peer advertising a label for the prefix ๐Ÿซถ

When the next hop for a prefix changes, the LSR has to pull the label advertised by the new next hop out of the LIB so it can use it for forwarding ๐Ÿƒโ€โ™€๏ธ To do that, the LSR has to be able to map the next hop address for the prefix to an LDP Identifier ๐Ÿ”

Similarly, when the LSR learns a label for a prefix from an LDP peer, it needs to figure out whether that peer is currently a next hop for the prefix. That tells it whether to start using the newly learned label when forwarding packets that match the prefix ๐Ÿค” To make that call, the LSR has to be able to map an LDP Identifier to the peer's addresses and check whether any of them is a next hop for the prefix ๐Ÿงฉ

So LSRs can map between a peer's LDP identifier and the peer's addresses, LSRs advertise their addresses using LDP Address and Withdraw Address messages ๐Ÿ“ฎ

An LSR sends an Address message to advertise its addresses to a peer. An LSR sends a Withdraw Address message to withdraw previously advertised addresses from a peer ๐Ÿซก

2.8. Loop Detection ๐Ÿ”

Loop detection is a configurable option that gives LSRs a way to find looping LSPs and to stop Label Request messages from looping when non-merge capable LSRs are involved ๐Ÿ•ต๏ธโ€โ™€๏ธ

The mechanism uses Path Vector and Hop Count TLVs carried by Label Request and Label Mapping messages. It builds on these basic properties of the TLVs:

  • A Path Vector TLV contains a list of the LSRs that its containing message has traversed. An LSR is identified in a Path Vector list by its unique LSR Identifier (Id), which is the first four octets of its LDP Identifier. When an LSR propagates a message containing a Path Vector TLV, it adds its LSR Id to the Path Vector list. An LSR that receives a message with a Path Vector containing its LSR Id detects that the message has traversed a loop ๐Ÿšจ LDP supports the notion of a maximum allowable Path Vector length. An LSR that detects a Path Vector has reached the maximum length behaves as if the containing message has traversed a loop.
  • A Hop Count TLV contains a count of the LSRS that the containing message has traversed. When an LSR propagates a message containing a Hop Count TLV, it increments the count. An LSR that detects a Hop Count has reached a configured maximum value behaves as if the containing message has traversed a loop. By convention, a count of 0 is interpreted to mean the hop count is unknown. Incrementing an unknown hop count value results in an unknown hop count value (0) ๐Ÿ”ข

The following paragraphs describes LDP loop detection procedures. For these paragraphs, and only these paragraphs, "MUST" is redefined to mean "MUST if configured for loop detection". The paragraphs specify messages that must carry Path Vector and Hop Count TLVs. Note that the Hop Count TLV and its procedures are used without the Path Vector TLV in situations when loop detection is not configured (see [RFC3035] and [RFC3034]) ๐ŸŒธ

2.8.1. Label Request Message

Okay bestie, this is the bit that keeps Label Request messages from going in circles forever ๐ŸŒ€ The Path Vector TLV and Hop Count TLV together stop them from looping, even in environments with non-merge capable LSRs ๐Ÿ’…

Here's how LSR R has to use the Hop Count TLV in Label Request messages when Loop Detection is turned on โœจ

  • The Label Request message MUST include a Hop Count TLV.
  • If R is sending the Label Request because it is a FEC ingress, it MUST include a Hop Count TLV with hop count value 1.
  • If R is sending the Label Request because it got one from an upstream LSR, and the received Label Request has a Hop Count TLV, R MUST increment the received hop count value by 1 and MUST pass the resulting value in a Hop Count TLV to its next hop along with the Label Request message.

Now the Path Vector TLV rules for LSR R when Loop Detection is on ๐Ÿฆ‹

  • If R is sending the Label Request because it is a FEC ingress, then if R is non-merge capable, it MUST include a Path Vector TLV of length 1 containing its own LSR Id.
  • If R is sending the Label Request because it got one from an upstream LSR, then if the received Label Request contains a Path Vector TLV or if R is non-merge capable:
    • R MUST add its own LSR Id to the Path Vector, and MUST pass the resulting Path Vector to its next hop along with the Label Request message. If the Label Request contains no Path Vector TLV, R MUST include a Path Vector TLV of length 1 containing its own LSR Id.

Also, heads up ๐Ÿ‘€ If R gets a Label Request for a particular FEC, and R already sent a Label Request for that same FEC to its next hop and hasn't got a reply yet, and R plans to merge the new one with the outstanding one, then R does NOT pass the Label Request on to the next hop ๐ŸŒธ

If R gets a Label Request from its next hop with a Hop Count TLV that goes over the configured maximum value, or with a Path Vector TLV that contains its own LSR Id or is longer than the maximum allowable length, then R knows the Label Request has traveled in a loop ๐Ÿ˜ญ

When R detects a loop, it MUST send a Loop Detected Notification message to the source of the Label Request message and drop the Label Request message. No drama, just a clean exit ๐Ÿซถ

2.8.2. Label Mapping Message

The Path Vector TLV and Hop Count TLV in the Label Mapping message are how we find and shut down looping LSPs ๐Ÿ” When an LSR gets a Label Mapping message from a next hop, the message keeps getting passed upstream (as described below) until it reaches an ingress LSR or a loop is caught ๐Ÿงš

Here's how an LSR R uses the Hop Count TLV in Label Mapping messages when Loop Detection is enabled โœจ

  • R MUST include a Hop Count TLV.
  • If R is the egress, the hop count value MUST be 1.
  • If the Label Mapping message is being sent to pass along a Label Mapping message from the next hop to an upstream peer, the hop count value MUST be worked out like this:
    • If R is a member of the edge set of an LSR domain whose LSRs do not perform 'TTL-decrement' (for example, an ATM LSR domain or a Frame Relay LSR domain) and the upstream peer is inside that domain, R MUST reset the hop count to 1 before passing the message on ๐ŸŽ€
    • Otherwise, R MUST increment the hop count received from the next hop before passing the message on ๐Ÿ’–
  • If the Label Mapping message is NOT being sent to pass along a Label Mapping message, the hop count value MUST be the result of incrementing R's current knowledge of the hop count learned from previous Label Mapping messages. Note that this hop count value will be unknown if R has not received a Label Mapping message from the next hop ๐Ÿ™ˆ

Any Label Mapping message MAY contain a Path Vector TLV ๐ŸŒˆ The rules for when it's mandatory for LSR R (with Loop Detection enabled) are these:

  • If R is the egress, the Label Mapping message need not include a Path Vector TLV.
  • If R is sending the Label Mapping message to pass along a Label Mapping message from the next hop to an upstream peer, then:
    • If R is merge capable and R has not previously sent a Label Mapping message to that upstream peer, then it MUST include a Path Vector TLV.
    • If the received message contains an unknown hop count, then R MUST include a Path Vector TLV.
    • If R has previously sent a Label Mapping message to that upstream peer, then it MUST include a Path Vector TLV if the received message reports an LSP hop count increase, a change in hop count from unknown to known, or a change from known to unknown.

If the rules above say R has to include a Path Vector TLV in the Label Mapping message, R works it out like this ๐Ÿงฎ

  • If the received Label Mapping message included a Path Vector, the Path Vector sent upstream MUST be the result of adding R's LSR Id to the received Path Vector.
  • If the received message had no Path Vector, the Path Vector sent upstream MUST be a path vector of length 1 containing R's LSR Id.
  • If the Label Mapping message is NOT being sent to pass along a received message upstream, the Label Mapping message MUST include a Path Vector of length 1 containing R's LSR Id.

If R gets a Label Mapping message from its next hop with a Hop Count TLV that goes over the configured maximum value, or with a Path Vector TLV that contains its own LSR Id or is longer than the maximum allowable length, then R knows the corresponding LSP has a loop ๐Ÿšจ

When R detects a loop, it MUST stop using the label for forwarding, drop the Label Mapping message, and signal Loop Detected status to the source of the Label Mapping message. Stop the loop before it starts, periodt ๐Ÿ’…

2.8.3. Discussion

If you want loop detection in an MPLS domain, it should be turned on in ALL LSRs within that MPLS domain ๐Ÿซถ Otherwise loop detection won't work properly and you could end up with undetected loops or falsely detected ones. Yikes ๐Ÿ˜ฌ

LSRs that are configured for loop detection are NOT expected to store the path vectors as part of the LSP state ๐Ÿง 

Heads up: in a network where only non-merge capable LSRs are present, Path Vectors get passed downstream from ingress to egress, and they are NOT passed upstream ๐ŸŒŠ Even when merge is supported, Path Vectors don't need to be passed upstream along an LSP that is known to reach the egress ๐Ÿฆ‹ When an LSR experiences a change of next hop, it only needs to pass Path Vectors upstream when it can't tell from the hop count that the change of next hop doesn't result in a loop ๐Ÿ”„

With ordered label distribution, Label Mapping messages travel from egress toward ingress, and the Path Vector gets built naturally along the way ๐ŸŒธ With independent label distribution, an LSR may originate a Label Mapping message for an FEC before it gets a Label Mapping message from its downstream peer for that FEC. In that case, the later Label Mapping message for that FEC from the downstream peer is treated as an update to LSP attributes, and it must be passed upstream. So it is recommended that loop detection be configured together with ordered label distribution, to cut down on the number of Label Mapping update messages โœจ


2.9. Authenticity and Integrity of LDP Messages

This section lays out a mechanism to protect against spoofed TCP segments getting injected into LDP session connection streams ๐Ÿ›ก๏ธ Using this mechanism MUST be supported as a configurable option. Non-negotiable, bestie ๐Ÿ”

The mechanism is based on the TCP MD5 Signature Option specified in [RFC2385] for use by BGP. See [RFC1321] for a specification of the MD5 hash function ๐Ÿง

2.9.1. TCP MD5 Signature Option

Here's what [RFC2385] itself says about the security properties and how the option works. These are direct quotes, no cap ๐Ÿ“œ

   "IESG Note

      This document describes current existing practice for securing
      BGP against certain simple attacks.  It is understood to have
      security weaknesses against concerted attacks."

   "Abstract

      This memo describes a TCP extension to enhance security for
      BGP.  It defines a new TCP option for carrying an MD5 [RFC1321]
      digest in a TCP segment.  This digest acts like a signature for
      that segment, incorporating information known only to the
      connection end points.  Since BGP uses TCP as its transport,
      using this option in the way described in this paper
      significantly reduces the danger from certain security attacks
      on BGP."

   "Introduction

      The primary motivation for this option is to allow BGP to
      protect itself against the introduction of spoofed TCP segments
      into the connection stream.  Of particular concern are TCP
      resets.

      To spoof a connection using the scheme described in this paper,
      an attacker would not only have to guess TCP sequence numbers,
      but would also have had to obtain the password included in the
      MD5 digest.  This password never appears in the connection
      stream, and the actual form of the password is up to the
      application.  It could even change during the lifetime of a
      particular connection so long as this change was synchronized
      on both ends (although retransmission can become problematical
      in some TCP implementations with changing passwords).

      Finally, there is no negotiation for the use of this option in
      a connection, rather it is purely a matter of site policy
      whether or not its connections use the option."

   "MD5 as a Hashing Algorithm

      Since this memo was first issued (under a different title), the
      MD5 algorithm has been found to be vulnerable to collision
      search attacks [Dobb], and is considered by some to be
      insufficiently strong for this type of application.

      This memo still specifies the MD5 algorithm, however, since the
      option has already been deployed operationally, and there was
      no "algorithm type" field defined to allow an upgrade using the
      same option number.  The original document did not specify a
      type field since this would require at least one more byte, and
      it was felt at the time that taking 19 bytes for the complete
      option (which would probably be padded to 20 bytes in TCP
      implementations) would be too much of a waste of the already
      limited option space.

      This does not prevent the deployment of another similar option
      which uses another hashing algorithm (like SHA-1).  Also, if
      most implementations pad the 18 byte option as defined to 20
      bytes anyway, it would be just as well to define a new option
      which contains an algorithm type field.

      This would need to be addressed in another document, however."

End of quotes from [RFC2385].

2.9.2. LDP Use of TCP MD5 Signature Option โœจ

okay so here's how LDP uses the TCP MD5 Signature Option ๐Ÿ”

  • Using the MD5 Signature Option for LDP TCP connections is a configurable LSR option. ๐Ÿ’…
  • An LSR that uses the MD5 Signature Option is configured with a password (shared secret) for each potential LDP peer. ๐Ÿ—๏ธ
  • The LSR applies the MD5 algorithm as specified in [RFC2385] to compute the MD5 digest for a TCP segment to be sent to a peer. This computation makes use of the peer password as well as the TCP segment. ๐Ÿงฎ
  • When the LSR receives a TCP segment with an MD5 digest, it validates the segment by calculating the MD5 digest (using its own record of the password) and compares the computed digest with the received digest. If the comparison fails, the segment is dropped without any response to the sender. ๐Ÿ’€
  • The LSR ignores LDP Hellos from any LSR for which a password has not been configured. This ensures that the LSR establishes LDP TCP connections only with LSRs for which a password has been configured. ๐Ÿซถ

2.10. Label Distribution for Explicitly Routed LSPs ๐Ÿ›ค๏ธ

Traffic Engineering [RFC2702] is expected to be an important MPLS application. ๐Ÿ”ฅ MPLS support for Traffic Engineering uses explicitly routed LSPs, which need not follow normally-routed (hop-by-hop) paths as determined by destination-based routing protocols. CR-LDP [CRLDP] defines extensions to LDP to use LDP to set up explicitly routed LSPs. ๐Ÿฆ‹

3. Protocol Specification ๐ŸŽ€

previous sections that describe LDP operation have discussed scenarios that involve the exchange of messages among LDP peers. this section is where we get into the message encodings and the procedures for processing those messages. ๐Ÿ“

LDP message exchanges happen by sending LDP protocol data units (PDUs) over LDP session TCP connections. ๐Ÿ“ฆ

Each LDP PDU can carry one or more LDP messages. Note that the messages in an LDP PDU need not be related to one another. For example, a single PDU could carry a message advertising FEC-label bindings for several FECs, another message requesting label bindings for several other FECs, and a third notification message signaling some event. ๐Ÿง

3.1. LDP PDUs ๐ŸŒธ

Each LDP PDU is an LDP header followed by one or more LDP messages. The LDP header is:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Version                      |         PDU Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         LDP Identifier                        |
+                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Version : Two octet unsigned integer containing the version number of the protocol. This version of the specification specifies LDP protocol version 1.

PDU Length : Two octet integer specifying the total length of this PDU in octets, excluding the Version and PDU Length fields.

The maximum allowable PDU Length is negotiable when an LDP session is initialized. Prior to completion of the negotiation the maximum allowable length is 4096 bytes. ๐Ÿ“

LDP Identifier : Six octet field that uniquely identifies the label space of the sending LSR for which this PDU applies. The first four octets identify the LSR and must be a globally unique value. It should be a 32-bit router Id assigned to the LSR and also used to identify it in loop detection Path Vectors. The last two octets identify a label space within the LSR. For a platform-wide label space, these should both be zero. ๐Ÿ†”

Note that there is no alignment requirement for the first octet of an LDP PDU. ๐Ÿ™ˆ

3.2. LDP Procedures ๐Ÿงญ

LDP defines messages, TLVs and procedures in the following areas:

  • Peer discovery;
  • Session management;
  • Label distribution;
  • Notification of errors and advisory information.

The sections that follow describe the message and TLV encodings for these areas and the procedures that apply to them. ๐Ÿ“š

The label distribution procedures are complex and are difficult to describe fully, coherently and unambiguously as a collection of separate message and TLV specifications. ๐Ÿ˜ญ

Appendix A, "LDP Label Distribution Procedures", describes the label distribution procedures in terms of label distribution events that may occur at an LSR and how the LSR must respond. Appendix A is the specification of LDP label distribution procedures. If a procedure described elsewhere in this document conflicts with Appendix A, Appendix A specifies LDP behavior. ๐Ÿ‘‘

3.3. Type-Length-Value Encoding ๐Ÿงฉ

LDP uses a Type-Length-Value (TLV) encoding scheme to encode much of the information carried in LDP messages. โœจ

An LDP TLV is encoded as a 2 octet field that uses 14 bits to specify a Type and 2 bits to specify behavior when an LSR doesn't recognize the Type, followed by a 2 octet Length Field, followed by a variable length Value field.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|U|F|        Type               |            Length             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                             Value                             |
~                                                               ~
|                                                               |
|                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

U bit : Unknown TLV bit. Upon receipt of an unknown TLV, if U is clear (=0), a notification must be returned to the message originator and the entire message must be ignored; if U is set (=1), the unknown TLV is silently ignored and the rest of the message is processed as if the unknown TLV did not exist. The sections following that define TLVs specify a value for the U-bit.

F bit : Forward unknown TLV bit. This bit applies only when the U bit is set and the LDP message containing the unknown TLV is to be forwarded. If F is clear (=0), the unknown TLV is not forwarded with the containing message; if F is set (=1), the unknown TLV is forwarded with the containing message. The sections following that define TLVs specify a value for the F-bit.

Type : Encodes how the Value field is to be interpreted.

Length : Specifies the length of the Value field in octets.

Value : Octet string of Length octets that encodes information to be interpreted as specified by the Type field.

Note that there is no alignment requirement for the first octet of a TLV. ๐Ÿ™ˆ

Note that the Value field itself may contain TLV encodings. That is, TLVs may be nested. ๐Ÿช†

The TLV encoding scheme is very general. In principle, everything appearing in an LDP PDU could be encoded as a TLV. This specification does not use the TLV scheme to its full generality. It is not used where its generality is unnecessary and its use would waste space unnecessarily. These are usually places where the type of a value to be encoded is known, for example by its position in a message or an enclosing TLV, and the length of the value is fixed or readily derivable from the value encoding itself. ๐Ÿ’ก

Some of the TLVs defined for LDP are similar to one another. For example, there is a Generic Label TLV, an ATM Label TLV, and a Frame Relay TLV; see Sections "Generic Label TLV", "ATM Label TLV", and "Frame Relay TLV". ๐Ÿ”

While it is possible to think about TLVs related in this way in terms of a TLV type that specifies a TLV class and a TLV subtype that specifies a particular kind of TLV within that class, this specification does not formalize the notion of a TLV subtype. ๐Ÿคทโ€โ™€๏ธ

The specification assigns type values for related TLVs, such as the label TLVs, from a contiguous block in the 16-bit TLV type number space. ๐Ÿ”ข

Section "TLV Summary" lists the TLVs defined in this version of the protocol and the section in this document that describes each. ๐Ÿ“‹

3.4. TLV Encodings for Commonly Used Parameters ๐Ÿ’œ

There are several parameters used by more than one LDP message. The TLV encodings for these commonly used parameters are specified in this section. ๐Ÿซง

Okay bestie, the FEC TLV is where labels get bound to Forwarding Equivalence Classes (FECs) ๐Ÿ’– A FEC is a list of one or more FEC elements, and this TLV is what carries those FEC items around ๐ŸŽ€ Here's the layout:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |0|0| FEC (0x0100)              |      Length                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                        FEC Element 1                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                                                               |
   ~                                                               ~
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                        FEC Element n                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

FEC Element 1 to FEC Element n ๐Ÿงš There are several types of FEC elements, and you'll find them under Section "FECs" โœจ The FEC element encoding depends on the type of FEC element, so it's totally type-dependent vibes.

A FEC Element value is encoded as a 1 octet field that specifies the element type, followed by a variable length field that holds the type-dependent element value ๐Ÿ’… Here's the sneaky part: even though the value's representation depends on the type, the FEC element encoding itself does not use standard LDP TLV encoding. Plot twist ๐Ÿ™ˆ

The FEC Element value encoding is:

   FEC Element       Type      Value
   type name

     Wildcard        0x01      No value; i.e., 0 value octets;
                                   see below.
     Prefix          0x02      See below.
     Host Address    0x03      Full host address; see below.

Okay, quick heads up ๐Ÿšจ this version of LDP supports multiple FEC Elements per FEC for the Label Mapping message only. Using multiple FEC Elements in other messages is not permitted in this version, and that's a subject for future study ๐Ÿ”ฎ

Wildcard FEC Element ๐ŸŒธ This one is only for the Label Withdraw and Label Release Messages. It means the withdraw or release applies to all FECs associated with the label inside the following label TLV. It MUST be the only FEC Element in the FEC TLV, no exceptions bestie ๐Ÿ‘‘

Prefix FEC Element value encoding:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Prefix (2)   |     Address Family            |     PreLen    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Prefix                                    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • Address Family: a two octet quantity holding a value from ADDRESS FAMILY NUMBERS in [RFC1700], which encodes the address family for the address prefix in the Prefix field ๐Ÿฆ‹
  • PreLen: a one octet unsigned integer with the length in bits of the address prefix that follows. A length of zero means a prefix that matches all addresses (the default destination). In this case the Prefix itself is zero octets ๐Ÿ“
  • Prefix: an address prefix encoded according to the Address Family field, whose length in bits was given in the PreLen field, padded to a byte boundary ๐Ÿ’œ

Host Address FEC Element encoding:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | Host Addr (3) |     Address Family            | Host Addr Len |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                                                               |
   |                     Host Addr                                 |
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • Address Family: a two octet quantity holding a value from ADDRESS FAMILY NUMBERS in [RFC1700], which encodes the address family for the address prefix in the Prefix field ๐ŸŒˆ
  • Host Addr Len: the length of the Host address in octets ๐ŸŽ€
  • Host Addr: an address encoded according to the Address Family field โœจ

3.4.1.1. FEC Procedures

So if an LSR decodes a FEC TLV and runs into a FEC Element with an Address Family it doesn't support, it SHOULD stop decoding the FEC TLV, abort processing the message that has the TLV, and send an "Unsupported Address Family" Notification message to its LDP peer to signal an error ๐Ÿ™…โ€โ™€๏ธ

And if it hits a FEC Element type it can't decode, it SHOULD stop decoding the FEC TLV, abort processing the message with the TLV, and send an "Unknown FEC" Notification message to its LDP peer to signal an error ๐Ÿ’€

3.4.2. Label TLVs

Label TLVs encode labels ๐Ÿท๏ธ They're carried by the messages used to advertise, request, release and withdraw label mappings. There are several different kinds of Label TLVs that can show up in situations where a Label TLV is needed ๐Ÿซถ

3.4.2.1. Generic Label TLV

An LSR uses Generic Label TLVs to encode labels for use on links where label values don't depend on the underlying link technology. PPP and Ethernet are examples of these links ๐Ÿ“

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |0|0| Generic Label (0x0200)    |      Length                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |     Label                                                     |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Label: this is a 20-bit label value as specified in [RFC3032], represented as a 20-bit number in a 4 octet field ๐Ÿ’–

3.4.2.2. ATM Label TLV

An LSR uses ATM Label TLVs to encode labels for use on ATM links ๐Ÿฆ‹

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |0|0| ATM Label (0x0201)        |         Length                |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |Res| V |          VPI          |         VCI                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • Res: this field is reserved. It MUST be set to zero on transmission and MUST be ignored on receipt ๐Ÿ”’
  • V-bits: a two-bit switching indicator. If V-bits is 00, both the VPI and VCI are significant. If V-bits is 01, only the VPI field is significant. If V-bit is 10, only the VCI is significant ๐Ÿ”€
  • VPI: the Virtual Path Identifier. If VPI is less than 12-bits, it SHOULD be right justified in this field, and preceding bits SHOULD be set to 0 ๐Ÿงญ
  • VCI: the Virtual Channel Identifier. If the VCI is less than 16- bits, it SHOULD be right justified in the field, and the preceding bits MUST be set to 0. If Virtual Path switching is indicated in the V-bits field, then this field MUST be ignored by the receiver and set to 0 by the sender ๐Ÿ™ˆ

3.4.2.3. Frame Relay Label TLV

An LSR uses Frame Relay Label TLVs to encode labels for use on Frame Relay links ๐ŸŒธ

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |0|0| Frame Relay Label (0x0202)|       Length                  |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | Reserved    |Len|                     DLCI                    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • Res: this field is reserved. It MUST be set to zero on transmission and MUST be ignored on receipt ๐Ÿ”
  • Len: this field specifies the number of bits of the DLCI. The following values are supported:
   0 = 10 bits DLCI
   2 = 23 bits DLCI

Len values 1 and 3 are reserved ๐Ÿ™ƒ

  • DLCI: the Data Link Connection Identifier. Refer to [RFC3034] for the label values and formats ๐Ÿงš

3.4.3. Address List TLV

The Address List TLV appears in Address and Address Withdraw messages ๐Ÿ“ฌ

Its encoding is:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |0|0| Address List (0x0101)     |      Length                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |     Address Family            |                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |
   |                                                               |
   |                        Addresses                              |
   ~                                                               ~
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • Address Family: a two octet quantity holding a value from ADDRESS FAMILY NUMBERS in [RFC1700], which encodes the addresses contained in the Addresses field ๐ŸŒˆ
  • Addresses: a list of addresses from the specified Address Family. The encoding of the individual addresses depends on the Address Family ๐Ÿ’…

The following address encodings are defined by this version of the protocol ๐ŸŽ€

   Address Family      Address Encoding

   IPv4                4 octet full IPv4 address
   IPv6                16 octet full IPv6 address

3.4.4. Hop Count TLV

The Hop Count TLV shows up as an optional field in messages that set up LSPs โญ It calculates the number of LSR hops along an LSP while the LSP is being set up ๐Ÿงฎ

Heads up ๐Ÿšจ setup procedures for LSPs that traverse ATM and Frame Relay links require use of the Hop Count TLV (see [RFC3035] and [RFC3034]) ๐Ÿ’œ

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |0|0| Hop Count (0x0103)        |      Length                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |     HC Value  |
   +-+-+-+-+-+-+-+-+

HC Value: a 1 octet unsigned integer hop count value ๐Ÿ”ข

3.4.4.1. Hop Count Procedures โœจ

okay so during setup of an LSP, an LSR R might get a Label Mapping or Label Request message for that LSP that carries the Hop Count TLV. if it does, it should record the hop count value ๐ŸŽ€

If LSR R then propagates the Label Mapping message for the LSP to an upstream peer, or the Label Request message to a downstream peer to keep the LSP setup going, it must must determine a hop count to put in the propagated message, and it works like this:

  • If the message is a Label Request message, R must increment the received hop count;
  • If the message is a Label Mapping message, R determines the hop count as follows:
    • If R is a member of the edge set of an LSR domain whose LSRs do not perform 'TTL-decrement' and the upstream peer is within that domain, R must reset the hop count to 1 before propagating the message.
    • Otherwise, R must increment the received hop count.

The first LSR in the LSP (ingress for a Label Request message, egress for a Label Mapping message) should set the hop count value to 1 ๐Ÿงš

By convention, a value of 0 indicates an unknown hop count. and the result of incrementing an unknown hop count is itself an unknown hop count (0). it's giving "no clue yet" ๐Ÿ™ˆ

Using the unknown hop count value greatly reduces the signaling overhead when independent control is used ๐Ÿ’– when a new LSP is established, each LSR starts with an unknown hop count. adding a new LSR whose hop count is also unknown does not cause a hop count update to be propagated upstream, since the hop count remains unknown. then, when the egress is finally added to the LSP, the LSRs propagate hop count updates upstream via Label Mapping messages. main character moment for the egress, ngl ๐Ÿ‘‘

Without the unknown hop count, every time a new LSR is added to the LSP, a hop count update would need to be propagated upstream if the new LSR is closer to the egress than any of the other LSRs. those updates are useless overhead, since they don't reflect the hop count to the egress ๐Ÿ’€

From the perspective of the ingress node, the fact that the hop count is unknown implies nothing about whether a packet sent on the LSP will actually make it to the egress. all it implies is that the hop count update from the egress has not yet reached the ingress. so don't panic, it's just not here yet ๐Ÿฆ‹

If an LSR receives a message containing a Hop Count TLV, it must check the hop count value to determine whether the hop count has exceeded its configured maximum allowable value. If so, it must behave as if the containing message has traversed a loop, by sending a Notification message signaling Loop Detected in reply to the sender of the message. the loop alarm is going off, bestie ๐Ÿšจ

If Loop Detection is configured, the LSR must follow the procedures specified in Section "Loop Detection". ๐Ÿซถ


3.4.5. Path Vector TLV ๐ŸŒธ

The Path Vector TLV is used with the Hop Count TLV in Label Request and Label Mapping messages to implement the optional LDP loop detection mechanism. See Section "Loop Detection". In a Label Request message, it records the path of LSRs the request has traversed. In a Label Mapping message, it records the path of LSRs a label advertisement has traversed to set up an LSP. it's a paper trail of every stop, iconic ๐Ÿ“œ

Its encoding is:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|0| Path Vector (0x0104)      |        Length                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            LSR Id 1                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
~                                                               ~
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            LSR Id n                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

One or more LSR Ids ๐Ÿ“ A list of router-ids indicating the path of LSRs the message has traversed. Each LSR Id is the first four octets (router-id) of the LDP identifier for the corresponding LSR. this makes sure it is unique within the LSR network. โœจ

3.4.5.1. Path Vector Procedures ๐Ÿ’œ

The Path Vector TLV is carried in Label Mapping and Label Request messages when loop detection is configured.

3.4.5.1.1. Label Request Path Vector ๐Ÿ”ฅ

Section "Loop Detection" specifies situations when an LSR must include a Path Vector TLV in a Label Request message.

An LSR that receives a Path Vector in a Label Request message must perform the procedures described in Section "Loop Detection".

If the LSR detects a loop, it must reject the Label Request message.

The LSR must:

  1. Transmit a Notification message to the sending LSR signaling "Loop Detected".
  2. Not propagate the Label Request message further.

Note that a Label Request message with a Path Vector TLV is forwarded until:

  1. A loop is found,
  2. The LSP egress is reached,
  3. The maximum Path Vector limit or maximum Hop Count limit is reached. This is treated as if a loop had been detected.

3.4.5.1.2. Label Mapping Path Vector ๐Ÿฆ‹

Section "Loop Detection" specifies the situations when an LSR must include a Path Vector TLV in a Label Mapping message.

An LSR that receives a Path Vector in a Label Mapping message must perform the procedures described in Section "Loop Detection".

If the LSR detects a loop, it must reject the Label Mapping message in order to prevent a forwarding loop. The LSR must:

  1. Transmit a Label Release message carrying a Status TLV to the sending LSR to signal "Loop Detected".
  2. Not propagate the message further.
  3. Check whether the Label Mapping message is for an existing LSP. If so, the LSR must unsplice any upstream labels which are spliced to the downstream label for the FEC.

Note that a Label Mapping message with a Path Vector TLV is forwarded until:

  1. A loop is found,
  2. An LSP ingress is reached, or
  3. The maximum Path Vector or maximum Hop Count limit is reached. This is treated as if a loop had been detected.

3.4.6. Status TLV ๐ŸŽ€

Notification messages carry Status TLVs to specify the events being signaled. the status TLV is basically the "here's what just happened" card ๐Ÿ“ฃ

The encoding for the Status TLV is:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|U|F| Status (0x0300)           |      Length                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Status Code                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Message ID                                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      Message Type             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

U bit ๐Ÿ’… Should be 0 when the Status TLV is sent in a Notification message. Should be 1 when the Status TLV is sent in some other message.

F bit ๐ŸŒˆ Should be the same as the setting of the F-bit in the Status Code field.

Status Code ๐Ÿงš 32-bit unsigned integer encoding the event being signaled. The structure of a Status Code is:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|E|F|                 Status Data                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • E bit: Fatal error bit. If set (=1), this is a fatal error notification. If clear (=0), this is an advisory notification.
  • F bit: Forward bit. If set (=1), the notification should be forwarded to the LSR for the next-hop or previous-hop for the LSP, if any, associated with the event being signaled. If clear (=0), the notification should not be forwarded.
  • Status Data: 30-bit unsigned integer which specifies the status information.

This specification defines Status Codes (32-bit unsigned integers with the above encoding).

A Status Code of 0 signals success. ๐ŸŽ‰

Message ID ๐Ÿ“ If non-zero, 32-bit value that identifies the peer message to which the Status TLV refers. If zero, no specific peer message is being identified.

Message Type ๐ŸŒธ If non-zero, the type of the peer message to which the Status TLV refers. If zero, the Status TLV does not refer to any specific message type.

Note that use of the Status TLV is not limited to Notification messages. A message other than a Notification message may carry a Status TLV as an Optional Parameter. When a message other than a Notification carries a Status TLV, the U-bit of the Status TLV should be set to 1 to indicate that the receiver should silently discard the TLV if unprepared to handle it. ๐Ÿซถ

3.5. LDP Messages โœจ

Okay bestie, every LDP message comes in the same basic shape ๐Ÿ’… Here's the layout:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|U|   Message Type              |      Message Length           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Message ID                                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                     Mandatory Parameters                      |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                     Optional Parameters                       |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

U bit: this is the unknown message bit ๐Ÿ”ฎ When an unknown message shows up, if U is clear (=0), a notification gets sent back to whoever sent it. If U is set (=1), the unknown message is silently ignored. The sections that come after define messages and specify a value for the U-bit.

Message Type: identifies the type of message ๐ŸŽ€

Message Length: specifies the cumulative length in octets of the Message ID, Mandatory Parameters, and Optional Parameters ๐Ÿ“

Message ID: a 32-bit value used to identify this message โœจ The sending LSR uses it to help figure out which notification messages might apply to this message. An LSR sending a notification in response should include this Message Id in the Status TLV carried by that notification. See Section "Notification Message" for the details.

Mandatory Parameters: a variable length set of required message parameters ๐Ÿ’– Some messages have no required parameters at all.

For messages that do have required parameters, the required parameters MUST appear in the order specified by the individual message specifications in the sections that follow. No skipping, no shuffling ๐Ÿ™…โ€โ™€๏ธ

Optional Parameters: a variable length set of optional message parameters ๐ŸŒธ Lots of messages have none of these.

For messages that have optional parameters, the optional parameters may appear in any order. Vibes are flexible here ๐Ÿฆ‹

Note that there is no alignment requirement for the first octet of an LDP message. It can start wherever it wants ๐Ÿ™ˆ

The following message types are defined in this version of LDP:

Message Name            Section Title

Notification            "Notification Message"
Hello                   "Hello Message"
Initialization          "Initialization Message"
KeepAlive               "KeepAlive Message"
Address                 "Address Message"
Address Withdraw        "Address Withdraw Message"
Label Mapping           "Label Mapping Message"
Label Request           "Label Request Message"
Label Abort Request     "Label Abort Request Message"
Label Withdraw          "Label Withdraw Message"
Label Release           "Label Release Message"

The sections that follow specify the encodings and procedures for these messages ๐Ÿ“–

Some of these messages are related to each other, like the Label Mapping, Label Request, Label Withdraw, and Label Release messages. They're giving family ๐Ÿ‘ฏโ€โ™€๏ธ

It's possible to think about these related messages as a message type that specifies a message class, plus a message subtype that picks out a particular kind of message within that class. This specification doesn't formalize the notion of a message subtype though, so don't go building a whole system around it ๐Ÿ’€

The specification assigns type values for related messages, like the label messages, from a contiguous block in the 16-bit message type number space ๐Ÿงš


3.5.1. Notification Message

An LSR sends a Notification message to inform an LDP peer of a significant event ๐Ÿšจ A Notification message signals a fatal error, or provides advisory information like the outcome of processing an LDP message or the state of the LDP session. It's the drama queen of LDP messages, honestly ๐ŸŽญ

The encoding for the Notification Message is:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|   Notification (0x0001)     |      Message Length           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Message ID                                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Status (TLV)                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Optional Parameters                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Message ID: a 32-bit value used to identify this message ๐Ÿ†”

Status TLV: indicates the event being signaled ๐Ÿ“ฃ The encoding for the Status TLV is specified in Section "Status TLV".

Optional Parameters: this variable length field holds 0 or more parameters, each encoded as a TLV ๐ŸŽ The following Optional Parameters are generic and may appear in any Notification Message:

Optional Parameter     Type     Length  Value

Extended Status        0x0301    4      See below
Returned PDU           0x0302    var    See below
Returned Message       0x0303    var    See below

Other Optional Parameters, specific to the particular event being signaled by the Notification Messages, may also show up. Those are described elsewhere ๐Ÿ—บ๏ธ

Extended Status: the 4 octet value is an Extended Status Code that adds extra info on top of what the Notification Status Code already says โœจ

Returned PDU: an LSR uses this to send back part of an LDP PDU to the LSR that sent it ๐Ÿ“ฌ The value is the PDU header plus as much PDU data after the header as makes sense for the condition being signaled.

Returned Message: an LSR uses this to send back part of an LDP message to the LSR that sent it ๐Ÿ’Œ The value is the message type and length fields, plus as much message data after those fields as makes sense for the condition being signaled.


3.5.1.1. Notification Message Procedures

If an LSR runs into a condition that needs it to notify its peer with advisory or error info, it sends the peer a Notification message ๐Ÿ“จ That message contains a Status TLV that encodes the info, and optionally some extra TLVs that give more detail about the condition.

If the condition is a fatal error, the Status Code in the notification will say so ๐Ÿšซ In that case, after sending the Notification message, the LSR should terminate the LDP session by closing the session TCP connection, and discard all state associated with the session. That includes all label-FEC bindings learned via the session. Bye bye, everything ๐Ÿ‘‹

When an LSR receives a Notification message carrying a Status Code that indicates a fatal error, it should terminate the LDP session right away by closing the session TCP connection, and discard all state associated with the session. Same energy, including all label-FEC bindings learned via the session ๐Ÿ’…


3.5.1.2. Events Signaled by Notification Messages

It's useful, for descriptive purposes, to sort the events signaled by Notification Messages into the following categories ๐Ÿ—‚๏ธ


3.5.1.2.1. Malformed PDU or Message

Malformed LDP PDUs or Messages that are part of the LDP Discovery mechanism get handled by silently discarding them ๐Ÿซฅ

An LDP PDU received on a TCP connection for an LDP session is malformed if:

  • The LDP Identifier in the PDU header is unknown to the receiver, or it's known but isn't the LDP Identifier the receiver associated with the LDP peer for this LDP session. This is a fatal error signaled by the Bad LDP Identifier Status Code ๐Ÿ™…โ€โ™€๏ธ
  • The LDP protocol version isn't supported by the receiver, or it's supported but isn't the version negotiated for the session during session establishment. This is a fatal error signaled by the Bad Protocol Version Status Code ๐Ÿงพ
  • The PDU Length field is too small (< 14) or too large (> maximum PDU length). This is a fatal error signaled by the Bad PDU Length Status Code. Section "Initialization Message" describes how the maximum PDU length for a session gets determined ๐Ÿ“

An LDP Message is malformed if:

  • The Message Type is unknown.
    • If the Message Type is < 0x8000 (high order bit = 0), it's an error signaled by the Unknown Message Type Status Code ๐Ÿคจ
    • If the Message Type is >= 0x8000 (high order bit = 1), it's silently discarded ๐Ÿซฅ
  • The Message Length is too large, meaning it indicates that the message extends beyond the end of the containing LDP PDU. This is a fatal error signaled by the Bad Message Length Status Code ๐Ÿ’€
  • The message is missing one or more Mandatory Parameters. This is a non-fatal error signalled by the Missing Message Parameters Status Code ๐Ÿฉน

3.5.1.2.2. Unknown or Malformed TLV

Malformed TLVs inside LDP messages that are part of the LDP Discovery mechanism get handled by silently discarding the containing message ๐Ÿ—‘๏ธ

A TLV contained in an LDP message received on a TCP connection of an LDP is malformed if:

  • The TLV Length is too large, meaning it indicates that the TLV extends beyond the end of the containing message. This is a fatal error signaled by the Bad TLV Length Status Code ๐Ÿ˜ฑ
  • The TLV type is unknown.
    • If the TLV type is < 0x8000 (high order bit 0), it's an error signaled by the Unknown TLV Status Code ๐Ÿค”
    • If the TLV type is >= 0x8000 (high order bit 1), the TLV is silently dropped. Section "Unknown TLV in Known Message Type" goes deeper on this behavior ๐Ÿ”
  • The TLV Value is malformed. This happens when the receiver handles the TLV but can't decode the TLV Value. It's treated as a sign of a bug in either the sending or receiving LSR ๐Ÿ› It's a fatal error signaled by the Malformed TLV Value Status Code ๐Ÿšจ

3.5.1.2.3. Session KeepAlive Timer Expiration

This is a fatal error signaled by the KeepAlive Timer Expired Status Code โฐ๐Ÿ’”


3.5.1.2.4. Unilateral Session Shutdown

This is a fatal event signaled by the Shutdown Status Code ๐Ÿ›‘ The Notification Message may optionally include an Extended Status TLV to give a reason for the Shutdown. The sending LSR terminates the session immediately after sending the Notification ๐Ÿซก

3.5.1.2.5. Initialization Message Events โœจ

okay so the session setup negotiation (check out "Session Initialization") can totally faceplant if the session parameters in the Initialization Message are unacceptable ๐Ÿ’€. this is a fatal error, no cap. the exact Status Code depends on which parameter got rejected, and those are defined in the "Initialization Message" sections ๐Ÿซถ

3.5.1.2.6. Events Resulting From Other Messages ๐Ÿฆ‹

other messages (not the Initialization message) can also cause events that LDP peers need to hear about, so they get sent via Notification Messages ๐Ÿ“ฃ. the events and the Status Codes used to signal them are described in the sections for each of those messages. so it's all spread out, not in one place, bestie ๐Ÿงš

3.5.1.2.7. Internal Errors ๐Ÿ”ฅ

an LDP implementation might be able to spot problems that are specific to its own internals. when one of those problems stops it from talking properly to a peer, the implementation should, when it's able to, send the Internal Error Status Code to signal the peer. this is a fatal error, and it's giving "my code is having a moment" energy ๐Ÿ˜ญ

3.5.1.2.8. Miscellaneous Events ๐ŸŒธ

these are events that don't fit in any of the categories above. there are no miscellaneous events defined in this version of the protocol, so nothing to see here ๐Ÿ’…

3.5.2. Hello Message ๐Ÿ’œ

LDP Hello Messages get exchanged as part of the LDP Discovery Mechanism, so check out "LDP Discovery" for the full story ๐Ÿ”

here's how the Hello Message is encoded:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|   Hello (0x0100)            |      Message Length           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Message ID                                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Common Hello Parameters TLV               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Optional Parameters                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Message ID ๐Ÿ†” 32-bit value used to identify this message.

Common Hello Parameters TLV ๐ŸŽ€ this one specifies the parameters that all Hello messages share. here's its encoding:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|0| Common Hello Parms(0x0400)|      Length                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      Hold Time                |T|R| Reserved                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Hold Time โณ the Hello hold time, in seconds. an LSR keeps a record of the Hellos it gets from potential peers (see "Hello Message Procedures") ๐Ÿ“’. the Hello Hold Time is how long the sending LSR keeps its record of Hellos from the receiving LSR when no new Hello shows up.

the two LSRs negotiate the hold times they'll use for each other's Hellos. each one proposes a hold time, and the one that gets used is the minimum of the proposed hold times in their Hellos. so it's a little bit of a compromise, lowkey ๐Ÿค

a value of 0 means "use the default", which is 15 seconds for Link Hellos and 45 seconds for Targeted Hellos. a value of 0xffff means infinite โ™พ๏ธ

T, Targeted Hello ๐ŸŽฏ a value of 1 means this Hello is a Targeted Hello. a value of 0 means it's a Link Hello.

R, Request Send Targeted Hellos ๐Ÿ“จ a value of 1 asks the receiver to send periodic Targeted Hellos to whoever sent this Hello. a value of 0 makes no request.

an LSR that starts Extended Discovery sets R to 1. when R is 1, the receiving LSR checks whether it's been configured to send Targeted Hellos to the Hello source in response to Hellos carrying this request. if it hasn't, it just ignores the request ๐Ÿ™„. if it has, it starts sending periodic Targeted Hellos to the Hello source. ate, and left no crumbs ๐Ÿ’…

Reserved ๐Ÿšซ this field is reserved. it must be set to zero on transmission and ignored on receipt.

Optional Parameters ๐Ÿงฉ this variable-length field holds 0 or more parameters, and each one is encoded as a TLV. the optional parameters defined by this version of the protocol are:

Optional Parameter         Type     Length  Value

IPv4 Transport Address     0x0401     4      See below
Configuration              0x0402     4      See below
   Sequence Number
IPv6 Transport Address     0x0403    16      See below

IPv4 Transport Address ๐ŸŒ this specifies the IPv4 address the sending LSR uses when it opens the LDP session TCP connection. if this optional TLV isn't present, the IPv4 source address of the UDP packet carrying the Hello should be used.

Configuration Sequence Number ๐Ÿ”ข this is a 4-octet unsigned configuration sequence number that identifies the configuration state of the sending LSR. the receiving LSR uses it to detect configuration changes on the sending LSR ๐Ÿ‘€.

IPv6 Transport Address ๐ŸŒ this specifies the IPv6 address the sending LSR uses when it opens the LDP session TCP connection. if this optional TLV isn't present, the IPv6 source address of the UDP packet carrying the Hello should be used.

3.5.2.1. Hello Message Procedures ๐Ÿช„

an LSR that gets Hellos from another LSR keeps a Hello adjacency that matches those Hellos. it runs a hold timer for that Hello adjacency and restarts it every time it receives a Hello matching the adjacency. if the hold timer for a Hello adjacency expires, the LSR throws that Hello adjacency away (see "Maintaining Hello Adjacencies" and "Maintaining LDP Sessions") ๐Ÿ—‘๏ธ

we recommend that the interval between Hello transmissions be at most one third of the Hello hold time ๐Ÿ’ก

an LSR processes a received LDP Hello like this:

  1. the LSR checks whether the Hello is acceptable. the criteria for that are implementation dependent (see below for example criteria).
  2. if the Hello isn't acceptable, the LSR ignores it.
  3. if the Hello is acceptable, the LSR checks whether it already has a Hello adjacency for the Hello source. if it does, it restarts the hold timer for that adjacency. if not, it creates a Hello adjacency for the Hello source and starts its hold timer.
  4. if the Hello carries any optional TLVs, the LSR processes them (see below).
  5. finally, if the LSR has no LDP session for the label space specified by the LDP identifier in the PDU header for the Hello, it follows the procedures in "LDP Session Establishment" ๐Ÿค

here are some examples of acceptability criteria for Link and Targeted Hellos ๐Ÿง:

  • a Link Hello is acceptable if the interface it was received on has been configured for label switching.
  • a Targeted Hello from source address A is acceptable if either:
    • the LSR has been configured to accept Targeted Hellos, or
    • the LSR has been configured to send Targeted Hellos to A.

here's how an LSR processes the Hello optional TLVs:

Transport Address ๐Ÿšš the LSR associates the specified transport address with the Hello adjacency.

Configuration Sequence Number ๐Ÿ” the sending LSR uses this optional parameter to signal configuration changes to the receiving LSR. when a receiving LSR that's playing the active role in LDP session establishment detects a change in the sending LSR's configuration, it may clear any session setup backoff delay associated with the sending LSR (see "Session Initialization") โœจ.

a sending LSR that uses this optional parameter is responsible for maintaining the configuration sequence number it transmits in Hello messages. whenever there's a configuration change on the sending LSR, it increments the configuration sequence number ๐Ÿ“ˆ.

3.5.3. Initialization Message ๐ŸŽฌ

the LDP Initialization Message is exchanged as part of the LDP session establishment procedure, so see "LDP Session Establishment" ๐Ÿค

here's how the Initialization Message is encoded:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|   Initialization (0x0200)   |      Message Length           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Message ID                                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Common Session Parameters TLV             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Optional Parameters                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Message ID ๐Ÿ†” 32-bit value used to identify this message.

Common Session Parameters TLV ๐Ÿ› ๏ธ this specifies the values the sending LSR proposes for the parameters that have to be negotiated for every LDP session ๐Ÿค

here's its encoding:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|0| Common Sess Parms (0x0500)|      Length                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Protocol Version              |      KeepAlive Time           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|A|D|  Reserved |     PVLim     |      Max PDU Length           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Receiver LDP Identifier                       |
+                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++

Protocol Version ๐Ÿ”ข a 2-octet unsigned integer with the version number of the protocol. this version of the specification defines LDP protocol version 1.

KeepAlive Time ๐Ÿ’“ a 2-octet unsigned, non-zero integer that gives the number of seconds the sending LSR proposes for the KeepAlive Time. the receiving LSR MUST calculate the value of the KeepAlive Timer by using the smaller of its own proposed KeepAlive Time and the KeepAlive Time received in the PDU ๐Ÿงฎ. the KeepAlive Time chosen is the maximum number of seconds that may pass between receiving successive PDUs from the LDP peer on the session TCP connection. the KeepAlive Timer resets every time a PDU arrives โฑ๏ธ

A, Label Advertisement Discipline ๐Ÿท๏ธ this tells you what type of Label advertisement is in use. a value of 0 means Downstream Unsolicited advertisement, and a value of 1 means Downstream On Demand. ๐ŸŽ‰

If one LSR proposes Downstream Unsolicited and the other proposes Downstream on Demand, here's how they settle it ๐Ÿ’…โœจ

  • If the session is for a label-controlled ATM link or a label-controlled Frame Relay link, then Downstream on Demand must be used. ๐ŸŽ€
  • Otherwise, Downstream Unsolicited must be used. ๐ŸŒธ

If an LSR finds the label advertisement discipline worked out this way unacceptable, it must send a Session Rejected/Parameters Advertisement Mode Notification message in response to the Initialization message and not establish the session. Bestie, that's a hard no ๐Ÿ™…โ€โ™€๏ธ

D, Loop Detection ๐Ÿ” Tells you whether loop detection based on path vectors is turned on. A value of 0 means loop detection is disabled, and a value of 1 means it's enabled.

PVLim, Path Vector Limit ๐Ÿ“ This is the configured maximum path vector length. Must be 0 if loop detection is disabled (D = 0). If the loop detection procedures would make the LSR send a path vector that goes over this limit, the LSR will behave as if a loop had been detected for the FEC in question. Yikes, but make sense ๐Ÿ˜ญ

When Loop Detection is enabled in a portion of a network, it is recommended that all LSRs in that portion of the network be configured with the same path vector limit. Knowing a peer's path vector limit won't change how an LSR behaves, but it does let the LSR alert an operator to a possible misconfiguration. Main character energy for catching mistakes ๐Ÿ‘‘

Reserved ๐ŸงŠ This field is reserved. It must be set to zero on transmission and ignored on receipt.

Max PDU Length ๐Ÿ“ฆ A two octet unsigned integer that proposes the maximum allowable length for LDP PDUs for the session. A value of 255 or less specifies the default maximum length of 4096 octets.

The receiving LSR MUST calculate the maximum PDU length for the session by using the smaller of its own proposal and its peer's proposal for Max PDU Length. The default maximum PDU length applies before session initialization completes. ๐Ÿซถ

If the maximum PDU length determined this way is unacceptable to an LSR, it must send a Session Rejected/Parameters Max PDU Length Notification message in response to the Initialization message and not establish the session. ๐Ÿ’€

Receiver LDP Identifier ๐Ÿชช Identifies the receiver's label space. This LDP Identifier, together with the sender's LDP Identifier in the PDU header, lets the receiver match the Initialization message with one of its Hello adjacencies. See Section "Hello Message Procedures". ๐Ÿฆ‹

If there is no matching Hello adjacency, the LSR must send a Session Rejected/No Hello Notification message in response to the Initialization message and not establish the session. ๐Ÿ™ˆ

Optional Parameters ๐ŸŽ This variable length field contains 0 or more parameters, each encoded as a TLV. The optional parameters are:

   Optional Parameter       Type     Length  Value

   ATM Session Parameters   0x0501   var     See below
   Frame Relay Session      0x0502   var     See below
     Parameters

ATM Session Parameters โšก Used when an LDP session manages label exchange for an ATM link, to specify ATM-specific session parameters.

   0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |0|0|   ATM Sess Parms (0x0501) |      Length                   |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | M |   N   |D|                        Reserved                 |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                 ATM Label Range Component 1                   |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                                                               |
  ~                                                               ~
  |                                                               |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                 ATM Label Range Component N                   |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

M, ATM Merge Capabilities ๐Ÿ”€ Specifies the merge capabilities of an ATM switch. The following values are supported in this version of the specification:

         Value          Meaning

           0            Merge not supported
           1            VP Merge supported
           2            VC Merge supported
           3            VP & VC Merge supported

If the merge capabilities of the LSRs differ, then:

  • Non-merge and VC-merge LSRs may freely interoperate. ๐Ÿค
  • The interoperability of VP-merge-capable switches with non-VP-merge-capable switches is a subject for future study. When the LSRs differ on the use of VP-merge, the session is established, but VP merge is not used.

Note that if VP merge is used, it is the responsibility of the ingress node to ensure that the chosen VCI is unique within the LSR domain (see [ATM-VP]). ๐Ÿ‘€

N, Number of label range components ๐Ÿ”ข Specifies the number of ATM Label Range Components included in the TLV.

D, VC Directionality ๐Ÿงญ A value of 0 specifies bidirectional VC capability. This means the LSR can, within a given VPI, support the use of a given VCI as a label for both link directions independently. A value of 1 specifies unidirectional VC capability. This means that, within a given VPI, a given VCI may appear in a label mapping for one direction on the link only. When either or both of the peers specify unidirectional VC capability, both LSRs use unidirectional VC label assignment for the link, as follows. The LSRs compare their LDP Identifiers as unsigned integers. The LSR with the larger LDP Identifier may assign only odd-numbered VCIs in the VPI/VCI range as labels. The system with the smaller LDP Identifier may assign only even-numbered VCIs in the VPI/VCI range as labels. ๐ŸŽฒ

Reserved ๐ŸงŠ This field is reserved. It must be set to zero on transmission and ignored on receipt.

One or more ATM Label Range Components ๐ŸŒˆ A list of ATM Label Range Components which together specify the label range supported by the transmitting LSR.

A receiving LSR MUST calculate the intersection between the received range and its own supported label range. The intersection is the range in which the LSR may allocate and accept labels. LSRs MUST NOT establish a session with neighbors for which the intersection of ranges is NULL. In this case, the LSR must send a Session Rejected/Parameters Label Range Notification message in response to the Initialization message and not establish the session. ๐Ÿšซ

The encoding for an ATM Label Range Component is:

   0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |  Res  |    Minimum VPI        |      Minimum VCI              |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |  Res  |    Maximum VPI        |      Maximum VCI              |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Res ๐ŸงŠ This field is reserved. It must be set to zero on transmission and must be ignored on receipt.

Minimum VPI (12 bits) ๐Ÿ”ฝ This 12 bit field specifies the lower bound of a block of Virtual Path Identifiers that is supported on the originating switch. If the VPI is less than 12-bits, it should be right justified in this field and preceding bits should be set to 0.

Minimum VCI (16 bits) ๐Ÿ”ฝ This 16 bit field specifies the lower bound of a block of Virtual Connection Identifiers that is supported on the originating switch. If the VCI is less than 16-bits, it should be right justified in this field and preceding bits should be set to 0.

Maximum VPI (12 bits) ๐Ÿ”ผ This 12 bit field specifies the upper bound of a block of Virtual Path Identifiers that is supported on the originating switch. If the VPI is less than 12-bits, it should be right justified in this field and preceding bits should be set to 0.

Maximum VCI (16 bits) ๐Ÿ”ผ This 16 bit field specifies the upper bound of a block of Virtual Connection Identifiers that is supported on the originating switch. If the VCI is less than 16-bits, it should be right justified in this field and preceding bits should be set to 0.

When peer LSRs are connected indirectly by means of an ATM VP, the sending LSR should set the Minimum and Maximum VPI fields to 0, and the receiving LSR must ignore the Minimum and Maximum VPI fields. ๐Ÿช„

See [ATM-VP] for the specification of the fields for ATM Label Range Components to be used with VP merge LSRs. ๐Ÿ“š

Frame Relay Session Parameters ๐ŸŒท Used when an LDP session manages label exchange for a Frame Relay link, to specify Frame Relay-specific session parameters.

   0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |0|0|   FR Sess Parms (0x0502)  |      Length                   |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | M |   N   |D|                        Reserved                 |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |             Frame Relay Label Range Component 1               |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                                                               |
  ~                                                               ~
  |                                                               |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |             Frame Relay Label Range Component N               |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

M, Frame Relay Merge Capabilities ๐Ÿงฉ Specifies the merge capabilities of a Frame Relay switch. The following values are supported in this version of the specification:

         Value          Meaning

           0            Merge not supported
           1            Merge supported

Non-merge and merge Frame Relay LSRs may freely interoperate. ๐Ÿ’ž

N, Number of label range components ๐Ÿ”ข Specifies the number of Frame Relay Label Range Components included in the TLV. ๐ŸŽ€

D, VC Directionality ๐Ÿฆ‹ Okay bestie, this one is the bidirectional vs. unidirectional switch. A value of 0 means bidirectional VC capability, so the LSR can use a DLCI as a label for both link directions, independently โœจ. A value of 1 means unidirectional VC capability, so a given DLCI can only show up in a label mapping for one direction on the link ๐Ÿ’…. When either or both peers have unidirectional VC capability, both LSRs switch to unidirectional VC label assignment for the link. Here's the drama-free way they split it up: they compare their LDP Identifiers as unsigned integers. The LSR with the larger LDP Identifier may only assign odd-numbered DLCIs in the range as labels, and the one with the smaller LDP Identifier may only assign even-numbered DLCIs ๐ŸŒธ Fair split, no fights.

Reserved ๐ŸŽ€ This field is reserved. It must be set to zero on transmission and ignored on receipt.

One or more Frame Relay Label Range Components ๐Ÿงš This is a list of Frame Relay Label Range Components that together specify the Label range supported by the transmitting LSR.

A receiving LSR MUST calculate the intersection between the received range and its own supported label range ๐Ÿซถ The intersection is the range where the LSR is allowed to allocate and accept labels. LSRs MUST NOT establish a session with neighbors whose intersection of ranges is NULL. In that case, the LSR must send a Session Rejected/Parameters Label Range Notification message in response to the Initialization message and not establish the session ๐Ÿ™ˆ No overlap, no session, periodt.

The encoding for a Frame Relay Label Range Component is:

  0                   1                   2                   3
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | Reserved    |Len|                     Minimum DLCI            |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 | Reserved        |                     Maximum DLCI            |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Reserved ๐ŸŒˆ This field is reserved. It must be set to zero on transmission and ignored on receipt.

Len ๐Ÿ“ This field specifies the number of bits of the DLCI. These are the supported values:

     Len    DLCI bits

     0       10
     2       23

Len values 1 and 3 are reserved.

Minimum DLCI ๐ŸŒธ This 23-bit field specifies the lower bound of a block of Data Link Connection Identifiers (DLCIs) supported on the originating switch. The DLCI should be right justified in this field, and unused bits should be set to 0.

Maximum DLCI ๐Ÿ’œ This 23-bit field specifies the upper bound of a block of Data Link Connection Identifiers (DLCIs) supported on the originating switch. The DLCI should be right justified in this field, and unused bits should be set to 0.

Note that there is no Generic Session Parameters TLV for sessions which advertise Generic Labels ๐Ÿ‘‘ Heads up, that one's not a typo.

3.5.3.1. Initialization Message Procedures โœจ

See Section "LDP Session Establishment" and particularly Section "Session Initialization" for the general procedures for handling the Initialization Message ๐Ÿงš

3.5.4. KeepAlive Message ๐Ÿ’–

An LSR sends KeepAlive Messages as part of a mechanism that monitors the integrity of the LDP session transport connection ๐Ÿซถ

The encoding for the KeepAlive Message is:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|   KeepAlive (0x0201)        |      Message Length           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Message ID                                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Optional Parameters                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Message ID ๐ŸŽ€ A 32-bit value used to identify this message.

Optional Parameters ๐Ÿ™ˆ No optional parameters are defined for the KeepAlive message.

3.5.4.1. KeepAlive Message Procedures ๐Ÿฆ‹

The KeepAlive Timer mechanism described in Section "Maintaining LDP Sessions" resets a session KeepAlive timer every time an LDP PDU is received on the session TCP connection. The KeepAlive Message exists so an LSR can reset the KeepAlive Timer when it has no other information to send to an LDP peer ๐ŸŒธ

An LSR must arrange that its peer receive an LDP Message from it at least every KeepAlive Time period. Any LDP protocol message will do, but if no other LDP protocol messages have been sent within the period, a KeepAlive message must be sent ๐Ÿ’…

3.5.5. Address Message ๐ŸŒˆ

An LSR sends the Address Message to an LDP peer to advertise its interface addresses ๐Ÿงš

The encoding for the Address Message is:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|   Address (0x0300)          |      Message Length           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Message ID                                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                     Address List TLV                          |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Optional Parameters                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Message ID ๐Ÿ“ A 32-bit value used to identify this message.

Address List TLV ๐Ÿ’– The list of interface addresses being advertised by the sending LSR. The encoding for the Address List TLV is specified in Section "Address List TLV".

Optional Parameters ๐Ÿซถ No optional parameters are defined for the Address message.

3.5.5.1. Address Message Procedures ๐Ÿ’…

An LSR that receives an Address Message message uses the addresses it learns to maintain a database for mapping between peer LDP Identifiers and next hop addresses; see Section "LDP Identifiers and Next Hop Addresses" ๐Ÿง 

When a new LDP session is initialized, and before sending Label Mapping or Label Request messages, an LSR should advertise its interface addresses with one or more Address messages ๐ŸŒธ

Whenever an LSR "activates" a new interface address, it should advertise the new address with an Address message โœจ

Whenever an LSR "de-activates" a previously advertised address, it should withdraw the address with an Address Withdraw message; see Section "Address Withdraw Message" ๐Ÿฆ‹

If an LSR does not support the Address Family specified in the Address List TLV, it should send an "Unsupported Address Family" Notification to its LDP signalling an error and abort processing the message ๐Ÿ˜ญ

3.5.6. Address Withdraw Message ๐Ÿงš

An LSR sends the Address Withdraw Message to an LDP peer to withdraw previously advertised interface addresses ๐ŸŒˆ

The encoding for the Address Withdraw Message is:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|   Address Withdraw (0x0301) |      Message Length           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Message ID                                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                     Address List TLV                          |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Optional Parameters                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Message ID ๐Ÿ’œ A 32-bit value used to identify this message.

Address list TLV ๐ŸŽ€ The list of interface addresses being withdrawn by the sending LSR. The encoding for the Address list TLV is specified in Section "Address List TLV".

Optional Parameters ๐Ÿ™ˆ No optional parameters are defined for the Address Withdraw message.

3.5.6.1. Address Withdraw Message Procedures ๐ŸŒธ

See Section "Address Message Procedures"

3.5.7. Label Mapping Message ๐Ÿ‘‘

An LSR sends a Label Mapping message to an LDP peer to advertise FEC-label bindings to the peer โœจ

The encoding for the Label Mapping Message is:

   0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |0|   Label Mapping (0x0400)    |      Message Length           |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Message ID                                |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     FEC TLV                                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Label TLV                                 |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Optional Parameters                       |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Message ID ๐Ÿฆ‹ A 32-bit value used to identify this message.

FEC TLV ๐Ÿงš Specifies the FEC component of the FEC-Label mapping being advertised. See Section "FEC TLV" for encoding.

Label TLV ๐ŸŒˆ Specifies the Label component of the FEC-Label mapping. See Section "Label TLV" for encoding.

Optional Parameters ๐Ÿ’… This variable length field contains 0 or more parameters, each encoded as a TLV. The optional parameters are:

   Optional Parameter    Length       Value

   Label Request         4            See below
       Message ID TLV
   Hop Count TLV         1            See below
   Path Vector TLV       variable     See below

The encodings for the Hop Count and Path Vector TLVs can be found in Section "TLV Encodings for Commonly Used Parameters" ๐Ÿซถ

Label Request Message ID ๐Ÿ“ If this Label Mapping message is a response to a Label Request message, it must include the Request Message Id optional parameter. The value of this optional parameter is the Message Id of the corresponding Label Request Message ๐Ÿ’–

Hop Count ๐ŸŒธ Specifies the running total of the number of LSR hops along the LSP being setup by the Label Message. Section "Hop Count Procedures" describes how to handle this TLV.

Path Vector โœจ Specifies the LSRs along the LSP being setup by the Label Message. Section "Path Vector Procedures" describes how to handle this TLV.

3.5.7.1. Label Mapping Message Procedures โœจ

Okay so the Mapping message is how an LSR hands a label mapping for a FEC over to its LDP peer ๐Ÿ’–. If an LSR sends a mapping for one FEC to a bunch of peers, it's totally up to it whether it makes one label and blasts that to everyone, or gives each peer a different label. Your call, bestie ๐Ÿ’…

An LSR is responsible for keeping the label mappings it has distributed consistent, and for making sure its peers actually have them ๐Ÿซถ

An LSR that gets a Label Mapping message from a downstream LSR for a Prefix or Host Address FEC Element should not use that label for forwarding unless its routing table has an entry that exactly matches the FEC Element. Lowkey the exact-match rule is everything ๐Ÿ™ˆ

See Appendix A "LDP Label Distribution Procedures" for more details. ๐Ÿ“–

3.5.7.1.1. Independent Control Mapping ๐Ÿฆ‹

If an LSR is set up for independent control, it sends a mapping message whenever any of these happen:

  1. The LSR spots a new FEC in its forwarding table, and the label advertisement mode is Downstream Unsolicited advertisement.
  2. The LSR gets a Request message from an upstream peer for a FEC that's in its forwarding table.
  3. The next hop for a FEC switches to a different LDP peer, and loop detection is configured.
  4. The attributes of a mapping change.
  5. The LSR receives a mapping from the downstream next hop AND
    • a) no upstream mapping has been created OR
    • b) loop detection is configured OR
    • c) the attributes of the mapping have changed.

3.5.7.1.2. Ordered Control Mapping ๐ŸŒธ

If an LSR is doing ordered control, the downstream LSRs send a Mapping message whenever any of these happen:

  1. The LSR spots a new FEC in its forwarding table, and it's the egress for that FEC.
  2. The LSR gets a Request message from an upstream peer for a FEC that's in its forwarding table, and the LSR is the egress for that FEC OR it already has a downstream mapping for that FEC.
  3. The next hop for a FEC switches to a different LDP peer, and loop detection is configured.
  4. The attributes of a mapping change.
  5. The LSR receives a mapping from the downstream next hop AND
    • a) no upstream mapping has been created OR
    • b) loop detection is configured OR
    • c) the attributes of the mapping have changed.

3.5.7.1.3. Downstream on Demand Label Advertisement ๐Ÿงš

Usually the upstream LSR is the one in charge of requesting label mappings when things are running in Downstream on Demand mode. BUT, unless some rules get followed, neighboring LSRs with different advertisement modes can end up in a livelock ๐Ÿ˜ญ Everything looks like it's working fine, and yet no labels ever get distributed.

Picture two LSRs, Ru and Rd, where Ru is the upstream LSR and Rd is the downstream LSR for a particular FEC. Ru is using Downstream Unsolicited advertisement mode and Rd is using Downstream on Demand mode. Rd might assume that Ru will request a label mapping whenever it wants one, and Ru might assume that Rd will advertise a label if it wants Ru to use one. If Rd and Ru both operate the way I just described, no labels get distributed from Rd to Ru. Oof ๐Ÿ’€

The fix is to follow this rule: an LSR operating in Downstream on Demand mode should not be expected to send unsolicited mapping advertisements. So if the downstream LSR is in Downstream on Demand mode, the upstream LSR is responsible for requesting label mappings as needed. Problem solved, periodt ๐Ÿ‘‘

3.5.7.1.4. Downstream Unsolicited Label Advertisement ๐ŸŽ€

Generally, the downstream LSR is the one responsible for advertising a label mapping when it wants an upstream LSR to use that label. An upstream LSR can send a mapping request if it wants to ๐Ÿ’œ

Here's a tricky combo ๐Ÿ‘€ Downstream Unsolicited mode plus conservative label retention can lead to an LSR releasing a label for a FEC that it later needs. For example, if LSR Rd advertises to LSR Ru the label for a FEC where Rd isn't Ru's next hop, Ru will release that label. Then if Ru's next hop for the FEC later changes to Rd, Ru needs the label it already let go of ๐Ÿ˜ฉ

So there are two ways to fix this. Either Ru explicitly requests the label when it needs it, or Rd periodically readvertises it to Ru. In a lot of situations Ru will know when it needs the label from Rd, like when its next hop for the FEC changes to Rd. But sometimes Ru won't know. For example, Rd might be trying to set up an LSP with non-standard properties. Making Ru explicitly request the label in that situation would force it to keep state about a potential LSP with non-standard properties, and nobody wants that mess ๐Ÿ™ƒ

So here's the split. When Ru knows it needs the label, it's responsible for explicitly requesting it with a Label Request message. When Ru might not know it needs the label, Rd is responsible for periodically readvertising it to Ru.

For this version of LDP, the only situation where Ru knows it needs a label for a FEC from Rd is when Rd is its next hop for the FEC, Ru doesn't have a label from Rd, and the LSP for the FEC is one that can be established with TLVs defined in this document. โœจ

3.5.8. Label Request Message ๐Ÿ”ฅ

An LSR sends the Label Request Message to an LDP peer when it wants that peer to hand over a binding (mapping) for a FEC ๐Ÿ™Œ

The encoding for the Label Request Message is:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|   Label Request (0x0401)    |      Message Length           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Message ID                                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     FEC TLV                                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Optional Parameters                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Message ID 32-bit value used to identify this message.

FEC TLV The FEC for which a label is being requested. See Section "FEC TLV" for encoding.

Optional Parameters This variable length field contains 0 or more parameters, each encoded as a TLV. The optional parameters are:

 Optional Parameter     Length       Value

 Hop Count TLV          1            See below
 Path Vector TLV        variable     See below

The encodings for the Hop Count, and Path Vector TLVs can be found in Section "TLV Encodings for Commonly Used Parameters".

Hop Count Specifies the running total of the number of LSR hops along the LSP being setup by the Label Request Message. Section "Hop Count Procedures" describes how to handle this TLV.

Path Vector Specifies the LSRs along the LSR being setup by the Label Request Message. Section "Path Vector Procedures" describes how to handle this TLV.

3.5.8.1. Label Request Message Procedures ๐Ÿฆ‹

The Request message is how an upstream LSR explicitly asks the downstream LSR to assign and advertise a label for a FEC ๐Ÿ’–

An LSR may send a Request message under any of these conditions:

  1. The LSR spots a new FEC in its forwarding table, the next hop is an LDP peer, and the LSR doesn't already have a mapping from the next hop for that FEC.
  2. The next hop to the FEC changes, and the LSR doesn't already have a mapping from that next hop for the FEC.

Note that if the LSR already has a pending Label Request message for the new next hop, it should not send an additional Label Request in response to the next hop change. Big brain move ๐Ÿง 

  1. The LSR gets a Label Request for a FEC from an upstream LDP peer, the FEC next hop is an LDP peer, and the LSR doesn't already have a mapping from the next hop.

Note that since a non-merge LSR must set up a separate LSP for each upstream peer requesting a label, it must send a separate Label Request for each such peer. As a result, a non-merge LSR may have multiple Label Request messages for a given FEC outstanding at the same time ๐ŸŒˆ

The receiving LSR should respond to a Label Request message with a Label Mapping for the requested label, or with a Notification message explaining why it can't satisfy the request.

When the FEC being requested is a Prefix FEC Element or a Host Address FEC Element, the receiving LSR uses its routing table to decide how to respond. Unless its routing table includes an entry that exactly matches the requested Prefix or Host Address, the LSR must respond with a No Route Notification message. ๐Ÿ™ˆ

The message ID of the Label Request message is the identifier for the Label Request transaction. When the receiving LSR responds with a Label Mapping message, that mapping message must include a Label Request/Returned Message ID TLV optional parameter, which includes the message ID of the Label Request message. Also, since LSRs use Label Request message IDs as transaction identifiers, an LSR should not reuse the message ID of a Label Request message until the matching transaction completes ๐ŸŽ€

This version of the protocol defines the following Status Codes for the Notification message that signals a request cannot be satisfied:

  • No Route The FEC for which a label was requested includes a FEC Element for which the LSR does not have a route.
  • No Label Resources The LSR cannot provide a label because of resource limitations. When resources become available, the LSR must notify the requesting LSR by sending a Notification message with the Label Resources Available Status Code.

An LSR that receives a No Label Resources response to a Label Request message must not issue further Label Request messages until it receives a Notification message with the Label Resources Available Status code. Patience is a virtue, bestie ๐Ÿซ 

  • Loop Detected The LSR has detected a looping Label Request message. ๐Ÿ”

See Appendix A "LDP Label Distribution Procedures" for more details. ๐Ÿ“–

3.5.9. Label Abort Request Message โœจ

okay so the Label Abort Request message is how an LSR can cancel a Label Request that's still hanging out waiting for an answer ๐Ÿซถ

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |0|   Label Abort Req (0x0404)  |      Message Length           |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Message ID                                |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     FEC TLV                                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Label Request Message ID TLV              |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Optional Parameters                       |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • Message ID: a 32-bit value that identifies this message ๐Ÿ”ข
  • FEC TLV: identifies the FEC that the Label Request is being aborted for ๐ŸŽฏ
  • Label Request Message ID TLV: carries the message ID of the Label Request message that's being aborted ๐Ÿงพ
  • Optional Parameters: no optional parameters are defined for the Label Abort Req message, so there's nothing extra to add here ๐Ÿ™…โ€โ™€๏ธ

3.5.9.1. Label Abort Request Message Procedures ๐Ÿ’…

so an LSR Ru may send a Label Abort Request message to abort an outstanding Label Request message for a FEC that was sent to LSR Rd, and it can do that in these situations:

  1. Ru's next hop for the FEC has changed from LSR Rd to LSR X; or
  2. Ru is a non-merge, non-ingress LSR and has received a Label Abort Request for the FEC from an upstream peer Y.
  3. Ru is a merge, non-ingress LSR and has received a Label Abort Request for the FEC from an upstream peer Y, and Y is the only (last) upstream LSR requesting a label for the FEC.

there can be other situations where an LSR decides to abort a pending Label Request to free up resources tied to the pending LSP ๐Ÿง  but LDP doesn't go into general strategies for using the abort mechanism, since that's beyond its scope ๐Ÿ™ˆ

when an LSR gets a Label Abort Request message and it hasn't already replied to the Label Request being aborted with a Label Mapping message or some other Notification message, it must acknowledge the abort by sending back a Label Request Aborted Notification message ๐Ÿ’– that Notification has to include a Label Request Message ID TLV carrying the message ID of the aborted Label Request message.

if an LSR gets a Label Abort Request Message after it has already replied to that Label Request with a Label Mapping message or a Notification message, it ignores the abort request ๐Ÿ™ƒ

if an LSR gets a Label Mapping message in response to a Label Request message after it has already sent a Label Abort Request message to abort that Label Request, the label in the Label Mapping message is valid ๐ŸŽ€ the LSR may choose to use the label or to release it with a Label Release message.

an LSR that is aborting a Label Request message may not reuse the Message ID for that Label Request message until it gets one of the following from its peer:

  • a Label Request Aborted Notification message acknowledging the abort;
  • a Label Mapping message in response to the Label Request message being aborted;
  • a Notification message in response to the Label Request message being aborted (e.g., Loop Detected, No Label Resources, etc.).

to protect itself from tardy peers or buggy peer implementations ๐Ÿ› an LSR may choose to time out while waiting for the above. the time out period should be relatively long (several minutes). if that time out period passes with no reply from the peer, the LSR may reuse the Message Id of the Label Request message, and if it does, it should also throw away any record of the outstanding Label Request and Label Abort messages ๐Ÿงน

one important thing ๐Ÿ‘‘ the response to a Label Abort Request message is never "ordered". the response doesn't depend on the downstream state of the LSP setup being aborted. so an LSR that receives a Label Abort Request message must process it immediately, no matter what the downstream state of the LSP is, and then respond with a Label Request Aborted Notification or ignore it, whichever is appropriate โšก


3.5.10. Label Withdraw Message ๐Ÿฆ‹

an LSR sends a Label Withdraw message to an LDP peer to tell that peer it can't keep using specific FEC-label mappings the LSR had previously advertised ๐Ÿ™…โ€โ™€๏ธ this breaks the mapping between the FECs and the labels ๐Ÿ’”

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |0|   Label Withdraw (0x0402)   |      Message Length           |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Message ID                                |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     FEC TLV                                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Label TLV (optional)                      |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Optional Parameters                       |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • Message ID: a 32-bit value that identifies this message ๐Ÿ”ข
  • FEC TLV: identifies the FEC whose FEC-label mapping is being withdrawn ๐ŸŽฏ
  • Optional Parameters: this variable length field holds 0 or more parameters, each one encoded as a TLV ๐Ÿงฉ the optional parameters are:
   Optional Parameter    Length       Value

   Label TLV             variable     See below

The encoding for Label TLVs is found in Section "Label TLVs".

  • Label: if present, specifies the label being withdrawn (see the procedures below) ๐Ÿท๏ธ

3.5.10.1. Label Withdraw Message Procedures ๐Ÿ’…

an LSR sends a Label Withdraw message under these conditions:

  1. The LSR no longer recognizes a previously known FEC for which it has advertised a label.
  2. The LSR has decided on its own (e.g., via configuration) to stop label switching a FEC (or FECs) using the label mapping being withdrawn.

the FEC TLV specifies the FEC whose labels are to be withdrawn. if there's no Label TLV after the FEC, then all labels associated with that FEC are to be withdrawn. otherwise, only the label in the optional Label TLV is to be withdrawn ๐ŸŽ€

the FEC TLV may contain the Wildcard FEC Element. if it does, it may not contain any other FEC Elements ๐ŸŒˆ in that case, if the Label Withdraw message has an optional Label TLV, then the label is to be withdrawn from all the FECs it's bound to. if there's no optional Label TLV in the Label Withdraw message, then the sending LSR is withdrawing all the label mappings it previously advertised to the receiving LSR.

an LSR that gets a Label Withdraw message must respond with a Label Release message ๐Ÿซถ

see Appendix A "LDP Label Distribution Procedures" for more details ๐Ÿ“–


3.5.11. Label Release Message ๐Ÿงš

an LSR sends a Label Release message to an LDP peer to tell that peer the LSR doesn't need specific FEC-label mappings it previously requested from and/or was advertised by that peer ๐ŸŒธ

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |0|   Label Release (0x0403)   |      Message Length            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Message ID                                |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     FEC TLV                                   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Label TLV (optional)                      |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Optional Parameters                       |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • Message ID: a 32-bit value that identifies this message ๐Ÿ”ข
  • FEC TLV: identifies the FEC whose FEC-label mapping is being released ๐ŸŽฏ
  • Optional Parameters: this variable length field holds 0 or more parameters, each one encoded as a TLV ๐Ÿงฉ the optional parameters are:
   Optional Parameter    Length       Value

   Label TLV             variable     See below

The encodings for Label TLVs are found in Section "Label TLVs".

  • Label: if present, the label being released (see the procedures below) ๐Ÿท๏ธ

3.5.11.1. Label Release Message Procedures โœจ

an LSR sends a Label Release message to a peer when it no longer needs a label it previously received from or requested of that peer ๐Ÿ’…

an LSR must send a Label Release message under any of these conditions:

  1. The LSR which sent the label mapping is no longer the next hop for the mapped FEC, and the LSR is configured for conservative operation.
  2. The LSR receives a label mapping from an LSR which is not the next hop for the FEC, and the LSR is configured for conservative operation.
  3. The LSR receives a Label Withdraw message.

heads up ๐Ÿšจ if an LSR is configured for "liberal mode", a release message will never be sent in the case of conditions (1) and (2) above. in that case, the upstream LSR keeps each unused label, so it can be used right away later if the downstream peer becomes the next hop for the FEC ๐Ÿฆ‹

the FEC TLV specifies the FEC whose labels are to be released. if there's no Label TLV after the FEC, then all labels associated with that FEC are to be released. otherwise, only the label in the optional Label TLV is to be released ๐Ÿ’–

the FEC TLV may contain the Wildcard FEC Element. if it does, it may not contain any other FEC Elements ๐ŸŒˆ in that case, if the Label Release message has an optional Label TLV, then the label is to be released for all the FECs it's bound to. if there's no optional Label TLV in the Label Release message, then the sending LSR is releasing all the label mappings it previously learned from the receiving LSR.

see Appendix A "LDP Label Distribution Procedures" for more details ๐Ÿ“–


3.6. Messages and TLVs for Extensibility ๐ŸŒธ

okay this part is all about extensibility, which is basically how LDP stays future-proof ๐Ÿ”ฎ support for it includes the rules for the U and F bits, and those rules say how an LSR should handle unknown TLVs and messages ๐Ÿง 

this section specifies TLVs and messages for vendor-private and experimental use ๐Ÿงช

3.6.1. LDP Vendor-private Extensions ๐Ÿซง

vendor-private TLVs and messages are used to carry vendor-private information between LSRs ๐Ÿคซ

3.6.1.1. LDP Vendor-private TLVs

okay bestie, the Type range 0x3E00 through 0x3EFF is reserved for vendor-private TLVs ๐ŸŽ€ it's like a VIP section just for vendors โœจ

here's how a vendor-private TLV is encoded ๐Ÿ‘‡

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |U|F|    Type (0x3E00-0x3EFF)   |            Length             |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Vendor ID                           |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                                                               |
   |                           Data....                            |
   ~                                                               ~
   |                                                               |
   |                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

the U bit is the "unknown TLV" bit, and it decides what happens when a receiver meets a TLV it doesn't recognise ๐Ÿง if U is clear (=0), a notification must be returned to the message originator and the entire message must be ignored ๐Ÿ˜ญ if U is set (=1), the unknown TLV is silently ignored and the rest of the message is processed as if the unknown TLV did not exist ๐Ÿ’…

the way vendor-private TLVs get understood is based on the Type and the mandatory Vendor ID field, so both of those together are the main character here ๐Ÿ‘‘

the F bit is the "forward unknown TLV" bit ๐Ÿฆ‹ it only applies when the U bit is set and the LDP message containing the unknown TLV is is to be forwarded. if F is clear (=0), the unknown TLV is not forwarded with the containing message. if F is set (=1), it is forwarded with the containing message ๐Ÿซถ

  • Type: a value in the range 0x3E00 through 0x3EFF. the Type and Vendor Id field together tell you how the Data field should be interpreted ๐Ÿ“
  • Length: the cumulative length in octets of the Vendor ID and Data fields ๐Ÿ’œ
  • Vendor Id: an 802 Vendor ID, assigned by the IEEE ๐ŸŒˆ
  • Data: whatever octets are left after the Vendor ID in the Value field. this stuff is optional and vendor-dependent ๐Ÿงš

3.6.1.2. LDP Vendor-private Messages

the Message Type range 0x3E00 through 0x3EFF is reserved for vendor-private Messages too, so vendors get a whole range of message types to flex with ๐Ÿ’…

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |U|    Msg Type (0x3E00-0x3EFF) |      Message Length           |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Message ID                                |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                     Vendor ID                                 |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   +                                                               +
   |                     Remaining Mandatory Parameters            |
   +                                                               +
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                                                               |
   +                                                               +
   |                     Optional Parameters                       |
   +                                                               +
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

the U bit here is the "unknown message" bit ๐ŸŒธ if U is clear (=0), a notification is returned to the message originator. if U is set (=1), the unknown message is silently ignored ๐Ÿ™ˆ

just like the TLV version, whether a vendor-private message is understood depends on the Msg Type and the Vendor ID parameter, so those two are a power couple ๐Ÿ‘‘

  • Msg Type: a message type value in the range 0x3E00 through 0x3EFF. the Msg Type and the Vendor ID together say how the message should be interpreted ๐ŸŽ€
  • Message Length: the cumulative length in octets of the Message ID, Vendor ID, Remaining Mandatory Parameters and Optional Parameters ๐Ÿงฎ
  • Message ID: a 32-bit integer that identifies this message. the sending LSR uses it to help figure out which notification messages apply to this message ๐Ÿ”ฅ an LSR that sends a notification in response to this message includes this Message Id in that notification; see Section "Notification Message" โœจ
  • Vendor ID: an 802 Vendor ID, assigned by the IEEE ๐ŸŒˆ
  • Remaining Mandatory Parameters: a variable length set of the remaining required message parameters ๐Ÿ’–
  • Optional Parameters: a variable length set of optional message parameters ๐Ÿฆ‹

3.6.2. LDP Experimental Extensions

LDP support for experimentation is kinda like the vendor-private stuff, just with a few key differences ๐Ÿงช

  • the Type range 0x3F00 through 0x3FFF is reserved for experimental TLVs ๐Ÿ’œ
  • the Message Type range 0x3F00 through 0x3FFF is reserved for experimental messages ๐Ÿ’œ
  • the encodings for experimental TLVs and messages look a lot like the vendor-private encodings, with one difference ๐Ÿ‘€

experimental TLVs and messages use an Experiment ID field in place of a Vendor ID field. the Experiment ID field goes together with the Type or Message Type field to specify how the experimental TLV or message is interpreted ๐Ÿง 

administration of Experiment IDs is the responsibility of the experimenters ๐Ÿซถ

3.7. Message Summary

here's the lineup of LDP messages defined in this version of the protocol ๐Ÿ“‹

   Message Name            Type     Section Title

   Notification            0x0001   "Notification Message"
   Hello                   0x0100   "Hello Message"
   Initialization          0x0200   "Initialization Message"
   KeepAlive               0x0201   "KeepAlive Message"
   Address                 0x0300   "Address Message"
   Address Withdraw        0x0301   "Address Withdraw Message"
   Label Mapping           0x0400   "Label Mapping Message"
   Label Request           0x0401   "Label Request Message"
   Label Withdraw          0x0402   "Label Withdraw Message"
   Label Release           0x0403   "Label Release Message"
   Label Abort Request     0x0404   "Label Abort Request Message"
   Vendor-Private          0x3E00-  "LDP Vendor-private Extensions"
                           0x3EFF
   Experimental            0x3F00-  "LDP Experimental Extensions"
                           0x3FFF

3.8. TLV Summary

and here are the TLVs defined in this version of the protocol ๐ŸŽ€

   TLV                      Type      Section Title

   FEC                      0x0100    "FEC TLV"
   Address List             0x0101    "Address List TLV"
   Hop Count                0x0103    "Hop Count TLV"
   Path Vector              0x0104    "Path Vector TLV"
   Generic Label            0x0200    "Generic Label TLV"
   ATM Label                0x0201    "ATM Label TLV"
   Frame Relay Label        0x0202    "Frame Relay Label TLV"
   Status                   0x0300    "Status TLV"
   Extended Status          0x0301    "Notification Message"
   Returned PDU             0x0302    "Notification Message"
   Returned Message         0x0303    "Notification Message"
   Common Hello             0x0400    "Hello Message"
      Parameters
   IPv4 Transport Address   0x0401    "Hello Message"
   Configuration            0x0402    "Hello Message"
      Sequence Number
   IPv6 Transport Address   0x0403    "Hello Message"
   Common Session           0x0500    "Initialization Message"
      Parameters
   ATM Session Parameters   0x0501    "Initialization Message"
   Frame Relay Session      0x0502    "Initialization Message"
      Parameters
   Label Request            0x0600    "Label Mapping Message"
       Message ID
   Vendor-Private           0x3E00-   "LDP Vendor-private Extensions"
                            0x3EFF
   Experimental             0x3F00-   "LDP Experimental Extensions"
                            0x3FFF

3.9. Status Code Summary

these are the Status Codes defined in this version of the protocol ๐Ÿšฆ

the "E" column is the required setting of the Status Code E-bit, and the "Status Data" column is the value of the 30-bit Status Data field in the Status Code TLV ๐Ÿ’…

heads up: the setting of the Status Code F-bit is up to the LSR that originates the Status TLV ๐Ÿ‘€

   Status Code           E   Status Data   Section Title

   Success               0   0x00000000    "Status TLV"
   Bad LDP Identifier    1   0x00000001    "Events Signaled by ..."
   Bad Protocol Version  1   0x00000002    "Events Signaled by ..."
   Bad PDU Length        1   0x00000003    "Events Signaled by ..."
   Unknown Message Type  0   0x00000004    "Events Signaled by ..."
   Bad Message Length    1   0x00000005    "Events Signaled by ..."
   Unknown TLV           0   0x00000006    "Events Signaled by ..."
   Bad TLV length        1   0x00000007    "Events Signaled by ..."
   Malformed TLV Value   1   0x00000008    "Events Signaled by ..."
   Hold Timer Expired    1   0x00000009    "Events Signaled by ..."
   Shutdown              1   0x0000000A    "Events Signaled by ..."
   Loop Detected         0   0x0000000B    "Loop Detection"
   Unknown FEC           0   0x0000000C    "FEC Procedures"
   No Route              0   0x0000000D    "Label Request Mess ..."
   No Label Resources    0   0x0000000E    "Label Request Mess ..."
   Label Resources /     0   0x0000000F    "Label Request Mess ..."
       Available
   Session Rejected/     1   0x00000010    "Session Initialization"
      No Hello
   Session Rejected/     1   0x00000011    "Session Initialization"
      Parameters Advertisement Mode
   Session Rejected/     1   0x00000012    "Session Initialization"
      Parameters Max PDU Length
   Session Rejected/     1   0x00000013    "Session Initialization"
      Parameters Label Range
   KeepAlive Timer       1   0x00000014    "Events Signaled by ..."
       Expired
   Label Request Aborted 0   0x00000015    "Label Request Abort ..."
   Missing Message       0   0x00000016    "Events Signaled by ..."
       Parameters
   Unsupported Address   0   0x00000017    "FEC Procedures"
       Family                              "Address Message Proc ..."

   Session Rejected/     1   0x00000018    "Session Initialization"
      Bad KeepAlive Time
   Internal Error        1   0x00000019    "Events Signaled by ..."

3.10. Well-known Numbers

3.10.1. UDP and TCP Ports

the UDP port for LDP Hello messages is 646 ๐Ÿ“ก

the TCP port for establishing LDP session connections is 646 ๐Ÿ”Œ

3.10.2. Implicit NULL Label

the Implicit NULL label (see [RFC3031]) is represented as a Generic Label TLV with a Label field value as specified by [RFC3032] ๐Ÿงš

4. IANA Considerations ๐ŸŒธ

LDP defines the following name spaces which require management ๐Ÿ—‚๏ธ

  • Message Type Name Space.
  • TLV Type Name Space.
  • FEC Type Name Space.
  • Status Code Name Space.
  • Experiment ID Name Space.

the following sections give guidelines for managing these name spaces ๐Ÿ’…

4.1. Message Type Name Space โœจ

okay so LDP splits the message type number space into three ranges, and each range has its own vibe ๐Ÿ’…

  • 0x0000 - 0x3DFF ๐ŸŒธ Message types in this range are part of the LDP base protocol. Following the policies outlined in [IANA], message types here are allocated through an IETF Consensus action.
  • 0x3E00 - 0x3EFF ๐ŸŽ€ Message types in this range are reserved for Vendor Private extensions and are the responsibility of the individual vendors (see Section "LDP Vendor-private Messages"). IANA management of this range of the Message Type Name Space is unnecessary.
  • 0x3F00 - 0x3FFF ๐Ÿงš Message types in this range are reserved for Experimental extensions and are the responsibility of the individual experimenters (see Sections "LDP Experimental Extensions" and "Experiment ID Name Space"). IANA management of this range of the Message Type Name Space is unnecessary. However, IANA is responsible for managing part of the Experiment ID Name Space (see below).

4.2. TLV Type Name Space ๐Ÿฆ‹

TLV types get the same three-range treatment, so it's giving dรฉjร  vu, but the rules are slightly different in the details ๐Ÿ‘€

  • 0x0000 - 0x3DFF ๐ŸŒˆ TLV types in this range are part of the LDP base protocol. Following the policies outlined in [IANA], TLV types in this range are allocated through an IETF Consensus action.
  • 0x3E00 - 0x3EFF ๐Ÿ’œ TLV types in this range are reserved for Vendor Private extensions and are the responsibility of the individual vendors (see Section "LDP Vendor-private TLVs"). IANA management of this range of the TLV Type Name Space is unnecessary.
  • 0x3F00 - 0x3FFF ๐ŸŒธ TLV types in this range are reserved for Experimental extensions and are the responsibility of the individual experimenters (see Sections "LDP Experimental Extensions" and "Experiment ID Name Space"). IANA management of this range of the TLV Name Space is unnecessary. However, IANA is responsible for managing part of the Experiment ID Name Space (see below).

4.3. FEC Type Name Space ๐Ÿ“

the FEC types live in 0 - 255, and the whole range is split up by policy ๐Ÿซถ

Following the policies outlined in [IANA], FEC types in the range 0 - 127 are allocated through an IETF Consensus action, types in the range 128 - 191 are allocated as First Come First Served, and types in the range 192 - 255 are reserved for Private Use.

4.4. Status Code Name Space โญ

status codes run from 0x00000000 - 0x3FFFFFFF, and the tea is in the splits ๐Ÿต

Following the policies outlined in [IANA], Status Codes in the range 0x00000000 - 0x1FFFFFFF are allocated through an IETF Consensus action, codes in the range 0x20000000 - 0x3EFFFFFF are allocated as First Come First Served, and codes in the range 0x3F000000 - 0x3FFFFFFF are reserved for Private Use.

4.5. Experiment ID Name Space ๐Ÿงช

the Experiment Ids go all the way from 0x00000000 - 0xffffffff, which is the full 32-bit buffet ๐Ÿฝ๏ธ

Following the policies outlined in [IANA], Experiment Ids in the range 0x00000000 - 0xefffffff are allocated as First Come First Served and Experiment Ids in the range 0xf0000000 - 0xffffffff are reserved for Private Use.


5. Security Considerations ๐Ÿ”

okay bestie, this part is serious, so let's go ๐Ÿฅน This section identifies threats to which LDP may be vulnerable and discusses means by which those threats might be mitigated.

5.1. Spoofing ๐ŸŽญ

there are two types of LDP communication that could be the target of a spoofing attack ๐Ÿ‘€

  1. Discovery exchanges carried by UDP.

LSRs directly connected at the link level exchange Basic Hello messages over the link. The threat of spoofed Basic Hellos can be reduced by:

  • Accepting Basic Hellos only on interfaces to which LSRs that can be trusted are directly connected.
  • Ignoring Basic Hellos not addressed to the All Routers on this Subnet multicast group.

LSRs not directly connected at the link level may use Extended Hello messages to indicate willingness to establish an LDP session. An LSR can reduce the threat of spoofed Extended Hellos by filtering them and accepting only those originating at sources permitted by an access list.

  1. Session communication carried by TCP.

LDP specifies use of the TCP MD5 Signature Option to provide for the authenticity and integrity of session messages.

[RFC2385] asserts that MD5 authentication is now considered by some to be too weak for this application. It also points out that a similar TCP option with a stronger hashing algorithm (it cites SHA-1 as an example) could be deployed. To our knowledge no such TCP option has been defined and deployed. However, we note that LDP can use whatever TCP message digest techniques are available, and when one stronger than MD5 is specified and implemented, upgrading LDP to use it would be relatively straightforward.

5.2. Privacy ๐Ÿ•ต๏ธโ€โ™€๏ธ

LDP provides no mechanism for protecting the privacy of label distribution. no privacy shield here, bestie ๐Ÿ™ˆ

The security requirements of label distribution protocols are essentially identical to those of the protocols which distribute routing information. By providing a mechanism to ensure the authenticity and integrity of its messages LDP provides a level of security which is at least as good as, though no better than, that which can be provided by the routing protocols themselves. The more general issue of whether privacy should be required for routing protocols is beyond the scope of this document.

One might argue that label distribution requires privacy to address the threat of label spoofing. However, that privacy would not protect against label spoofing attacks since data packets carry labels in the clear. Furthermore, label spoofing attacks can be made without knowledge of the FEC bound to a label.

To avoid label spoofing attacks, it is necessary to ensure that labeled data packets are labeled by trusted LSRs and that the labels placed on the packets are properly learned by the labeling LSRs. ๐Ÿ›ก๏ธ

5.3. Denial of Service ๐Ÿšจ

LDP provides two potential targets for denial of service (DoS) attacks, so let's make sure we know both ๐Ÿฅบ

  1. Well known UDP Port for LDP Discovery

An LSR administrator can address the threat of DoS attacks via Basic Hellos by ensuring that the LSR is directly connected only to peers which can be trusted to not initiate such an attack.

Interfaces to peers interior to the administrator's domain should not represent a threat since interior peers are under the administrator's control. Interfaces to peers exterior to the domain represent a potential threat since exterior peers are not. An administrator can reduce that threat by connecting the LSR only to exterior peers that can be trusted to not initiate a Basic Hello attack.

DoS attacks via Extended Hellos are potentially a more serious threat. This threat can be addressed by filtering Extended Hellos using access lists that define addresses with which extended discovery is permitted. However, performing the filtering requires LSR resource.

In an environment where a trusted MPLS cloud can be identified, LSRs at the edge of the cloud can be used to protect interior LSRs against DoS attacks via Extended Hellos by filtering out Extended Hellos originating outside of the trusted MPLS cloud, accepting only those originating at addresses permitted by access lists. This filtering protects LSRs in the interior of the cloud but consumes resources at the edges.

  1. Well known TCP port for LDP Session Establishment

Like other control plane protocols that use TCP, LDP may be the target of DoS attacks, such a SYN attacks. LDP is no more or less vulnerable to such attacks than other control plane protocols that use TCP.

The threat of such attacks can be mitigated somewhat by the following:

  • An LSR should avoid promiscuous TCP listens for LDP session establishment. It should use only listens that are specific to discovered peers. This enables it to drop attack packets early in their processing since they are less likely to match existing or in-progress connections.
  • The use of the MD5 option helps somewhat since it prevents a SYN from being accepted unless the MD5 segment checksum is valid. However, the receiver must compute the checksum before it can decide to discard an otherwise acceptable SYN segment.
  • The use of access list mechanisms applied at the boundary of the MPLS cloud in a manner similar to that suggested above for Extended Hellos can protect the interior against attacks originating from outside the cloud.

6. Areas for Future Study ๐Ÿ”ญ

the following topics are not addressed in this version of LDP, so they're the future plotlines ๐Ÿ“–

  • Section 2.16 of the MPLS architecture [RFC3031] requires that the initial label distribution protocol negotiation between peer LSRs enable each LSR to determine whether its peer is capable of popping the label stack. This version of LDP assumes that LSRs support label popping for all link types except ATM and Frame Relay. A future version may specify means to make this determination part of the session initiation negotiation.
  • LDP support for CoS is not specified in this version. CoS support may be addressed in a future version.
  • LDP support for multicast is not specified in this version. Multicast support may be addressed in a future version.
  • LDP support for multipath label switching is not specified in this version. Multipath support may be addressed in a future version.

7. Intellectual Property Considerations โš–๏ธ

the IETF has been notified of intellectual property rights claimed in regard to some or all of the specification contained in this document. For more information consult the online list of claimed rights.

8. Acknowledgments ๐Ÿซถ

the ideas and text in this document have been collected from a number of sources, so big shoutouts to everyone who helped out ๐Ÿ’– We would like to thank Rick Boivie, Ross Callon, Alex Conta, Eric Gray, Yoshihiro Ohba, Eric Rosen, Bernard Suter, Yakov Rekhter, and Arun Viswanathan. ๐ŸŒŸ

9. References ๐Ÿ“š

okay bestie, this is the bibliography, and it's giving whole research era ๐ŸŽ€ every source this spec leans on is listed here, with all the details, so you can go find them yourself ๐Ÿ”

  • [ATM-VP] N. Feldman, B. Jamoussi, S. Komandur, A, Viswanathan, T Worster, "MPLS using ATM VP Switching", Work in Progress.
  • [CRLDP] L. Andersson, A. Fredette, B. Jamoussi, R. Callon, P. Doolan, N. Feldman, E. Gray, J. Halpern, J. Heinanen T. E. Kilty, A. G. Malis, M. Girish, K. Sundell, P. Vaananen, T. Worster, L. Wu, R. Dantu, "Constraint-Based LSP Setup using LDP", Work in Progress.
  • [DIFFSERV] Blake, S., Black, D., Carlson, M., Davies, E., Wang, Z. and W. Weiss, "An Architecture for Differentiated Services", RFC 2475, December 1998.
  • [IANA] Narten, T. and H. Alvestrand, "Guidelines for Writing an IANA Considerations Section in RFCs", BCP 26, RFC 2434, October 1998.
  • [RFC1321] Rivest, R., "The MD5 Message-Digest Algorithm," RFC 1321, April 1992.
  • [RFC1483] Heinanen, J., "Multiprotocol Encapsulation over ATM Adaptation Layer 5", RFC 1483, July 1993.
  • [RFC2328] Moy, J., "OSPF Version 2", STD 54, RFC 2328, April 1998.
  • [RFC1700] Reynolds, J. and J. Postel, "ASSIGNED NUMBERS", STD 2, RFC 1700, October 1994.
  • [RFC1771] Rekhter, Y. and T. Li, "A Border Gateway Protocol 4 (BGP-4)", RFC 1771, March 1995.
  • [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.
  • [RFC2205] Braden, R., Zhang, L., Berson, S., Herzog, S. and S. Jamin, "Resource ReSerVation Protocol (RSVP) -- Version 1 Functional Specification", RFC 2205, September 1997.
  • [RFC2385] Heffernan, A., "Protection of BGP Sessions via the TCP MD5 Signature Option", RFC 2385, August 1998.
  • [RFC2702] Awduche, D., Malcolm, J., Agogbua, J., O'Dell, M. and J. McManus, "Requirements for Traffic Engineering over MPLS", RFC 2702, September 1999.
  • [RFC3031] Rosen, E., Viswanathan, A. and R. Callon, "Multiprotocol Label Switching Architecture", RFC 3031, January 2001.
  • [RFC3032] Rosen, E., Rekhter, Y., Tappan, D., Farinacci, D., Fedorkow, G., Li, T. and A. Conta, "MPLS Label Stack Encoding", RFC 3032, January 2001.
  • [RFC3034] Conta, A., Doolan, P. and A. Malis, "Use of Label Switching on Frame Relay Networks Specification", RFC 3034, January 2001.
  • [RFC3035] Davie, B., Lawrence, J., McCloghrie, K., Rekhter, Y., Rosen, E., Swallow, G. and P. Doolan, "MPLS using LDP and ATM VC Switching", RFC 3035, January 2001.
  • [RFC3037] Thomas, B. and E. Gray, "LDP Applicability", RFC 3037, January 2001.

10. Authors' Addresses ๐Ÿ’Œ

these are the lovely people who wrote this spec, with their contact info, so you can slide into their inbox if you have questions ๐Ÿ’–

Loa Andersson
Nortel Networks Inc
St Eriksgatan 115, PO Box 6701
113 85 Stockholm
Sweden

Phone: +46 8 5088 36 34
Mobile: +46 70 522 78 34
EMail: loa.andersson@nortelnetworks.com


Paul Doolan
Ennovate Networks
60 Codman Hill Rd
Marlborough MA 01719

Phone: 978-263-2002
EMail: pdoolan@ennovatenetworks.com


Nancy Feldman
IBM Research
30 Saw Mill River Road
Hawthorne, NY 10532

Phone:  914-784-3254
EMail: nkf@us.ibm.com


Andre Fredette
PhotonEx Corporation
8C Preston Court
Bedford, MA 01730

Phone: 781-301-4655
EMail: fredette@photonex.com


Bob Thomas
Cisco Systems, Inc.
250 Apollo Dr.
Chelmsford, MA 01824

Phone:  978-244-8078
EMail: rhthomas@cisco.com

Appendix A. LDP Label Distribution Procedures ๐ŸŒธ

this appendix is where the spec gets very precise about what an LSR does when stuff happens ๐Ÿงš it lists the events, then explains how each one gets handled

This section specifies label distribution behavior in terms of LSR response to the following events:

  • Receive Label Request Message;
  • Receive Label Mapping Message;
  • Receive Label Abort Request Message;
  • Receive Label Release Message;
  • Receive Label Withdraw Message;
  • Recognize new FEC;
  • Detect change in FEC next hop;
  • Receive Notification Message / Label Request Aborted;
  • Receive Notification Message / No Label Resources;
  • Receive Notification Message / No Route;
  • Receive Notification Message / Loop Detected;
  • Receive Notification Message / Label Resources Available;
  • Detect local label resources have become available;
  • LSR decides to no longer label switch a FEC;
  • Timeout of deferred label request.

The specification of LSR behavior in response to an event has three parts:

  1. Summary. Prose that describes LSR response to the event in overview.
  2. Context. A list of elements referred to by the Algorithm part of the specification. (See 3.)
  3. Algorithm. An algorithm for LSR response to the event.

The Summary may omit details of the LSR response, such as bookkeeping action or behavior dependent on the LSR label advertisement mode, control mode, or label retention mode in use. The intent is that the Algorithm fully and unambiguously specify the LSR response.

The algorithms in this section use procedures defined in the MPLS architecture specification [RFC3031] for hop-by-hop routed traffic. These procedures are:

  • Label Distribution procedure, which is performed by a downstream LSR to determine when to distribute a label for a FEC to LDP peers. The architecture defines four Label Distribution procedures:
    • . Downstream Unsolicited Independent Control, called PushUnconditional in [RFC3031].
    • . Downstream Unsolicited Ordered Control, called PushConditional in [RFC3031].
    • . Downstream On Demand Independent Control, called PulledUnconditional in [RFC3031].
    • . Downstream On Demand Ordered Control, called PulledConditional in [RFC3031].
  • Label Withdrawal procedure, which is performed by a downstream LSR to determine when to withdraw a FEC label mapping previously distributed to LDP peers. The architecture defines a single Label Withdrawal procedure. Whenever an LSR breaks the binding between a label and a FEC, it must withdraw the FEC label mapping from all LDP peers to which it has previously sent the mapping.
  • Label Request procedure, which is performed by an upstream LSR to determine when to explicitly request that a downstream LSR bind a label to a FEC and send it the corresponding label mapping. The architecture defines three Label Request procedures:
    • . Request Never. The LSR never requests a label.
    • . Request When Needed. The LSR requests a label whenever it needs one.
    • . Request On Request. This procedure is used by non-label merging LSRs. The LSR requests a label when it receives a request for one, in addition to whenever it needs one.
  • Label Release procedure, which is performed by an upstream LSR to determine when to release a previously received label mapping for a FEC. The architecture defines two Label Release procedures:
    • . Conservative label retention, called Release On Change in [RFC3031].
    • . Liberal label retention, called No Release On Change in [RFC3031].
  • Label Use procedure, which is performed by an LSR to determine when to start using a FEC label for forwarding/switching. The architecture defines three Label Use procedures:
    • . Use Immediate. The LSR immediately uses a label received from a FEC next hop for forwarding/switching.
    • . Use If Loop Free. The LSR uses a FEC label received from a FEC next hop for forwarding/switching only if it has determined that by doing so it will not cause a forwarding loop.
    • . Use If Loop Not Detected. This procedure is the same as Use Immediate unless the LSR has detected a loop in the FEC LSP. Use of the FEC label for forwarding/switching will continue until the next hop for the FEC changes or the loop is no longer detected.

This version of LDP does not include a loop prevention mechanism; therefore, the procedures below do not make use of the Use If Loop Free procedure.

  • Label No Route procedure (called Label Not Available procedure in [RFC3031]), which is performed by an upstream LSR to determine how to respond to a No Route notification from a downstream LSR in response to a request for a FEC label mapping. The architecture specification defines two Label No Route procedures:
    • . Request Retry. The LSR should issue the label request at a later time.
    • . No Request Retry. The LSR should assume the downstream LSR will provide a label mapping when the downstream LSR has a next hop and it should not reissue the request.

A.1. Handling Label Distribution Events ๐Ÿฆ‹

okay so this part is where the algorithms get defined ๐Ÿง  the big takeaway is that your implementation doesn't have to follow these steps line by line, it just has to end up with the exact same effect, and the data structure stuff is left up to you ๐Ÿ’…

This section defines LDP label distribution procedures by specifying an algorithm for each label distribution event. The requirement on an LDP implementation is that its event handling must have the effect specified by the algorithms. That is, an implementation need not follow exactly the steps specified by the algorithms as long as the effect is identical.

The algorithms for handling label distribution events share common actions. The specifications below package these common actions into procedure units. Specifications for these common procedures are in their own section "Common Label Distribution Procedures", which follows this.

An implementation would use data structures to store information about protocol activity. This appendix specifies the information to be stored in sufficient detail to describe the algorithms, and assumes the ability to retrieve the information as needed. It does not specify the details of the data structures.

A.1.1. Receive Label Request ๐ŸŽ€

Summary:

okay so when an LSR gets a FEC label request from an LDP peer, it can do one or more of these things ๐Ÿ’…:

  • send a notification message back to the requesting LSR saying why it can't give a label mapping for the FEC ๐Ÿ™…โ€โ™€๏ธ
  • send a FEC label mapping to the requesting LSR ๐Ÿ’Œ
  • send a FEC label request to the FEC next hop ๐Ÿ“จ
  • install labels for forwarding/switching use โšก

Context:

  • LSR. The LSR handling the event.
  • MsgSource. The LDP peer that sent the message.
  • FEC. The FEC specified in the message.
  • RAttributes. Attributes received with the message. E.g., Hop Count, Path Vector.
  • SAttributes. Attributes to be included in the Label Request message, if any, propagated to the FEC Next Hop.
  • StoredHopCount. The hop count, if any, previously recorded for the FEC.

Algorithm:

LRq.1   Execute procedure Check_Received_Attributes (MsgSource,
        LabelRequest, RAttributes).
        If Loop Detected, goto LRq.13.

LRq.2   Is there a Next Hop for FEC?
        If not, goto LRq.5.

LRq.3   Is MsgSource the Next Hop?
        Ifnot, goto LRq.6.

LRq.4   Execute procedure Send_Notification (MsgSource, Loop
        Detected).
        Goto LRq.13

LRq.5   Execute procedure Send_Notification (MsgSource, No Route).
        Goto LRq.13.

LRq.6   Has LSR previously received a label request for FEC from
        MsgSource?
        If not, goto LRq.8.  (See Note 1.)

LRq.7   Is the label request a duplicate request?
        If so, Goto LRq.13.  (See Note 2.)

LRq.8   Record label request for FEC received from MsgSource and
        mark it pending.

LRq.9   Perform LSR Label Distribution procedure:

      For Downstream Unsolicited Independent Control OR
      For Downstream On Demand Independent Control

         1. Has LSR previously received and retained a label
            mapping for FEC from Next Hop?.
            Is so, set Propagating to IsPropagating.
            If not, set Propagating to NotPropagating.

         2. Execute procedure
            Prepare_Label_Mapping_Attributes(MsgSource, FEC,
            RAttributes, SAttributes, Propagating,
            StoredHopCount).

         3. Execute procedure Send_Label (MsgSource, FEC,
            SAttributes).

         4. Is LSR egress for FEC? OR
            Has LSR previously received and retained a label
            mapping for FEC from Next Hop?
            If so, goto LRq.11.
            If not, goto LRq.10.

      For Downstream Unsolicited Ordered Control OR
      For Downstream On Demand Ordered Control

         1. Is LSR egress for FEC? OR
            Has LSR previously received and retained a label
            mapping for FEC from Next Hop?  (See Note 3.)
            If not, goto LRq.10.

         2. Execute procedure
            Prepare_Label_Mapping_Attributes(MsgSource, FEC,
            RAttributes, SAttributes, IsPropagating,
            StoredHopCount)

         3. Execute procedure Send_Label (MsgSource, FEC,
            SAttributes).
            Goto LRq.11.

LRq.10  Perform LSR Label Request procedure:

      For Request Never

1. Goto LRq.13.

      For Request When Needed OR
      For Request On Request

         1. Execute procedure Prepare_Label_Request_Attributes
            (Next Hop, FEC, RAttributes, SAttributes);

         2. Execute procedure Send_Label_Request (Next Hop, FEC,
            SAttributes).
            Goto LRq.13.

LRq.11  Has LSR successfully sent a label for FEC to MsgSource?
        If not, goto LRq.13.  (See Note 4.)

LRq.12  Perform LSR Label Use procedure.

      For Use Immediate OR
      For Use If Loop Not Detected

         1. Install label sent to MsgSource and label from Next
            Hop (if LSR is not egress) for forwarding/switching
            use.

LRq.13  DONE

Notes:

  1. Okay, so if MsgSource is a non-label merging LSR, it'll send a label request for each upstream LDP peer that asked it for a label for this FEC ๐Ÿ™ƒ. The LSR has to be able to tell those apart from actual duplicate requests coming from a non-label merging MsgSource. To do that, it looks at the message ID of each received Label Request message to spot duplicates. That also means an upstream peer must not reuse a Label Request's message ID until that Label Request transaction is finished ๐Ÿ”’.
  2. When an LSR sends a label request to a peer, it records that the request went out and marks it as outstanding. While a request is marked outstanding, the LSR should not send another request for the same label to that peer, because that second one would be a duplicate ๐Ÿšซ. The Send_Label_Request procedure described below follows this rule. A duplicate label request counts as a protocol error and should be dropped by the receiving LSR (maybe with a proper notification sent back to MsgSource) ๐Ÿ™…โ€โ™€๏ธ.
  3. If the LSR is not merge-capable, this test will fail ๐Ÿงฑ.
  4. The Send_Label procedure can fail if there aren't enough label resources ๐Ÿซ . When that happens, the LSR should not perform the Label Use procedure.

A.1.2. Receive Label Mapping ๐Ÿฆ‹

Summary:

when an LSR gets a FEC label mapping from an LDP peer, it might do one or more of the following ๐ŸŒธ:

  • send a label release message for the FEC label back to that LDP peer ๐Ÿ‘‹
  • send label mapping messages for the FEC to one or more LDP peers ๐Ÿ“ฌ
  • install the newly learned label for forwarding/switching use โœจ

Context:

  • LSR. The LSR handling the event.
  • MsgSource. The LDP peer that sent the message.
  • FEC. The FEC specified in the message.
  • Label. The label specified in the message.
  • PrevAdvLabel. The label for the FEC, if any, previously advertised to an upstream peer.
  • StoredHopCount. The hop count previously recorded for the FEC.
  • RAttributes. Attributes received with the message. E.g., Hop Count, Path Vector.
  • SAttributes. Attributes to be included in the Label Mapping message, if any, propagated to upstream peers.

Algorithm:

LMp.1   Does the received label mapping match an outstanding
        label request for FEC previously sent to MsgSource.
        If not, goto LMp.3.

LMp.2   Delete record of outstanding FEC label request.

LMp.3   Execute procedure Check_Received_Attributes (MsgSource,
        LabelMapping, RAttributes).
        If No Loop Detected, goto LMp.9.

LMp.4   Does the LSR have a previously received label mapping for
        FEC from MsgSource? (See Note 1.)
        If not, goto LMp.8.  (See Note 2.)

LMp.5   Does the label previously received from MsgSource match
        Label (i.e., the label received in the message)?
        (See Note 3.)
        If not, goto LMp.8.  (See Note 4.)

LMp.6   Delete matching label mapping for FEC previously
        received from MsgSource.

LMp.7   Remove Label from forwarding/switching use.  (See Note 5.)
        Goto LMp.33.

LMp.8   Execute procedure Send_Message (MsgSource, Label Release,
        FEC, Label, Loop Detected Status code).  Goto LMp.33.

LMp.9   Does LSR have a previously received label mapping for FEC
        from MsgSource for the LSP in question?  (See Note 6.)
        If not, goto LMp.11.

LMp.10  Does the label previously received from MsgSource match
        Label (i.e., the label received in the message)?
        (See Note 3.)
        If not, goto LMp.32.  (See Note 4.)

LMp.11  Determine the Next Hop for FEC.

LMp.12  Is MsgSource the Next Hop for FEC?
        If so, goto LMp.14.

LMp.13  Perform LSR Label Release procedure:

      For Conservative Label retention:

1. Goto LMp.32.

      For Liberal Label retention:

        1. Record label mapping for FEC with Label and
           RAttributes has been received from MsgSource.
           Goto LMp.33.

LMp.14  Is LSR an ingress for FEC?
        If not, goto LMp.16.

LMp.15  Install Label for forwarding/switching use.

LMp.16  Record label mapping for FEC with Label and RAttributes
        has been received from MsgSource.

LMp.17  Iterate through LMp.31 for each Peer.  (See Note 7).

LMp.18  Has LSR previously sent a label mapping for FEC to Peer
        for the LSP in question?  (See Note 8.)
        If so, goto LMp.22.

LMp.19  Is the Downstream Unsolicited Ordered Control Label
        Distribution procedure being used by LSR?  If not, goto
        LMp.28.

LMp.20  Execute procedure Prepare_Label_Mapping_Attributes(Peer,
        FEC, RAttributes, SAttributes, IsPropagating,
        StoredHopCount).

LMp.21  Execute procedure Send_Message (Peer, Label Mapping, FEC,
        PrevAdvLabel, SAttributes).
        Goto LMp.28

LMp.22  Iterate through LMp.27 for each label mapping for FEC
        previously sent to Peer.

LMp.23  Are RAttributes in the received label mapping consistent
        with those previously sent to Peer?
        If so, continue iteration from LMp.22 for next label
        mapping. (See Note 9.)

LMp.24  Execute procedure Prepare_Label_Mapping_Attributes(Peer,
        FEC, RAttributes, SAttributes, IsPropagating,
        StoredHopCount).

LMp.25  Execute procedure Send_Message (Peer, Label Mapping, FEC,
        PrevAdvLabel, SAttributes).  (See Note 10.)

LMp.26  Update record of label mapping for FEC previously sent to
        Peer to include the new attributes sent.

LMp.27  End iteration from LMp.22.

LMp.28  Does LSR have any label requests for FEC from Peer marked
        as pending?
        If not, goto LMp.30.

LMp.29  Perform LSR Label Distribution procedure:

      For Downstream Unsolicited Independent Control OR
      For Downstream Unsolicited Ordered Control

        1. Execute procedure
           Prepare_Label_Mapping_Attributes(Peer, FEC,
           RAttributes, SAttributes, IsPropagating,
           UnknownHopCount).

        2. Execute procedure Send_Label (Peer, FEC, SAttributes).
           If the procedure fails, continue iteration for
           next Peer at LMp.17.

        3. If no pending requests exist for Peer goto LMp.30.
           (See Note 11.)

      For Downstream On Demand Independent Control OR
      For Downstream On Demand Ordered Control

        1. Iterate through Step 5 for each pending label
           request for FEC from Peer marked as pending.

        2. Execute procedure
           Prepare_Label_Mapping_Attributes(Peer, FEC,
           RAttributes, SAttributes, IsPropagating,
           UnknownHopCount)

        3. Execute procedure Send_Label (Peer, FEC,
           SAttributes).
           If the procedure fails, continue iteration for next
           Peer at LMp.17.
4. Delete record of pending request.

5. End iteration from Step 1.

6. Goto LMp.30.

      LMp.30  Perform LSR Label Use procedure:

            For Use Immediate OR
            For Use If Loop Not Detected

              1. Iterate through Step 3 for each label mapping for
                 FEC previously sent to Peer.

              2. Install label received and label sent to Peer for
                 forwarding/switching use.

3. End iteration from Step 1.

4. Goto LMp.31.

      LMp.31  End iteration from LMp.17.
              Go to LMp.33.

      LMp.32  Execute procedure Send_Message (MsgSource, Label Release,
              FEC, Label).

      LMp.33  DONE.

Notes:

  1. Okay so, if the LSR is merging, there should be at most 1 received mapping for the FEC for that LSP ๐Ÿ”—. If it's not merging, there could be several received mappings for the FEC for the LSP, so don't panic when you see more than one. ๐ŸŒธ
  2. If the LSR has detected a loop and it hasn't previously gotten a label mapping from MsgSource for the FEC, it just releases the label. Simple, clean, no drama. ๐Ÿ’…
  3. Does the Label received in the message match any of the 1 or more label mappings identified in the previous step (LMp.4 or LMp.9)? This is the check, bestie. ๐Ÿ”
  4. An unsolicited mapping with a different label from the same peer would be an attempt to set up multipath label switching, which is not supported in this version of LDP. Not today, multipath ๐Ÿ™…โ€โ™€๏ธ
  5. If Label is not in forwarding/switching use, LMp.7 has no effect. Nothing to see here. ๐Ÿฆ‹
  6. If the received label mapping message matched an outstanding label request in LMp.1, then (by definition) the LSR has not previously received a label mapping for the FEC for that LSP. If the LSR is merging upstream labels for the LSP, there should be at most 1 received mapping. In the non-merging case, there could be multiple received label mappings for the same FEC, one for each resulting LSP. It's giving by definition ๐ŸคŒ
  7. The LMp.17 iteration includes MsgSource so it can handle the case where the LSR is operating in Downstream Unsolicited ordered control mode. Ordered control stops the LSR from advertising a label for the FEC until it has received a label mapping for the FEC from its next hop (MsgSource). Patience is a virtue, babe. โญ
  8. If the LSR is merging the LSP, it may have previously sent label mappings for the FEC LSP to one or more peers. If the LSR is not merging, it may have sent a label mapping for that LSP to at most one LSR. Merging is the group project, non-merging is solo mode ๐ŸŽ€
  9. The loop detection Path Vector attribute gets considered in this check. If the received RAttributes include a Path Vector and no Path Vector had been previously sent to the Peer, or if the received Path Vector doesn't match the Path Vector previously sent to the Peer, then the attributes are considered inconsistent. Heads up: an LSR doesn't have to store a received Path Vector after it propagates it in a mapping message. But if it doesn't store it, it has no way to check a newly received Path Vector for consistency. So whenever an LSR like that gets a mapping message carrying a Path Vector, it must always propagate the Path Vector. Memory is tricky but we do what we gotta do ๐Ÿงš
  10. LMp.22 through LMp.27 deal with a situation that can pop up when the LSR is using independent control and gets a mapping from the downstream peer after it has already sent a mapping to an upstream peer. In that case the LSR needs to propagate any changed attributes, like Hop Count, upstream. If Loop Detection is configured on, the propagated attributes must include the Path Vector. Plot twist, but it's manageable โœจ
  11. An LSR operating in Downstream Unsolicited mode must process any Label Request messages it receives. If there are pending label requests, it falls through into the Downstream on Demand procedures so it can satisfy them. Multitasking queen behavior ๐Ÿ‘‘

A.1.3. Receive Label Abort Request โœจ

Summary:

When an LSR gets a label abort request message from a peer, it checks whether it has already responded to the label request in question. If it has, it quietly ignores the message. If it hasn't, it sends the peer a Label Request Aborted Notification. On top of that, if it has a label request outstanding for the LSP in question to a downstream peer, it sends a Label Abort Request to that downstream peer so the LSP gets aborted too. Full cancel culture, but make it organized ๐Ÿซถ

Context:

  • LSR. The LSR handling the event.
  • MsgSource. The LDP peer that sent the message.
  • FEC. The FEC specified in the message.
  • RequestMessageID. The message ID of the label request message to be aborted.
  • Next Hop. The next hop for the FEC.

Algorithm:

   Algorithm:

      LAbR.1  Does the message match a previously received label request
              message from MsgSource? (See Note 1.)
              If not, goto LAbR.12.

      LAbR.2  Has LSR responded to the previously received label
              request?
              If so, goto LAbR.12.

      LAbR.3  Execute procedure Send_Message(MsgSource, Notification,
              Label Request Aborted, TLV), where TLV is the Label
              Request Message ID TLV received in the label abort
              request message.

      LAbR.4  Does LSR have a label request message outstanding for
              FEC?
              If so, goto LAbR.7

      LAbR.5  Does LSR have a label mapping for FEC?
              If not, goto LAbR.11

      LAbR.6  Generate Event: Received Label Release Message for FEC
              from MsgSource.  (See Note 2.)
              Goto LAbR.11.

      LAbR.7  Is LSR merging the LSP for FEC?
              If not, goto LAbR.9.

      LAbR.8  Are there upstream peers other than MsgSource that have
              requested a label for FEC?
              If so, goto LAbR.11.

      LAbR.9  Execute procedure Send_Message (Next Hop, Label Abort
              Request, FEC, TLV), where TLV is a Label Request Message
              ID TLV containing the Message ID used by the LSR in the
              outstanding Label Request message.

      LAbR.10  Record that a label abort request for FEC is pending.

      LAbR.11  Delete record of label request for FEC from MsgSource.

      LAbR.12  DONE

Notes:

  1. The LSR uses the FEC and the Label Request Message ID TLV carried by the label abort request to find its record (if it has one) of the previously received label request from MsgSource. It's a matching game ๐ŸŽฏ
  2. If the LSR has received a label mapping from NextHop, it should behave as if it had advertised a label mapping to MsgSource and MsgSource has released it. Pretend it happened, then move on ๐Ÿ’–

A.1.4. Receive Label Release โœจ

Summary:

When an LSR gets a label release message for a FEC from a peer, it checks whether any other peers still hold the released label. If none do, the LSR takes the label out of forwarding/switching use (if it hasn't already), and if it holds a label mapping from the FEC next hop, it releases that label mapping too. Clean-up crew mode activated ๐Ÿงน

Context:

  • LSR. The LSR handling the event.
  • MsgSource. The LDP peer that sent the message.
  • Label. The label specified in the message.
  • FEC. The FEC specified in the message.

Algorithm:

   Algorithm:

      LRl.1   Remove MsgSource from record of peers that hold Label for
              FEC.  (See Note 1.)

      LRl.2   Does message match an outstanding label withdraw for FEC
              previously sent to MsgSource?
              If not, goto LRl.4

      LRl.3   Delete record of outstanding label withdraw for FEC
              previously sent to MsgSource.

      LRl.4   Is LSR merging labels for this FEC?
              If not, goto LRl.6.  (See Note 2.)

      LRl.5   Has LSR previously advertised a label for this FEC to
              other peers?
              If so, goto LRl.10.

      LRl.6   Is LSR egress for the FEC?
              If so, goto LRl.10

      LRl.7   Is there a Next Hop for FEC? AND
              Does LSR have a previously received label mapping for FEC
              from Next Hop?
              If not, goto LRl.10.

      LRl.8   Is LSR configured to propagate releases?
              If not, goto LRl.10.  (See Note 3.)

      LRl.9   Execute procedure Send_Message (Next Hop, Label Release,
              FEC, Label from Next Hop).

      LRl.10  Remove Label from forwarding/switching use for traffic
              from MsgSource.

      LRl.11  Do any peers still hold Label for FEC?
              If so, goto LRl.13.

      LRl.12  Free the Label.

      LRl.13  DONE.

Notes:

  1. If the LSR is using Downstream Unsolicited label distribution, it shouldn't re-advertise a label mapping for the FEC to MsgSource until MsgSource asks for it again. Wait for the ask ๐Ÿ™
  2. LRl.4 through LRl.8 are all about figuring out whether the LSR should pass the label release on to a downstream peer (LRl.9). Lots of checkpoints, big brain energy ๐Ÿง 
  3. If LRl.8 is reached, no upstream LSR holds a label for the FEC, and the LSR holds a label for the FEC from the FEC Next Hop. The LSR could propagate the Label Release to the Next Hop. By doing that, the LSR frees up a potentially scarce label resource. But it also increases the latency for re-establishing the LSP if MsgSource or some other upstream LSR sends it a new Label Request for the FEC later. ๐Ÿ˜ญ

Whether or not to propagate the release isn't a protocol issue. Label distribution works fine either way. The decision should take into account things like: whether labels are a scarce resource in the operating environment; how important it is to keep LSP setup latency low by keeping the amount of signaling small; and whether LSP setup is ingress-controlled or egress-controlled in the operating environment. It's a vibe check for your network, not a rule ๐ŸŒˆ

A.1.5. Receive Label Withdraw ๐Ÿฆ‹

Summary:

okay so when an LSR gets a label withdraw for a FEC from an LDP peer, it fires back a label release ๐Ÿ“ค and yanks that label out of any forwarding/switching use ๐Ÿ’…. If ordered control is in use, the LSR sends a label withdraw to each LDP peer it had previously sent a label mapping for that FEC ๐Ÿ”. And if the LSR is using Downstream on Demand label advertisement with independent control, it then acts like it just recognized the FEC all over again ๐ŸŒธ.

Context:

  • LSR. The LSR handling the event. ๐Ÿ’–
  • MsgSource. The LDP peer that sent the message. ๐Ÿซถ
  • Label. The label specified in the message. ๐Ÿท๏ธ
  • FEC. The FEC specified in the message. ๐ŸŽ€

Algorithm:

LWd.1   Remove Label from forwarding/switching use.  (See Note 1.)

LWd.2   Execute procedure Send_Message (MsgSource, Label Release,
        FEC, Label)

LWd.3   Has LSR previously received and retained a matching label
        mapping for FEC from MsgSource?
        If not, goto LWd.13.

LWd.4   Delete matching label mapping for FEC previously received
        from MsgSource.

LWd.5   Is LSR using ordered control?
        If so, goto LWd.8.

LWd.6   Is MsgSource using Downstream On Demand label
        advertisement?
        If not, goto LWd.13.

LWd.7   Generate Event: Recognize New FEC for FEC.
        Goto LWd.13.  (See Note 2.)

LWd.8   Iterate through LWd.12 for each Peer, other than
        MsgSource.

LWd.9   Has LSR previously sent a label mapping for FEC to Peer?
        If not, continue iteration for next Peer at LWd.8.

LWd.10  Does the label previously sent to Peer "map" to the
        withdrawn Label?
        If not, continue iteration for next Peer at LWd.8.
        (See Note 3.)

LWd.11  Execute procedure Send_Label_Withdraw (Peer, FEC, Label
        previously sent to Peer).

LWd.12  End iteration from LWd.8.

LWd.13  DONE

Notes:

  1. โœจ If Label is not in forwarding/switching use, LWd.1 has no effect.
  2. ๐ŸŒˆ LWd.7 handles the case where the LSR is using Downstream On Demand label distribution with independent control. In this situation the LSR should send a label request to the FEC next hop as if it had just recognized the FEC.
  3. ๐Ÿ’œ LWd.10 handles both label merging (one or more incoming labels map to the same outgoing label) and no label merging (one label maps to the outgoing label) cases.

A.1.6. Recognize New FEC ๐ŸŒธ

Summary:

so when an LSR learns about a brand new FEC through the routing table, it might do one or more of these things, bestie ๐Ÿ’…:

  • Send label mappings for the FEC to one or more LDP peers ๐Ÿ“จ;
  • Send a label request for the FEC to the FEC next hop ๐Ÿ™‹;
  • Do any of the stuff that happens when the LSR gets a label mapping for the FEC from the FEC next hop โœจ.

Context:

  • LSR. The LSR handling the event. ๐Ÿ’–
  • FEC. The newly recognized FEC. ๐Ÿ†•
  • Next Hop. The next hop for the FEC. ๐Ÿ‘‰
  • InitAttributes. Attributes to be associated with the new FEC. (See Note 1.) ๐ŸŽ€
  • SAttributes. Attributes to be included in Label Mapping or Label Request messages, if any, sent to peers. ๐Ÿ“ฌ
  • StoredHopCount. Hop count associated with FEC label mapping, if any, previously received from Next Hop. ๐Ÿ”ข

Algorithm:

FEC.1   Perform LSR Label Distribution procedure:

      For Downstream Unsolicited Independent Control

1. Iterate through 5 for each Peer.

   2. Has LSR previously received and retained a label
      mapping for FEC from Next Hop?
      If so, set Propagating to IsPropagating.
      If not, set Propagating to NotPropagating.

   3. Execute procedure Prepare_Label_Mapping_Attributes
      (Peer, FEC, InitAttributes, SAttributes, Propagating,
      Unknown hop count(0)).

4. Execute procedure Send_Label (Peer, FEC, SAttributes)

   5. End iteration from 1.
      Goto FEC.2.

      For Downstream Unsolicited Ordered Control

1. Iterate through 5 for each Peer.

   2. Is LSR egress for the FEC? OR
      Has LSR previously received and retained a label
      mapping for FEC from Next Hop?
      If not, continue iteration for next Peer.

   3. Execute procedure Prepare_Label_Mapping_Attributes
      (Peer, FEC, InitAttributes, SAttributes, Propagating,
      StoredHopCount).

4. Execute procedure Send_Label (Peer, FEC, SAttributes)

   5. End iteration from 1.
      Goto FEC.2.

      For Downstream On Demand Independent Control OR
      For Downstream On Demand Ordered Control

1. Goto FEC.2.  (See Note 2.)

FEC.2   Has LSR previously received and retained a label
        mapping for FEC from Next Hop?
        If so, goto FEC.5

FEC.3   Is Next Hop an LDP peer?
        If not, Goto FEC.6

FEC.4   Perform LSR Label Request procedure:

      For Request Never

1. Goto FEC.6

      For Request When Needed OR
      For Request On Request

        1. Execute procedure
           Prepare_Label_Request_Attributes
           (Next Hop, FEC, InitAttributes, SAttributes);

        2. Execute procedure Send_Label_Request (Next
           Hop, FEC, SAttributes).
           Goto FEC.6.

FEC.5   Generate Event: Received Label Mapping from Next Hop.
        (See Note 3.)

FEC.6   DONE.

Notes:

  1. ๐ŸŽ€ An example of an attribute that might be part of InitAttributes is one which specifies desired LSP characteristics, such as class of service (CoS). (Note that while the current version of LDP does not specify a CoS attribute, LDP extensions may.)

The means by which FEC InitAttributes, if any, are specified is beyond the scope of LDP. Note that the InitAttributes will not include a known Hop Count or a Path Vector.

  1. ๐Ÿ™ˆ An LSR using Downstream On Demand label distribution would send a label only if it had a previously received label request marked as pending. The LSR would have no such pending requests because it responds to any label request for an unknown FEC by sending the requesting LSR a No Route notification and discarding the label request; see LRq.3.
  2. ๐Ÿงš If the LSR has a label for the FEC from the Next Hop, it should behave as if it had just received the label from the Next Hop. This occurs in the case of Liberal label retention mode.

A.1.7. Detect Change in FEC Next Hop ๐Ÿฆ‹

Summary:

so when the next hop for a FEC changes, the LSR's response might include one or more of these moves, periodt ๐Ÿ’…:

  • Taking the label from the FEC's old next hop out of forwarding/switching use ๐Ÿšซ;
  • Sending label mapping messages for the FEC to one or more LDP peers ๐Ÿ“จ;
  • Sending a label request to the FEC's new next hop ๐Ÿ™‹;
  • Doing any of the stuff that can happen when the LSR gets a label mapping from the FEC's new next hop ๐Ÿ”ฅ.

Context:

  • LSR. The LSR handling the event. ๐Ÿ’–
  • FEC. The FEC whose next hop changed. ๐Ÿ”€
  • New Next Hop. The current next hop for the FEC. ๐Ÿ†•
  • Old Next Hop. The previous next hop for the FEC. ๐Ÿ•ฐ๏ธ
  • OldLabel. Label, if any, previously received from Old Next Hop. ๐Ÿท๏ธ
  • CurAttributes. The attributes, if any, currently associated with the FEC. ๐ŸŽ€
  • SAttributes. Attributes to be included in Label Label Request message, if any, sent to New Next Hop. ๐Ÿ“ฌ

Algorithm:

NH.1   Has LSR previously received and retained a label mapping
       for FEC from Old Next Hop?
       If not, goto NH.6.

NH.2   Remove label from forwarding/switching use.  (See Note 1.)

NH.3   Is LSR using Liberal label retention?
       If so, goto NH.6.

NH.4   Execute procedure Send_Message (Old Next Hop, Label
       Release, OldLabel).

NH.5   Delete label mapping for FEC previously received from Old
       Next Hop.

NH.6   Does LSR have a label request pending with Old Next Hop?
       If not, goto NH.10.

NH.7   Is LSR using Conservative label retention?
       If not, goto NH.10.

NH.8   Execute procedure Send_Message (Old Next Hop, Label Abort
       Request, FEC, TLV), where TLV is a Label Request Message
       ID TLV that carries the message ID of the pending label
       request.

NH.9   Record a label abort request is pending for FEC with Old
       Next Hop.

NH.10  Is there a New Next Hop for the FEC?
       If not, goto NH.16.

NH.11  Has LSR previously received and retained a label mapping
       for FEC from New Next Hop?
       If not, goto NH.13.

NH.12  Generate Event: Received Label Mapping from New Next Hop.
       Goto NH.20.  (See Note 2.)

NH.13  Is LSR using Downstream on Demand advertisement? OR
       Is Next Hop using Downstream on Demand advertisement? OR
       Is LSR using Conservative label retention? (See Note 3.)
       If so, goto NH.14.
       If not, goto NH.20.

NH.14  Execute procedure Prepare_Label_Request_Attributes (Next
       Hop, FEC, CurAttributes, SAttributes)

NH.15  Execute procedure Send_Label_Request (New Next Hop, FEC,
       SAttributes).  (See Note 4.)
       Goto NH.20.

NH.16  Iterate through NH.19 for each Peer.

NH.17  Has LSR previously sent a label mapping for FEC to Peer?
       If not, continue iteration for next Peer at NH.16.

NH.18  Execute procedure Send_Label_Withdraw (Peer, FEC, Label
       previously sent to Peer).

NH.19  End iteration from NH.16.

NH.20  DONE.

Notes:

  1. ๐ŸŒธ If Label is not in forwarding/switching use, NH.2 has no effect.
  2. ๐Ÿ’… If the LSR has a label for the FEC from the New Next Hop, it should behave as if it had just received the label from the New Next Hop.
  3. ๐Ÿค“ The purpose of the check on label retention mode is to avoid a race with steps LMp.12-LMp.13 of the procedure for handling a Label Mapping message where the LSR operating in Conservative Label retention mode may have released a label mapping received from the New Next Hop before it detected the FEC next hop had changed.
  4. ๐Ÿซถ Regardless of the Label Request procedure in use by the LSR, it must send a label request if the conditions in NH.8 hold. Therefore it executes the Send_Label_Request procedure directly rather than perform LSR Label Request procedure.

A.1.8. Receive Notification / Label Request Aborted ๐Ÿ™ˆ

Summary: okay so when an LSR gets a Label Request Aborted notification from an LDP peer, it just marks that the matching label request transaction (if there even is one ๐Ÿซ ) is done. Tidy. โœจ

Context:

  • LSR. The LSR handling the event.
  • FEC. The FEC for which a label was requested.
  • RequestMessageID. The message ID of the label request message to be aborted.
  • MsgSource. The LDP peer that sent the Notification message.

Algorithm:

LRqA.1  Does the notification correspond to an outstanding label
        request abort for FEC? (See Note 1).
        If not, goto LRqA.3.

LRqA.2  Record that the label request for FEC has been aborted.

LRqA.3  DONE

Notes:

  1. The LSR uses the FEC and RequestMessageID to locate its record, if any, of the outstanding label request abort. ๐Ÿ”

A.1.9. Receive Notification / No Label Resources ๐Ÿšซ

Summary: when an LSR hears No Label Resources from an LDP peer, it stops sending label requests to that peer. It stays on pause until the peer sends a Label Resources Available Notification. Boundaries, periodt. ๐Ÿ’…

Context:

  • LSR. The LSR handling the event.
  • FEC. The FEC for which a label was requested.
  • MsgSource. The LDP peer that sent the Notification message.

Algorithm:

NoRes.1 Delete record of outstanding label request for FEC sent
        to MsgSource.

NoRes.2 Record label mapping for FEC from MsgSource is needed but
        that no label resources are available.

NoRes.3 Set status record indicating it is not OK to send label
        requests to MsgSource.

NoRes.4 DONE.

A.1.10. Receive Notification / No Route ๐Ÿ›ฃ๏ธ

Summary: when a No Route notification comes back from an LDP peer after a Label Request message, the Label No Route procedure in use decides what happens next. The LSR can either do nothing else, or it can defer the label request by starting a timer and then send another Label Request message to the peer once that timer runs out. Your call, depending on the procedure. โฐ

Context:

  • LSR. The LSR handling the event.
  • FEC. The FEC for which a label was requested.
  • Attributes. The attributes associated with the label request.
  • MsgSource. The LDP peer that sent the Notification message.

Algorithm:

NoNH.1  Delete record of outstanding label request for FEC sent
        to MsgSource.

NoNH.2  Perform LSR Label No Route procedure.

      For Request No Retry

1. Goto NoNH.3.

      For Request Retry

  1. Record deferred label request for FEC and Attributes
     to be sent to MsgSource.

2. Start timeout.  Goto NoNH.3.

NoNH.3  DONE.

A.1.11. Receive Notification / Loop Detected ๐Ÿ”

Summary: when a Loop Detected Status Code shows up from an LDP peer, either for a Label Request message or a Label Mapping message, the LSR acts as though it had received a No Route notification. Same energy, different trigger. ๐Ÿงš

Context:

See "Receive Notification / No Route".

Algorithm:

See "Receive Notification / No Route"

Notes:

  1. When the Loop Detected notification is in response to a Label Request message, it arrives in a Status Code TLV in a Notification message. When it is in response to a Label Mapping message, it arrives in a Status Code TLV in a Label Release message. ๐Ÿ“ฆ

A.1.12. Receive Notification / Label Resources Available โœ…

Summary: when an LSR gets a Label Resources Available notification from an LDP peer, it's back in business and starts sending label requests to that peer again. Let's gooo. ๐ŸŽ‰

Context:

  • LSR. The LSR handling the event.
  • MsgSource. The LDP peer that sent the Notification message.
  • SAttributes. Attributes stored with postponed Label Request message.

Algorithm:

Res.1   Set status record indicating it is OK to send label
        requests to MsgSource.

Res.2   Iterate through Res.6 for each record of a FEC label
        mapping needed from MsgSource for which no label
        resources are available.

Res.3   Is MsgSource the next hop for FEC?
        If not, goto Res.5.

Res.4   Execute procedure Send_Label_Request (MsgSource, FEC,
        SAttributes).  If the procedure fails, terminate
        iteration.

Res.5   Delete record that no resources are available for a label
        mapping for FEC needed from MsgSource.

Res.6   End iteration from Res.2

Res.7   DONE.

A.1.13. Detect local label resources have become available ๐ŸŒธ

Summary: after an LSR has sent a No Label Resources notification to a peer, the moment its label resources come back, it sends a Label Resources Available notification to each of those peers. Full comeback arc. ๐Ÿฆ‹

Context:

  • LSR. The LSR handling the event.
  • Attributes. Attributes stored with postponed Label Mapping message.

Algorithm:

ResA.1  Iterate through ResA.4 for each Peer to which LSR has
        previously sent a No Label Resources notification.

ResA.2  Execute procedure Send_Notification (Peer, Label
        Resources Available)

ResA.3  Delete record that No Label Resources notification was
        previously sent to Peer.

ResA.4  End iteration from ResA.1

ResA.5  Iterate through ResA.8 for each record of a label mapping
        needed for FEC for Peer but no-label-resources.  (See Note
        1.)

ResA.6  Execute procedure Send_Label (Peer, FEC, Attributes).  If
        the procedure fails, terminate iteration.

ResA.7  Clear record of FEC label mapping needed for peer but no-
        label-resources.

ResA.8  End iteration from ResA.5

ResA.9  DONE.

Notes:

  1. Iteration ResA.5 through ResA.8 handles the situation where the LSR is using Downstream Unsolicited label distribution and was previously unable to allocate a label for a FEC. ๐Ÿซถ

A.1.14. LSR decides to no longer label switch a FEC ๐Ÿ‘‹

Summary: an LSR can decide on its own to stop label switching a FEC for an LDP peer. If it does, it has to send a label withdraw message for that FEC to the peer. No ghosting, bestie. ๐Ÿ’œ

Context:

  • Peer. The peer.
  • FEC. The FEC.
  • PrevAdvLabel. The label for FEC previously advertised to Peer.

Algorithm:

NoLS.1  Execute procedure Send_Label_Withdraw (Peer, FEC,
        PrevAdvLabel).  (See Note 1.)

NoLS.2  DONE.

Notes:

  1. The LSR may remove the label from forwarding/switching use as part of this event or as part of processing the label release from the peer in response to the label withdraw. ๐Ÿ”„

A.1.15. Timeout of deferred label request โณ

Summary: label requests get deferred when a No Route or Loop Detected notification shows up. When a deferred FEC label request for a peer times out, the LSR sends that label request. Patience rewarded. ๐Ÿ“

Context:

  • LSR. The LSR handling the event.
  • FEC. The FEC associated with the timeout event.
  • Peer. The LDP peer associated with the timeout event.
  • Attributes. Attributes stored with deferred Label Request message.

Algorithm:

TO.1    Retrieve the record of the deferred label request.

TO.2    Is Peer the next hop for FEC?
        If not, goto TO.4.

TO.3    Execute procedure Send_Label_Request (Peer, FEC).

TO.4    DONE.

A.2. Common Label Distribution Procedures ๐Ÿงฐ

This section is the shared toolbox ๐Ÿงฐโœจ. These are the utility procedures that the algorithms handling label distribution events all rely on.

A.2.1. Send_Label ๐Ÿท๏ธ

Summary: Send_Label is the procedure that tries to allocate a label for a FEC for an LDP peer and then sends that peer a label mapping for the FEC. If the LSR can't allocate a label, and it has a pending label request from that peer, it sends the peer a No Label Resources notification. Iconic behaviour, honestly. ๐Ÿ‘‘

Parameters:

  • Peer. The LDP peer to which the label mapping is to be sent.
  • FEC. The FEC for which a label mapping is to be sent.
  • Attributes. The attributes to be included with the label mapping.

Additional Context:

  • LSR. The LSR executing the procedure.
  • Label. The label allocated and sent to Peer.

Algorithm:

SL.1   Does LSR have a label to allocate?
       If not, goto SL.9.

SL.2   Allocate Label and bind it to the FEC.

SL.3   Install Label for forwarding/switching use.

SL.4   Execute procedure Send_Message (Peer, Label Mapping, FEC,
       Label, Attributes).

SL.5   Record label mapping for FEC with Label and Attributes has
       been sent to Peer.

SL.6   Does LSR have a record of a FEC label request from Peer
       marked as pending?
       If not, goto SL.8.

SL.7   Delete record of pending label request for FEC from Peer.

SL.8   Return success.

SL.9   Does LSR have a label request for FEC from Peer marked as
       pending?
       If not, goto SL.13.

SL.10  Execute procedure Send_Notification (Peer, No Label
       Resources).

SL.11  Delete record of pending label request for FEC from Peer.

SL.12  Record No Label Resources notification has been sent to
       Peer.
       Goto SL.14.

SL.13  Record label mapping needed for FEC and Attributes for
       Peer, but no-label-resources.  (See Note 1.)

SL.14  Return failure.

Notes:

  1. SL.13 handles the case of Downstream Unsolicited label distribution when the LSR is unable to allocate a label for a FEC to send to a Peer. ๐Ÿ’ญ

A.2.2. Send_Label_Request ๐Ÿ“จ

Summary: an LSR uses Send_Label_Request to ask an LDP peer for a label for a FEC, but only if it's currently allowed to. Permission check first, bestie. ๐Ÿšฆ

Parameters:

  • Peer. The LDP peer to which the label request is to be sent.
  • FEC. The FEC for which a label request is to be sent.
  • Attributes. Attributes to be included in the label request. E.g., Hop Count, Path Vector.

Additional Context:

  • LSR. The LSR executing the procedure.

Algorithm:

SLRq.1  Has a label request for FEC previously been sent to Peer
        and is it marked as outstanding?
        If so, Return success.  (See Note 1.)

SLRq.2  Is status record indicating it is OK to send label
        requests to Peer set?
        If not, goto SLRq.6

SLRq.3  Execute procedure Send_Message (Peer, Label Request, FEC,
        Attributes).

SLRq.4  Record label request for FEC has been sent to Peer and
        mark it as outstanding.

SLRq.5  Return success.

SLRq.6  Postpone the label request by recording label mapping for
        FEC and Attributes from Peer is needed but that no label
        resources are available.

SLRq.7  Return failure.

Notes:

  1. If the LSR is a non-merging LSR it must distinguish between attempts to send label requests for a FEC triggered by different upstream LDP peers from duplicate requests. This procedure will not send a duplicate label request. ๐Ÿง โœจ

A.2.3. Send_Label_Withdraw โœจ

Okay so this is the procedure an LSR uses when it wants to take back a label it handed out for a FEC. It sends a Label Withdraw message to the peer, and that's how the label gets withdrawn ๐Ÿฆ‹

Parameters:

  • Peer. The LDP peer the label withdraw is sent to.
  • FEC. The FEC the label is being withdrawn for.
  • Label. The label being withdrawn.

Additional Context:

  • LSR. The LSR running the procedure.

Algorithm:

SWd.1  Execute procedure Send_Message (Peer, Label Withdraw, FEC,
       Label)

SWd.2  Record label withdraw for FEC has been sent to Peer and
       mark it as outstanding.

A.2.4. Send_Notification ๐Ÿ’Œ

This is the one an LSR uses to send its LDP peer a notification message. Simple, clean, iconic ๐Ÿ’…

Parameters:

  • Peer. The LDP peer the Notification message is sent to.
  • Status. The status code included in the Notification message.

Additional Context:

  • None.

Algorithm:

SNt.1  Execute procedure Send_Message (Peer, Notification, Status)

A.2.5. Send_Message ๐Ÿ“จ

This is the general-purpose sender. An LSR uses it to send an LDP peer any LDP message, and it's the thing that actually does the sending for the other procedures ๐Ÿซถ

Parameters:

  • Peer. The LDP peer the message is sent to.
  • Message Type. The type of message being sent.
  • Additional message contents . . . .

Additional Context:

  • None.

Algorithm:

This procedure is how an LSR sends an LDP message of the specified type to the specified LDP peer.

A.2.6. Check_Received_Attributes ๐Ÿ”

This is the loop-checking glow-up ๐Ÿ‘‘ It looks at the attributes that came in on a Label Mapping or Label Request message. If there's a Hop Count or a Path Vector, it runs a loop detection check, and if it finds a loop, it sends a Loop Detected Notification message back to MsgSource. Iconic behaviour, no notes ๐Ÿ’€

Parameters:

  • MsgSource. The LDP peer that sent the message.
  • MsgType. The type of message received.
  • RAttributes. The attributes in the message.

Additional Context:

  • LSR Id. The unique LSR Id of this LSR.
  • Hop Count. The Hop Count, if any, in the received attributes.
  • Path Vector. The Path Vector, if any, in the received attributes.

Algorithm:

CRa.1   Do RAttributes include Hop Count?
        If not, goto CRa.5.

CRa.2   Does Hop Count exceed Max allowable hop count?
        If so, goto CRa.6.

CRa.3   Do RAttributes include Path Vector?
        If not, goto CRa.5.

CRa.4   Does Path Vector Include LSR Id? OR
        Does length of Path Vector exceed Max allowable length?
        If so, goto CRa.6

CRa.5   Return No Loop Detected.

CRa.6   Is MsgType LabelMapping?
        If so, goto CRa.8.  (See Note 1.)

CRa.7   Execute procedure Send_Notification (MsgSource, Loop
        Detected)

CRa.8   Return Loop Detected.

CRa.9   DONE

Notes:

  1. When the attributes being checked came in on a Label Mapping message, the LSR sends the Loop Detected notification inside a Status Code TLV in a Label Release message. (See Section "Receive Label Mapping".) ๐ŸŽ€

A.2.7. Prepare_Label_Request_Attributes ๐Ÿงš

This one gets called every time a Label Request is about to go out to a Peer. It works out the Hop Count and Path Vector, if any, that should go in the message. It's giving careful planning ๐Ÿ“‹

Parameters:

  • Peer. The LDP peer the message is sent to.
  • FEC. The FEC a label request is being sent for.
  • RAttributes. The attributes this LSR associates with the LSP for FEC.
  • SAttributes. The attributes to be included in the Label Request message.

Additional Context:

  • LSR Id. The unique LSR Id of this LSR.

Algorithm:

PRqA.1  Is Hop Count required for this Peer (see Note 1.) ? OR
        Do RAttributes include a Hop Count? OR
        Is Loop Detection configured on LSR?
        If not, goto PRqA.14.

PRqA.2  Is LSR ingress for FEC?
        If not, goto PRqA.6.

PRqA.3  Include Hop Count of 1 in SAttributes.

PRqA.4  Is Loop Detection configured on LSR?
        If not, goto PRqA.14.

PRqA.5  Is LSR merge-capable?
        If so, goto PRqA.14.
        If not, goto PRqA.13.

PRqA.6  Do RAttributes include a Hop Count?
        If not, goto PRqA.8.

PRqA.7  Increment RAttributes Hop Count and copy the resulting Hop
        Count to SAttributes.  (See Note 2.)
        Goto PRqA.9.

PRqA.8  Include Hop Count of unknown (0) in SAttributes.

PRqA.9  Is Loop Detection configured on LSR?
        If not, goto PRqA.14.

PRqA.10 Do RAttributes have a Path Vector?
        If so, goto PRqA.12.

PRqA.11 Is LSR merge-capable?
        If so, goto PRqA.14.
        If not, goto PRqA.13.

PRqA.12 Add LSR Id to beginning of Path Vector from RAttributes
        and copy the resulting Path Vector into SAttributes.
        Goto PRqA.14.

PRqA.13 Include Path Vector of length 1 containing LSR Id in
        SAttributes.

PRqA.14 DONE.

Notes:

  1. The link with Peer may need Hop Count to be included in Label Request messages. For example, see [RFC3035] and [RFC3034]. ๐Ÿ”—
  2. For hop count arithmetic, unknown + 1 = unknown.

A.2.8. Prepare_Label_Mapping_Attributes ๐ŸŒธ

This is the Label Mapping version of the one above. It's called whenever a Label Mapping is about to go to a Peer, and it figures out the Hop Count and Path Vector, if any, to include. It's a lot, but it's giving thorough ๐Ÿฅน

Parameters:

  • Peer. The LDP peer the message is sent to.
  • FEC. The FEC a label request is being sent for.
  • RAttributes. The attributes this LSR associates with the LSP for FEC.
  • SAttributes. The attributes to be included in the Label Mapping message.
  • IsPropagating. Whether the LSR is sending the Label Mapping message to propagate one it received from the FEC next hop.
  • PrevHopCount. The Hop Count, if any, this LSR associates with the LSP for the FEC.

Additional Context:

  • LSR Id. The unique LSR Id of this LSR.

Algorithm:

PMpA.1  Is Hop Count required for this Peer (see Note 1.) ? OR
        Do RAttributes include a Hop Count? OR
        Is Loop Detection configured on LSR?
        If not, goto PMpA.21.

PMpA.2  Is LSR egress for FEC?
        If not, goto PMpA.4.

PMpA.3  Include Hop Count of 1 in SAttributes.  Goto PMpA.21.

PMpA.4  Do RAttributes have a Hop Count?
        If not, goto PMpA.8.

PMpA.5  Is LSR member of edge set for an LSR domain whose LSRs do
        not perform TTL decrement AND
        Is Peer in that domain (See Note 2.).
        If not, goto PMpA.7.

PMpA.6  Include Hop Count of 1 in SAttributes.  Goto PMpA.9.

PMpA.7  Increment RAttributes Hop Count and copy the resulting
        Hop Count to SAttributes.  See Note 2.  Goto PMpA.9.

PMpA.8  Include Hop Count of unknown (0) in SAttributes.

PMpA.9  Is Loop Detection configured on LSR?
        If not, goto PMpA.21.

PMpA.10 Do RAttributes have a Path Vector?
        If so, goto PMpA.19.

PMpA.11 Is LSR propagating a received Label Mapping?
        If not, goto PMpA.20.

PMpA.12 Does LSR support merging?
        If not, goto PMpA.14.

PMpA.13 Has LSR previously sent a Label Mapping for FEC to Peer?
        If not, goto PMpA.20.

PMpA.14 Do RAttributes include a Hop Count?
        If not, goto PMpA.21.

PMpA.15 Is Hop Count in Rattributes unknown(0)?
        If so, goto PMpA.20.

PMpA.16 Has LSR previously sent a Label Mapping for FEC to Peer?
        If not goto PMpA.21.

PMpA.17 Is Hop Count in RAttributes different from PrevHopCount ?
        If not goto PMpA.21.

PMpA.18 Is the Hop Count in RAttributes > PrevHopCount? OR
        Is PrevHopCount unknown(0)
        If not, goto PMpA.21.

PMpA.19 Add LSR Id to beginning of Path Vector from RAttributes
        and copy the resulting Path Vector into SAttributes.
        Goto PMpA.21.

PMpA.20 Include Path Vector of length 1 containing LSR Id in
        SAttributes.

PMpA.21 DONE.

Notes:

  1. The link with Peer may need Hop Count to be included in Label Mapping messages. For example, see [RFC3035] and [RFC3034]. ๐Ÿ”—
  2. If the LSR sits at the edge of a cloud of LSRs that don't do TTL-decrement, and it's propagating the Label Mapping message upstream into that cloud, it sets the Hop Count to 1. That way the Hop Count across the cloud gets calculated properly. This keeps TTL management right for packets forwarded over the part of the LSP that goes through the cloud. ๐Ÿง 
  3. For hop count arithmetic, unknown + 1 = unknown.

Okay, this part is legal stuff, so I'm keeping it exactly as written so nobody can say I changed a word ๐Ÿ™ˆ

   Copyright (C) The Internet Society (2001).  All Rights Reserved.

   This document and translations of it may be copied and furnished to
   others, and derivative works that comment on or otherwise explain it
   or assist in its implementation may be prepared, copied, published
   and distributed, in whole or in part, without restriction of any
   kind, provided that the above copyright notice and this paragraph are
   included on all such copies and derivative works.  However, this
   document itself may not be modified in any way, such as by removing
   the copyright notice or references to the Internet Society or other
   Internet organizations, except as needed for the purpose of
   developing Internet standards in which case the procedures for
   copyrights defined in the Internet Standards process must be
   followed, or as required to translate it into languages other than
   English.

   The limited permissions granted above are perpetual and will not be
   revoked by the Internet Society or its successors or assigns.

   This document and the information contained herein is provided on an
   "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
   TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
   BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
   HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

Acknowledgement ๐Ÿซถ

Funding for the RFC Editor function is currently provided by the Internet Society. Thank you, Internet Society, you're a real one ๐ŸŒˆ

๐Ÿ“ฆ where this page comes from