# lacp — IEEE 802.3ad Actor/Partner Link Aggregation PDUs (`lacp`)

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

- **Full Protocol Name:** IEEE 802.3ad / 802.1AX Link Aggregation Control Protocol
- **Keyword:** `lacp`
- **OSI Layer & Transport:** Layer 2 · EtherType 0x8809 (Slow Subtype 0x01)
- **Host Endpoint Rule:** MAC-Only or IP
- **Standards:** IEEE 802.1AX, IEEE 802.3ad
- **Wireshark Display Filter:** `lacp`
- **Wire Encapsulation:** `Ethernet II -> LACP (EtherType 0x8809 (Slow Subtype 0x01))`

## Overview

Few things burn a Friday night faster than two switches refusing to bundle a LAG because one side is passive and the keys disagree. `lacp` writes exact 128-byte `actor <-> partner` slow-protocol PDUs.

Link Aggregation Control Protocol (`lacp`) negotiates and monitors bundled Ethernet port-channels (LAG / MLAG / vPC) using Ethernet Slow Protocols (`EtherType 0x8809`, subtype `0x01`) addressed to `01:80:c2:00:00:02`. Every IEEE 802.1AX LACPDU has a fixed wire structure containing Actor Information (`TLV 0x01`, length `20`), Partner Information (`TLV 0x02`, length `20`), Collector Information (`TLV 0x03`, length `16`), Terminator (`TLV 0x00`), and 50 reserved zero bytes.

FrameAssembly constructs the complete 110-byte LACPDU payload (124-byte Ethernet frame) automatically, defaulting both Actor and Partner state bitmasks to `0x3d` (Active + Aggregatable + In-Sync + Collecting + Distributing).

## Minimal Quickstart (`lacp_quickstart.frasm`)

```frameassembly
host tor_sw  { mac 00:1c:73:aa:10:01 }
host host_nic { mac 00:1b:21:bb:20:01 }

compile {
    tor_sw -> host_nic lacp
}
```

### Automatic Wire Calculations

- Sets Ethernet II EtherType to Slow Protocols `0x8809`, destination MAC to `01:80:c2:00:00:02`, Subtype `0x01` (LACP), and Version `0x01`.
- Builds the exact 110-byte LACPDU body: Actor TLV (`0x01`, 20B), Partner TLV (`0x02`, 20B), Collector TLV (`0x03`, 16B, MaxDelay `0x8000`), Terminator TLV (`0x00`), and 50 zero-pad octets.
- Defaults `actorsys` and `partnersys` from the endpoint MACs and sets `actorstate` / `partnerstate` to `0x3d` (healthy bundled active link).

## Practical Lab Example: LACP Port-Channel Bring-Up From Unsynced Defaulted to Active Distributing (`lacp_negotiation.frasm`)

Models a Linux bond interface and Top-of-Rack switch negotiating Port-Channel 10 (`key 10`) from initial unsynced discovery (`actorstate 0x45`) to full `0x3f` Fast-LACP Collecting/Distributing sync.

```frameassembly
host srv_bond0 { mac 00:1b:21:44:55:01 }
host tor_leaf1 { mac 00:1c:73:88:99:01 }

compile {
    // 1. Initial server LACPDU: Active + ShortTimeout + Aggregatable + Defaulted (0x47)
    srv_bond0 -> tor_leaf1 lacp actorkey 10 actorport 1 actorstate 0x47 partnerkey 0 partnerport 0 partnerstate 0x00 wait 5ms
    // 2. Switch replies recognizing server Actor as Partner and setting In-Sync (0x0f)
    tor_leaf1 -> srv_bond0 lacp actorkey 10 actorport 49 actorstate 0x0f partnersys 00:1b:21:44:55:01 partnerkey 10 partnerport 1 partnerstate 0x47 wait 5ms
    // 3. Both sides enter Active + Fast + Aggregatable + Sync + Collecting + Distributing (0x3f)
    srv_bond0 -> tor_leaf1 lacp actorkey 10 actorport 1 actorstate 0x3f partnersys 00:1c:73:88:99:01 partnerkey 10 partnerport 49 partnerstate 0x0f wait 2ms
    tor_leaf1 -> srv_bond0 lacp actorkey 10 actorport 49 actorstate 0x3f partnersys 00:1b:21:44:55:01 partnerkey 10 partnerport 1 partnerstate 0x3f
}
```

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

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

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

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

## All `lacp` Keywords & Header Options

Packet line pattern: `src_host -> dst_host lacp [actorsys <mac>] [actorkey <0..65535>] [actorport <0..65535>] [actorstate <0..255>] [partnersys <mac>] [partnerkey <0..65535>] [partnerport <0..65535>] [partnerstate <0..255>]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `actorsys <mac>` | 48-bit MAC address | `Source host MAC` | Sets the 6-byte Actor System MAC identifier inside TLV `0x01`. |
| `actorkey <0..65535> \| actorport <0..65535>` | 16-bit unsigned integers | `actorkey 1, actorport 1` | Sets the Actor Operational Key (LAG ID) and Actor Port Number. |
| `actorstate <0..255>` | 8-bit IEEE 802.1AX state bitmask | `0x3d` | Bitmask: `0x01` Activity, `0x02` Timeout (1=Short 1s), `0x04` Aggregation, `0x08` Sync, `0x10` Collecting, `0x20` Distributing, `0x40` Defaulted, `0x80` Expired. |
| `partnersys <mac>` | 48-bit MAC address | `Destination host MAC` | Sets the 6-byte Partner System MAC identifier inside TLV `0x02`. |
| `partnerkey <0..65535> \| partnerport <0..65535>` | 16-bit unsigned integers | `partnerkey 1, partnerport 1` | Sets the Partner Operational Key and Partner Port Number. |
| `partnerstate <0..255>` | 8-bit IEEE 802.1AX state bitmask | `0x3d` | Sets the 8-bit Partner State bitmask recorded by the sender. |

## Cross-Layer Options Valid with `lacp`

| 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

### Zero Underscores in Actor and Partner Modifiers

- **Avoid:** `sw1 -> sw2 lacp actor_key 10 actor_state 0x3d`
- **Valid v3.2.2 Syntax:** `sw1 -> sw2 lacp actorkey 10 actorstate 0x3d`

All LACP modifiers follow the strict `[a-z0-9]+` rule: `actorsys`, `actorkey`, `actorport`, `actorstate`, `partnersys`, `partnerkey`, `partnerport`, `partnerstate`.

### LACP Frames Are Never VLAN-Tagged on Native Port-Channel Members

- **Valid v3.2.2 Syntax:** `sw1 -> sw2 lacp actorkey 10 actorport 1`

Per IEEE 802.1AX, link-local LACPDUs (`01:80:c2:00:00:02`) are transmitted untagged on physical member links unless explicitly testing provider L2 protocol tunneling.
