# eapol — IEEE 802.1X Port Authentication & EAPOL Frames (`eapol`)

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

- **Full Protocol Name:** IEEE 802.1X Port-Based Network Access Control (EAP over LAN)
- **Keyword:** `eapol`
- **OSI Layer & Transport:** Layer 2 · EtherType 0x888e -> 01:80:c2:00:00:03
- **Host Endpoint Rule:** MAC-Only or IP
- **Standards:** IEEE 802.1X, RFC 3748
- **Wireshark Display Filter:** `eapol || eap`
- **Wire Encapsulation:** `Ethernet II -> 802.1X EAPOL (EtherType 0x888e -> 01:80:c2:00:00:03)`

## Overview

Before your workstation even gets an IP address, `supplicant -> switch eapol start` kicks off the 802.1X bouncer at the switch port so you can script the whole EAP identity handshake without locking your own NIC into quarantine VLAN 999.

Extensible Authentication Protocol over LAN (`eapol`) carries IEEE 802.1X Port-Based Network Access Control signaling directly over Ethernet II (`0x888e`) between an endpoint Supplicant and a switch or wireless Authenticator (PAE multicast group MAC `01:80:c2:00:00:03`).

FrameAssembly models the complete 802.1X access-port lifecycle: `start` (`EAPOL-Start`), `eappacket` (`EAP-Request/Response/Success/Failure` with `identity` or EAP method codes), `key` (WPA2/MACsec EAPOL-Key descriptors), and `logoff` (`EAPOL-Logoff`)—and pairs naturally with `radius` frames on the upstream switch-to-AAA leg.

## Minimal Quickstart (`eapol_quickstart.frasm`)

```frameassembly
host supplicant { mac 00:1b:21:cc:10:25 }
host switch_pae { mac 00:1c:73:aa:00:01 }

compile {
    supplicant -> switch_pae eapol
}
```

### Automatic Wire Calculations

- Sets Ethernet II EtherType to `0x888e` and defaults destination MAC to the IEEE 802.1X PAE group address `01:80:c2:00:00:03`.
- Writes the 4-byte EAPOL header (`Protocol Version` default `2`, `Packet Type`, and exact 16-bit `Packet Body Length`).
- For `eappacket` (`type 0`), encodes the RFC 3748 EAP header (`Code`, `Identifier`, 16-bit `Length`, `Type` such as `1` Identity or `13` EAP-TLS, and `identity` bytes) or minimal 4-byte EAP-Success (`eapcode 3`) / EAP-Failure (`eapcode 4`).

## Practical Lab Example: Full IEEE 802.1X Supplicant Onboarding With Upstream RADIUS Verification (`eapol_8021x_nac.frasm`)

Traces a workstation sending `EAPOL-Start`, answering an `EAP-Request/Identity` challenge, triggering an upstream `RADIUS Access-Request/Accept` on the switch, and receiving `EAP-Success`.

```frameassembly
host laptop    { mac 00:1b:21:55:66:77 }
host access_sw { ip 10.20.0.2  mac 00:1c:73:00:01:02 }
host radius_srv { ip 10.20.0.50 mac 00:50:56:00:00:50 }

compile {
    // 1. Supplicant initiates 802.1X on physical switch port
    laptop -> access_sw eapol start version 2 wait 2ms
    // 2. Switch Authenticator requests EAP Identity (eapcode 1 = Request, eapmethod 1 = Identity)
    access_sw -> laptop eapol eappacket version 2 eapcode 1 eapid 1 eapmethod 1 dstmac 00:1b:21:55:66:77 wait 3ms
    // 3. Supplicant responds with corporate identity
    laptop -> access_sw eapol eappacket version 2 eapcode 2 eapid 1 eapmethod 1 identity "corp\\jdoe" wait 2ms
    // 4. Switch forwards authentication upstream to RADIUS AAA server
    access_sw -> radius_srv radius accessrequest id 10 user "corp\\jdoe" nasip 10.20.0.2 wait 4ms
    access_sw <- radius_srv radius accessaccept id 10 framedip 10.20.100.45 wait 2ms
    // 5. Switch grants port access with EAP-Success (eapcode 3)
    access_sw -> laptop eapol eappacket version 2 eapcode 3 eapid 1 dstmac 00:1b:21:55:66:77
}
```

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

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

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

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

## All `eapol` Keywords & Header Options

Packet line pattern: `src_host -> dst_host eapol [version <0..255>] [type <eappacket|start|logoff|key> | eappacket | start | logoff | key] [eapcode <0..255>] [eapid <0..255>] [eapmethod <0..255>] [identity "<text>"]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `eappacket \| start \| logoff \| key \| type <...>` | EAPOL packet type keyword or u8 | `eappacket (type 0)` | Selects EAPOL Packet Type: `eappacket` (`0`), `start` (`1`, 0-byte body), `logoff` (`2`, 0-byte body), or `key` (`3`, EAPOL-Key descriptor). |
| `version <0..255>` | Whole number (0..255) | `2 (802.1X-2004)` | Sets the 1-byte EAPOL Protocol Version (`1` = 2001, `2` = 2004, `3` = 2010/2020). |
| `eapcode <1..4>` | 8-bit RFC 3748 EAP Code | `2 (Response)` | Sets the inner EAP Code when `eappacket` is active: `1` Request, `2` Response, `3` Success, `4` Failure. |
| `eapid <0..255>` | 8-bit EAP Identifier | `1` | Matches an EAP Response (`eapcode 2`) to its corresponding EAP Request (`eapcode 1`). |
| `eapmethod <0..255>` | 8-bit EAP Method Type | `1 (Identity)` | Sets EAP Method on Request/Response: `1` Identity, `4` MD5-Challenge, `13` EAP-TLS, `25` PEAP. |
| `identity "<text>"` | UTF-8 string | `"user" (on Identity)` | Populates the EAP-Identity Type-Data string (escape backslashes as `"corp\\alice"`). |

## Cross-Layer Options Valid with `eapol`

| 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

### Escape Backslashes in Windows Domain Identities

- **Avoid:** `laptop -> sw eapol identity "corp\alice"`
- **Valid v3.2.2 Syntax:** `laptop -> sw eapol identity "corp\\alice"`

Double-quoted `.frasm` strings support C-style escape sequences (`\r`, `\n`, `\t`, `\\`). Write `"corp\\alice"` so the wire string contains a literal `\` rather than an escape.

### MAC-Only Supplicants Cannot Directly Send L3 RADIUS

- **Avoid:** `laptop -> radius_srv radius accessrequest (when laptop has no ip)`
- **Valid v3.2.2 Syntax:** `access_sw -> radius_srv radius accessrequest (switch has ip + mac)`

`eapol` supports MAC-only hosts, whereas `radius` is a Layer 7 UDP protocol requiring IPv4 or IPv6 addresses on both endpoints.
