# pppoe — Broadband PADI/PADO/PADR/PADS Discovery & Session Frames (`pppoe`)

> **FrameAssembly v3.3.0** · Protocol 13 of 81 · Canonical URL: https://frameassembly-lang.dev/docs/protocols/pppoe

- **Full Protocol Name:** Point-to-Point Protocol over Ethernet (Discovery & Session)
- **Keyword:** `pppoe`
- **OSI Layer & Transport:** Layer 2 · EtherType 0x8863 / 0x8864
- **Host Endpoint Rule:** MAC-Only or IP
- **Standards:** RFC 2516, RFC 4638
- **Wireshark Display Filter:** `pppoed || pppoes`
- **Wire Encapsulation:** `Ethernet II -> PPPoE (EtherType 0x8863 / 0x8864)`

## Overview

Still powering tens of millions of FTTH fiber ONTs worldwide: `pppoe` steps cleanly through `0x8863` `padi -> pado -> padr -> pads` discovery tags and `0x8864` subscriber `session` data.

Point-to-Point Protocol over Ethernet (`pppoe`, RFC 2516) remains the primary residential FTTH/GPON and wholesale broadband subscriber access encapsulation terminating on ISP Broadband Network Gateways (BNGs). PPPoE operates across two distinct EtherTypes: **Discovery (`0x8863`)**—which negotiates a 16-bit Session ID via `padi` (`0x09`), `pado` (`0x07`), `padr` (`0x19`), `pads` (`0x65`), and `padt` (`0xa7`)—and **Session (`0x8864`)**, which carries 2-byte PPP Protocol IDs (`0xc021` LCP, `0xc023` PAP, `0xc223` CHAP, `0x0021` IPv4, `0x0057` IPv6).

FrameAssembly encodes Discovery TLV tags (`0x0101` Service-Name, `0x0102` AC-Name, `0x0103` Host-Uniq, `0x0104` AC-Cookie), broadcasts `padi` to `ff:ff:ff:ff:ff:ff` automatically, and calculates exact 16-bit PPPoE payload lengths.

## Minimal Quickstart (`pppoe_quickstart.frasm`)

```frameassembly
host ont_cpe { mac 00:1b:21:c0:00:10 }
host isp_bng { mac 00:1c:73:b0:00:01 }

compile {
    ont_cpe -> isp_bng pppoe padi servicename "ftth-gigabit" hostuniq "01020304" wait 2ms
    ont_cpe <- isp_bng pppoe pado acname "bng-edge-01" servicename "ftth-gigabit" hostuniq "01020304" accookie "deadbeefcafe"
}
```

### Automatic Wire Calculations

- Selects EtherType `0x8863` for Discovery (`padi`, `pado`, `padr`, `pads`, `padt`) and `0x8864` for `session`, broadcasting `padi` to `ff:ff:ff:ff:ff:ff` automatically.
- Sets Version=1, Type=1 (`0x11`), writes `sessionid 0x0000` during Discovery (until `pads` assigns a non-zero session), and calculates the 16-bit PPPoE Length field.
- Encodes RFC 2516 Discovery Tags (`Service-Name`, `AC-Name`, `Host-Uniq`, `AC-Cookie`) or prepends the 16-bit `pppproto` header on `session` frames.

## Practical Lab Example: QinQ FTTH Subscriber DORA-Equivalent: PADI/PADO/PADR/PADS + PPP Session + PADT (`pppoe_bng_lifecycle.frasm`)

Models a residential ONT over QinQ (`S-VLAN 500`, `C-VLAN 101`) completing full PPPoE Discovery with an ISP BNG, exchanging a PPP session frame (`sessionid 0x1a2b`), and closing cleanly via `padt`.

```frameassembly
host cpe_ont { mac 00:1b:21:55:01:01 }
host bng_agg { mac 00:1c:73:99:00:01 }

compile {
    // 1. 4-step RFC 2516 PPPoE Discovery over QinQ S-VLAN 500 / C-VLAN 101
    cpe_ont -> bng_agg pppoe padi servicename "isp-fiber" hostuniq "a1b2c3d4" qinq 500 innervlan 101 wait 2ms
    cpe_ont <- bng_agg pppoe pado acname "bng-metro-01" servicename "isp-fiber" hostuniq "a1b2c3d4" accookie "aa55aa55" qinq 500 innervlan 101 wait 2ms
    cpe_ont -> bng_agg pppoe padr servicename "isp-fiber" hostuniq "a1b2c3d4" accookie "aa55aa55" qinq 500 innervlan 101 wait 2ms
    cpe_ont <- bng_agg pppoe pads sessionid 0x1a2b servicename "isp-fiber" hostuniq "a1b2c3d4" qinq 500 innervlan 101 wait 5ms
    // 2. Active PPPoE Session frame (EtherType 0x8864, PPP LCP 0xc021)
    cpe_ont -> bng_agg pppoe session sessionid 0x1a2b pppproto 0xc021 hexpayload "0901000812345678" qinq 500 innervlan 101 wait 10ms
    // 3. Session termination (PADT on EtherType 0x8863)
    cpe_ont -> bng_agg pppoe padt sessionid 0x1a2b qinq 500 innervlan 101
}
```

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

# 2. Compile .frasm -> classic .pcap, nanosecond .pcapng, or pipe via '-'
frameassembly pppoe_bng_lifecycle.frasm pppoe_bng_lifecycle.pcap
frameassembly pppoe_bng_lifecycle.frasm pppoe_bng_lifecycle.pcapng

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

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

## All `pppoe` Keywords & Header Options

Packet line pattern: `src_host -> dst_host pppoe [padi | pado | padr | pads | padt | session] [sessionid <0..65535>] [servicename "<text>"] [acname "<text>"] [hostuniq "<hex>"] [accookie "<hex>"] [pppproto <0..65535>]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `padi \| pado \| padr \| pads \| padt \| session` | PPPoE stage keyword (or `type <stage>`) | `padi (Discovery 0x09)` | Selects Discovery codes `0x09` (`padi`), `0x07` (`pado`), `0x19` (`padr`), `0x65` (`pads`), `0xa7` (`padt`) on `0x8863`, or `session` (`0x00`) on `0x8864`. |
| `sessionid <0..65535>` | 16-bit PPPoE Session ID | `0 on PADI/PADO/PADR; 1 on PADS/Session` | Sets the big-endian 16-bit Session_ID in bytes 2..3 of the 6-byte PPPoE header. |
| `servicename "<text>"` | Quoted ISP service string | `"" (empty wildcard Service-Name tag)` | Encodes Discovery Tag `0x0101` (`Service-Name`). |
| `acname "<text>"` | Quoted Access Concentrator name | `Omitted unless set (or "AC" on PADO)` | Encodes Discovery Tag `0x0102` (`AC-Name` advertised by the BNG in `pado`). |
| `hostuniq "<hex>"` | Quoted hex byte string | `Omitted unless set` | Encodes Discovery Tag `0x0103` (`Host-Uniq` client correlation token). |
| `accookie "<hex>"` | Quoted hex byte string | `Omitted unless set` | Encodes Discovery Tag `0x0104` (`AC-Cookie` SYN-cookie-style anti-spoofing token). |
| `pppproto <0..65535>` | 16-bit PPP Protocol ID (e.g. 0xc021, 0x0021, 0x0057) | `0x0021 (IPv4)` | Sets the 2-byte PPP Protocol field immediately following the `0x8864` PPPoE Session header. |

## Cross-Layer Options Valid with `pppoe`

| 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). |
| `comment "<text>"` | Quoted UTF-8 annotation | `Omitted` | Attaches an Enhanced Packet Block `opt_comment` annotation when compiling to `.pcapng` (Wireshark `pkt_comment` filter). |
| `payload "<text>" \| hexpayload "<hex>"` | Quoted text or hex bytes (choose one) | `Omitted` | Appends or overrides raw payload bytes (`"deadbeef"`, `"de:ad:be:ef"`, or `"\x01\x02"`) and updates packet lengths and checksums. |
| `srcmac <mac> \| dstmac <mac> \| ethertype <0..65535>` | Colon/hyphen/Cisco MAC · EtherType 0..65535 (e.g. 0x0800) | `Host MAC / RFC multicast MAC / auto EtherType` | Overrides the 14-byte Ethernet II source MAC, destination MAC, or standalone Layer 2 16-bit EtherType. |
| `fcs \| badfcs` | Ethernet CRC-32 trailer flags (choose one) | `Omitted` | `fcs` appends a valid IEEE 802.3 4-byte CRC-32 Frame Check Sequence trailer; `badfcs` XOR-corrupts the CRC-32 for NIC/tap negative tests. |
| `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>]` | Repeatable label stack (0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255) | `Unlabeled (auto bos=0 on outer labels, bos=1 on bottom)` | Prepends one or more 32-bit MPLS label shims (`0x8847`, e.g. `mpls 16000 mpls 24010`) ahead of Layer 2 EoMPLS or Layer 3 payloads. |

## Common Mistakes & Quick Fixes

### hostuniq and accookie Expect Quoted Even-Length Hex Bytes

- **Avoid:** `cpe -> bng pppoe padi hostuniq "router-1"`
- **Valid v3.3.0 Syntax:** `cpe -> bng pppoe padi hostuniq "6370653031"`

`hostuniq` and `accookie` are raw binary RFC 2516 TLV octets parsed as hex byte strings (`"a1b2c3d4"` or `"a1:b2:c3:d4"`).

### Discovery Uses sessionid 0 Until PADS Assigns the Session ID

- **Avoid:** `cpe -> bng pppoe padi sessionid 42`
- **Valid v3.3.0 Syntax:** `cpe <- bng pppoe pads sessionid 42`

Per RFC 2516, `padi`, `pado`, and `padr` carry `SESSION_ID = 0x0000`; the BNG assigns the non-zero `sessionid` in `pads`, which both peers reuse in `session` and `padt`.
