LDP

Label Distribution Protocol (LDP) is a protocol in which routers capable of Multiprotocol Label Switching (MPLS) exchange label mapping information. Two routers with an established session are called LDP peers and the exchange of information is bi-directional. LDP is used to build and maintain LSP databases that are used to forward traffic through MPLS networks.

LDP discovery runs on UDP port 646 and the session is built on TCP port 646. During the discovery phase hello packets are sent on UDP port 646 to the ‘all routers on this subnet’ group multicast address (224.0.0.2).

LDP is defined by the IETF (RFC 5036).

Configuration

Following is an example LDP configuration with one instance attached to a network interface function.

{
    "interfaces": {
        "network": [
            {
                "interface": "eth1",
                "address": "10.0.1.2/24",
                "gateway": "10.0.1.1",
                "ldp-instance-id": 1
            }
        ]
    },
    "ldp": [
        {
            "instance-id": 1,
            "lsr-id": "10.10.10.11"
        }
    ]
}
{ "ldp": {} }

Attribute

Description

instance-id

Mandatory LDP instance identifier.
Range: 1 - 65535

keepalive-time

LDP session keepalive time in seconds.
The keepalive-time defines the local LDP session
keepalive timeout. Each LDP peer must calculate the
effective keepalive timeout by using the smaller of its
locally defined and received timeout in the PDU. The
value chosen indicates the maximum number of seconds
that may elapse between the receipt of successive PDUs
from the LDP peer on the session TCP connection. The
keepalive timeout is reset each time a PDU arrives. The
BNG Blaster will send keepalive messages at an interval
calculated by using the effective keepalive time divided
by 3. Assuming an effective keepalive time of 15
seconds results in a keepalive interval of 5 seconds.
Default: 15 Range: 1 - 65535

hold-time

LDP hello hold time in seconds.
Default: 15 Range: 1 - 65535

teardown-time

Maximum time in seconds to wait for LDP sessions to
close gracefully on teardown before they are closed.
Default: 5 Range: 0 - 65535

hostname

LDP hostname.
Default: bngblaster

lsr-id

LDP LSR identifier.
Default: 10.10.10.10

ipv6-transport-address

LDP transport IPv6 address.
Setting a valid IPv6 address here enables LDP IPv6
hello and transport.

ipv4-transport-address

LDP transport IPv4 address.
Default: lsr-id

no-ipv4-transport

Disable/discard IPv4 LDP hello messages.

prefer-ipv4-transport

According to RFC7552, IPv6 is preferred over IPv4 which
can be changed with this option to prefer IPv4 transport
even if IPv6 is enabled.
Default: false

raw-update-file

LDP RAW update file.

tos

TOS/TC for all LDP control traffic.
Default: 0 Range: 0 - 255

targeted-neighbors

List of targeted LDP neighbors, see
LDP targeted neighbors.

targeted-hold-time

Targeted hello hold time in seconds.
Default: 45 Range: 1 - 65535

targeted-hello-accept

Accept targeted hellos sent to the transport address
from neighbors which are not configured and respond
with targeted hellos.
Default: false

Limitations

The following LDP functionalities are currently not supported:

  • LDP TCP authentication

  • Multiple links between LDP instance and DUT (ECMP)

  • Label release messages for label withdraw messages received

Targeted LDP

Targeted LDP (extended discovery) sends unicast targeted hellos to the configured targeted-neighbors, typically the loopback address of a remote LSR. IPv4 and IPv6 targeted neighbors are supported, where IPv6 requires the ipv6-transport-address. The targeted hellos are sent to the gateway of the network interface, from the transport address of the address family or the configured source-address. The DUT needs a route to this address and to the transport address used for the session (static or IGP), except for directly connected addresses like the network interface address. The targeted hello hold time is targeted-hold-time (default 45 seconds), the minimum of both proposals is used.

Targeted hellos of a configured neighbor are accepted if sent to its source or the transport address. With targeted-hello-accept, targeted hellos sent from other neighbors to the transport address are accepted and answered, e.g. if the DUT initiates targeted LDP for a pseudowire. The hellos to such a neighbor stop when its adjacency times out.

Link and targeted adjacencies, IPv4 and IPv6, to the same peer share one LDP session. If both IPv4 and IPv6 transport are enabled, the targeted hellos carry the dual-stack capability (RFC 7552) with the preferred transport like the link hellos (prefer-ipv4-transport). Label messages with FEC elements other than prefix (e.g. PWid FEC 128 of pseudowires) are ignored.

{
    "interfaces": {
        "network": {
            "interface": "eth1",
            "address": "10.0.1.2/24",
            "gateway": "10.0.1.1",
            "address-ipv6": "fc00:1::2/64",
            "gateway-ipv6": "fc00:1::1"
        }
    },
    "ldp": {
        "instance-id": 1,
        "lsr-id": "10.10.10.2",
        "ipv6-transport-address": "fc00:10::2",
        "targeted-neighbors": [
            {
                "address": "10.0.0.1",
                "network-interface": "eth1"
            },
            {
                "address": "fc00::1",
                "source-address": "fc00:1::2",
                "network-interface": "eth1"
            }
        ]
    }
}
{ "ldp": { "targeted-neighbors": [] } }

Attribute

Description

address

Mandatory targeted neighbor IPv4 or IPv6 address.
IPv6 requires the LDP ipv6-transport-address.

source-address

Source address of the targeted hellos, of the same address
family as address.
Default: IPv4 or IPv6 transport address

network-interface

Network interface used for the targeted hellos and the session.
Default: first network interface

bfd-profile-id

Enable multi-hop BFD for the session of this targeted
neighbor with this BFD profile.

LDP Adjacencies

When the BNG Blaster receives an LDP discovery hello message, an LDP adjacency is set up between the two peers.

$ sudo bngblaster-cli run.sock ldp-adjacencies

{
    "status": "ok",
    "code": 200,
    "ldp-adjacencies": [
        {
            "ldp-instance-id": 1,
            "type": "link",
            "interface": "eth0",
            "state": "up"
        },
        {
            "ldp-instance-id": 1,
            "type": "targeted",
            "peer-address": "10.0.0.1",
            "source-address": "10.10.10.2",
            "interface": "eth0",
            "configured": true,
            "state": "up",
            "hold-time": 45
        }
    ]
}

LDP Sessions

LDP peers exchange messages over a TCP session which is initiated by the peer with the larger transport IP address (active peer).

The LDP transport IP address can be explicitly configured for the LDP instance using the option ipv4-transport-address. The lsr-id is used as a transport IP address if not explicitly configured.

The session is terminated if no hello (link or targeted) of the peer is received within the hold time (RFC 5036), and established again with the next hello. On teardown, the BNG Blaster stops sending hellos and closes all sessions, sessions not closed within teardown-time are closed without waiting for the peer.

The BNG Blaster advertises its addresses and the LSR identifier and interface prefixes with implicit null label, and with IPv6 transport enabled also its IPv6 addresses and prefixes (RFC 7552). A dual-stack instance establishes the session with the preferred transport only if the peer has the same preference. An IPv4 only instance ignores the dual-stack capability of the peer.

Note

It is currently not supported to setup multiple links between a single LDP instance and the device under test (ECMP).

$ sudo bngblaster-cli run.sock ldp-sessions

{
    "status": "ok",
    "code": 200,
    "ldp-sessions": [
        {
            "ldp-instance-id": 1,
            "interface": "eth0",
            "local-address": "10.2.3.1",
            "local-identifier": "10.2.3.1:0",
            "peer-address": "10.2.3.2",
            "peer-identifier": "10.2.3.2:0",
            "state": "operational",
            "raw-update-state": "done",
            "raw-update-file": "out.ldp",
            "stats": {
                "pdu-rx": 23,
                "pdu-tx": 32,
                "messages-rx": 24,
                "messages-tx": 34,
                "keepalive-rx": 21,
                "keepalive-tx": 21
            }
        }
    ]
}

LDP Traffic Streams

Traffic streams send from network interface functions (downstream) can be configured to dynamically resolve the outer MPLS label using the learned label mappings.

The traffic stream configuration options ldp-ipv4-lookup-address and ldp-ipv6-lookup-address specify the lookup IPv4 or IPv6 address. This means that traffic will not start until this address is found in the corresponding label database of the sending network interface function, which is the LDP instance of the interface (ldp-instance-id) or of a targeted neighbor using this interface. The implicit null label (3) is not sent, the stream is sent without this label.

{
    "streams": [
        {
            "name": "S1",
            "type": "ipv4",
            "direction": "downstream",
            "priority": 128,
            "network-interface": "eth1",
            "destination-ipv4-address": "10.0.0.1",
            "ldp-ipv4-lookup-address": "13.37.0.1",
            "pps": 1
        }
    ]
}

$ sudo bngblaster-cli run.sock ldp-database ldp-instance-id 1

{
    "status": "ok",
    "code": 200,
    "ldp-database": [
        {
            "afi": "ipv4",
            "prefix": "10.0.0.0/24",
            "label": 3,
            "active": true,
            "source-identifier": "10.2.3.1:0"
        },
        {
            "afi": "ipv4",
            "prefix": "13.37.0.0/32",
            "label": 10000,
            "active": true,
            "source-identifier": "10.2.3.1:0"
        },
        {
            "afi": "ipv4",
            "prefix": "13.37.0.1/32",
            "label": 10001,
            "active": true,
            "source-identifier": "10.2.3.1:0"
        }
    ]
}

The database has one entry per prefix (address and prefix length) with the label mappings of all sessions. The entry shows the label of the selected mapping, which is kept as long as its session advertises the prefix, traffic streams prefer the mapping of a session on their network interface. Labels withdrawn by the peer (label withdraw message) and all labels of a session which went down are removed, entries without mapping are kept as inactive entries (active false) and are not used by traffic streams, which stop sending until the label is advertised again.

The ldp-ipv4-lookup-address and ldp-ipv6-lookup-address are mutually exclusive and must exactly match the prefix address as shown in the LDP database. This means that if the prefix is 10.0.0.0/24, the lookup address should be 10.0.0.0.

Note

There is currently no longest prefix match supported, if several prefixes with this address exist, the active one with the longest prefix length is used. Streams switch to another prefix length if a longer prefix is learned or the used one is withdrawn.

RAW Update Files

The BNG Blaster can inject LDP PDU from a pre-compiled RAW update file into the defined sessions. A RAW update file is nothing more than a pre-compiled binary stream of LDP PDUs.

 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                        |
+                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
.                         LDP Messages
.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Version                      |         PDU Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         LDP Identifier                        |
+                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
.                         LDP Messages
.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Those files can be created using the included LDP RAW update generator script ldpupdate or manually using libraries like scapy.

The configured raw-update-file under the LDP instance is loaded during BNG Blaster startup phase and sent as soon as the session is established.

The ldp-raw-update command allows sending further updates during the session lifetime. Sessions which are not operational or still sending an update are skipped (reported as skipped in the response).

$ sudo bngblaster-cli run.sock ldp-raw-update file update1.ldp

This allows loading label mappings after the LDP session has started and manually triggering a series of changes using incremental updates files.

All LDP RAW update files are loaded once and can then be used for multiple sessions. This means that if two or more sessions reference the same file identified by file name, this file is loaded once into memory and used by multiple sessions.

Therefore for incremental updates, it may make sense to pre-load them via the ldp-raw-update-files configuration option.

{
    "ldp": [
        {
            "instance-id": 1,
            "lsr-id": "10.10.10.11",
            "raw-update-file": "start.ldp"
        }
    ],
    "ldp-raw-update-files": [
        "update1.ldp",
        "update2.ldp"
    ]
}

Incremental updates not listed here will be loaded dynamically as soon as referenced by the first ldp-raw-update command.

LDP RAW Update Generator

The LDP RAW update generator is a simple tool to generate LDP RAW update streams for use with the BNG Blaster.

$ ldpupdate --help
usage: ldpupdate [-h] -l ADDRESS [-i N] [-w] [-a ADDRESS] [-A N] [-p PREFIX] [-P N] [-m LABEL] [-M N] [-f FILE] [--append] [--pcap FILE] [--log-level {warning,info,debug}]

The LDP RAW update generator is a simple tool to generate LDP RAW update streams for use with the BNG Blaster.

optional arguments:
-h, --help            show this help message and exit
-l ADDRESS, --lsr-id ADDRESS
                        LSR identifier
-i N, --message-id-base N
                        message identifier base
-w, --withdraw        withdraw
-a ADDRESS, --address-base ADDRESS
                        address message base
-A N, --address-num N
                        address message count
-p PREFIX, --prefix-base PREFIX
                        label mapping base prefix
-P N, --prefix-num N  label mapping prefix count
-m LABEL, --label-base LABEL
                        label base
-M N, --label-num N   label count
-f FILE, --file FILE  output file
--append              append to file if exist
--pcap FILE           write LDP updates to PCAP file
--log-level {warning,info,debug}
                        logging Level

The label withdraw messages generated with --withdraw contain the label TLV, which withdraws only this label (RFC 5036 section 3.5.10). Therefore the same label base (-m) and count (-M) as for the advertised labels must be used.

ldpupdate -l 10.10.10.2 -p 10.200.0.0/32 -P 20 -m 50000 -M 20 -f update.ldp
ldpupdate -l 10.10.10.2 -p 10.200.0.0/32 -P 10 -m 50000 -M 20 -w -f withdraw.ldp

The Python LDP RAW update generator is a Python script that uses scapy to build LDP PDU. Therefore this tool can be easily modified, extended, or used as a blueprint for your own tools to generate valid LDP update streams.