# lldp — IEEE 802.1AB Neighbor Discovery TLV Frames (`lldp`)

> **FrameAssembly v3.2.2** · Protocol 4 of 81 · Canonical URL: https://frameassembly-lang.dev/docs/protocols/lldp

- **Full Protocol Name:** IEEE 802.1AB Link Layer Discovery Protocol
- **Keyword:** `lldp`
- **OSI Layer & Transport:** Layer 2 · EtherType 0x88cc
- **Host Endpoint Rule:** MAC-Only or IP
- **Standards:** IEEE 802.1AB
- **Wireshark Display Filter:** `lldp`
- **Wire Encapsulation:** `Ethernet II -> LLDP (EtherType 0x88cc)`

## Overview

Want your NMS or test bench to think a 400G core chassis is plugged into `Gi0/1`? One `sw -> peer lldp` frame advertises Chassis ID, Port ID, TTL, and System Name TLVs to `01:80:c2:00:00:0e`.

Link Layer Discovery Protocol (`lldp`) is the vendor-neutral IEEE 802.1AB neighbor discovery protocol sent over Ethernet II (`0x88cc`) to the bridge multicast MAC `01:80:c2:00:00:0e`. Switches, routers, hypervisors, and VoIP phones advertise their hostname and interface port via Type-Length-Value (TLV) fields.

FrameAssembly builds a complete IEEE 802.1AB LLDPDU—Chassis ID (TLV 1), Port ID (TLV 2), Time-To-Live (TLV 3), optional System Name (TLV 5) and System Description (TLV 6), plus the required End of LLDPDU marker (TLV 0)—from a single line.

## Minimal Quickstart (`lldp_quickstart.frasm`)

```frameassembly
host leaf_sw  { mac 00:1c:73:aa:01:01 }
host spine_sw { mac 00:1c:73:bb:02:01 }

compile {
    leaf_sw -> spine_sw lldp
}
```

### Automatic Wire Calculations

- Sets Ethernet II EtherType to `0x88cc` and defaults the destination MAC to IEEE nearest-bridge multicast `01:80:c2:00:00:0e`.
- Encodes TLV 1 (Chassis ID, subtype `4` MAC or `7` Locally Assigned), TLV 2 (Port ID, subtype `5` Interface Name), and TLV 3 (16-bit `ttl`, default `120` seconds) with exact 7-bit type + 9-bit length bitfields.
- Appends TLV 5 (`sysname`) and TLV 6 (`sysdesc`) when specified, always terminating with the 2-byte End of LLDPDU (`0x0000`).

## Practical Lab Example: Bidirectional Leaf-Spine LLDP Neighbor Exchange Plus Shutdown Frame (`lldp_leaf_spine.frasm`)

Captures mutual LLDP advertisements between an Arista-class spine and an access switch, followed by an IEEE 802.1AB `ttl 0` neighbor withdrawal frame.

```frameassembly
host leaf_01  { mac 00:1c:73:11:22:01 }
host spine_01 { mac 00:1c:73:99:88:01 }

compile {
    leaf_01 -> spine_01 lldp chassisid "leaf-01.dc1" portid "Ethernet49/1" ttl 120 sysname "leaf-01.dc1.internal" sysdesc "EOS 4.32.1F" wait 5ms
    spine_01 -> leaf_01 lldp chassisid "spine-01.dc1" portid "Ethernet1/1" ttl 120 sysname "spine-01.dc1.internal" sysdesc "EOS 4.32.1F" wait 10ms
    // Graceful LLDP port shutdown advertisement (TTL = 0)
    leaf_01 -> spine_01 lldp chassisid "leaf-01.dc1" portid "Ethernet49/1" ttl 0
}
```

```bash
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show lldp_leaf_spine.frasm

# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly lldp_leaf_spine.frasm lldp_leaf_spine.pcap
frameassembly lldp_leaf_spine.frasm lldp_leaf_spine.pcapng

# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse lldp_leaf_spine.pcap lldp_leaf_spine_edited.frasm

# 4. Verify dissected protocol fields in tshark
tshark -r lldp_leaf_spine.pcap
```

## All `lldp` Keywords & Header Options

Packet line pattern: `src_host -> dst_host lldp [chassisid "<text>"] [portid "<text>"] [ttl <0..65535>] [sysname "<text>"] [sysdesc "<text>"]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `chassisid "<text>"` | Quoted string or identifier | `"switch"` | Encodes Mandatory TLV Type 1 (Chassis ID) with Locally Assigned subtype. |
| `portid <str\|u16>` | Interface string or port number | `"eth0"` | Encodes Mandatory TLV Type 2 (Port ID, e.g. `"Gi1/0/48"` or `"Ethernet1"`). |
| `ttl <0..65535>` | Whole number (0..65535) (seconds) | `120` | Encodes Mandatory TLV Type 3 (Time To Live in seconds; `0` signals neighbor entry deletion). Note: on `lldp`, `ttl` sets the 16-bit LLDP Hold TTL rather than an IPv4 TTL. |
| `sysname "<text>"` | Quoted string or identifier | `Omitted unless set` | Appends Optional TLV Type 5 (System Name). |
| `sysdesc "<text>"` | Quoted string | `Omitted unless set` | Appends Optional TLV Type 6 (System Description). |

## Cross-Layer Options Valid with `lldp`

| Option | Range / Format | Default | Effect |
| --- | --- | --- | --- |
| `wait <number><ns\|us\|ms\|s\|m>` | Time gap (ns, us, ms, s, m) | `10ms` | Advances the packet timestamp clock after sending this packet and before the next packet (`wait 0ns` sends back-to-back). |
| `payload "<text>" \| hexpayload "<hex>"` | Quoted text or hex bytes (choose one) | `Omitted` | Appends or overrides raw payload bytes (`"deadbeef"` or `"de:ad:be:ef"`) and updates packet lengths and checksums. |
| `srcmac <mac> \| dstmac <mac> \| ethertype <0..65535>` | Colon/hyphen/Cisco MAC · EtherType u16 (e.g. 0x0800) | `Host MAC / RFC multicast MAC / auto EtherType` | Overrides the 14-byte Ethernet II source MAC, destination MAC, or 16-bit EtherType for this single packet. |
| `vlan <0..4095> [pcp <0..7>] [dei <0\|1>]` | VLAN ID 0..4095, PCP 0..7, DEI 0..1 | `Untagged` | Wraps the packet in an IEEE 802.1Q VLAN tag (`0x8100`) with optional 802.1p QoS priority. |
| `qinq <0..4095> [innervlan <0..4095>]` | Outer S-VLAN 0..4095, Inner C-VLAN 0..4095 | `Untagged (innervlan 1 when qinq is set)` | Double-tags the packet with outer IEEE 802.1ad S-Tag (`0x88a8`) plus inner IEEE 802.1Q C-Tag (`0x8100`). |
| `mpls <0..1048575> [label <0..1048575>] [exp\|tc <0..7>] [bos <0\|1>] [mplsttl <0..255>]` | Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255 | `Unlabeled (at most 1 mpls tag per packet)` | Inserts a 32-bit MPLS label header (`0x8847`) ahead of the Layer 3 header. |

## Common Mistakes & Quick Fixes

### Contextual ttl Meaning on lldp

- **Valid v3.2.2 Syntax:** `sw1 -> sw2 lldp chassisid "sw1" portid "eth1" ttl 180`

Because `lldp` is a pure Layer 2 protocol with no IP header, `ttl` sets the 16-bit LLDP Time-To-Live TLV (`0..=65535` seconds, allowing values > 255 such as `ttl 300`), not an 8-bit IPv4 TTL.

### Quote Interface Names Containing Slashes

- **Avoid:** `sw1 -> sw2 lldp portid Gi1/0/48`
- **Valid v3.2.2 Syntax:** `sw1 -> sw2 lldp portid "Gi1/0/48"`

Slash characters (`/`) are not part of bare identifiers—always wrap interface names like `"Gi1/0/48"` or `"Ethernet49/1"` in double quotes.
