Protocol 5 of 81Layer 2FrameAssembly v3.1.2
llms-full.txt
stpIEEE 802.1D Spanning Tree & IEEE 802.1w Rapid Spanning Tree

Declare Yourself Root Bridge (stp / rstp) Safely Inside a .pcap

Default Port / Protocol
802.3 LLC 0x4242 -> 01:80:c2:00:00:00
Host Endpoint Rule
MAC-Only or IP
Wireshark Display Filter
stp
Standards & Specs
IEEE 802.1D, IEEE 802.1w
Wire Stack:Ethernet IISTP / RSTP (802.3 LLC 0x4242 -> 01:80:c2:00:00:00)

What It Does on the Wire

Electing your laptop Root Bridge on a live corporate VLAN is a career-limiting move — crafting stp and stp rstp BPDUs into a .pcap lets you audit BPDU Guard without the walk of shame.

Spanning Tree Protocol (stp) prevents Layer 2 bridging loops by exchanging Bridge Protocol Data Units (BPDUs) encapsulated inside IEEE 802.3 length-framed Ethernet + LLC (DSAP=0x42, SSAP=0x42, Control=0x03) addressed to the Bridge Group multicast MAC 01:80:c2:00:00:00.

FrameAssembly emits classic IEEE 802.1D Configuration BPDUs by default (version 0x00, 35-byte BPDU) and switches seamlessly to IEEE 802.1w Rapid Spanning Tree (rstp, version 0x02, type 0x02, including the mandatory Version 1 Length 0x00 byte) when the rstp flag is added.

BPDU Guard & Root Guard Security Audits

Craft superior Root Bridge BPDUs (rootid "4096:00:00:0c:aa:bb:cc" cost 0) to verify edge ports enter err-disabled under BPDU Guard or root-inconsistent under Root Guard.

RSTP Proposal / Agreement Flag Dissection

Test RSTP port-role and Topology Change (flags) bitfields in Wireshark and switch control-plane packet analyzers.

802.3 LLC Frame Parser & Dissector Fuzzing

Exercise packet parsers that distinguish Ethernet II EtherTypes (>= 0x0600) from IEEE 802.3 payload-length headers (<= 1500 bytes) + 3-byte LLC headers.

Minimal Quickstart (stp_quickstart.frasm)

Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.

stp_quickstart.frasm6 lines
Open in Playground
host root_sw { mac 00:1c:73:00:00:01 }
host edge_sw { mac 00:1c:73:00:00:02 }
compile {
root_sw -> edge_sw stp rstp
}

What the Compiler Calculates So You Don't Have To

  • Addresses Ethernet destination to IEEE Bridge Group multicast 01:80:c2:00:00:00 and writes the exact IEEE 802.3 Payload Length field instead of an Ethernet II EtherType.
  • Prepends the 3-byte LLC header (0x42 0x42 0x03) and Protocol Identifier 0x0000 ahead of the Configuration or RSTP BPDU.
  • Converts maxage (20), hellotime (2), and forwarddelay (15) seconds into IEEE 802.1D 1/256-second timer units (0x1400, 0x0200, 0x0f00) automatically.
Multi-Frame Lab · Ready to Compile

Normal Root RSTP Heartbeat Followed by Rogue Superior BPDU Attack

Captures a legitimate distribution switch sending RSTP BPDUs (priority 32768), followed by a rogue access device advertising priority 4096 (cost 0) to trigger Root Guard / BPDU Guard.

stp_rogue_root_audit.frasm12 lines
Open in Playground
host dist_root { mac 00:1c:73:01:00:01 }
host access_sw { mac 00:1c:73:02:00:10 }
host rogue_port { mac 00:50:56:99:99:99 }
compile {
// Legitimate RSTP Proposal/Learning-Forwarding BPDU from distribution root
dist_root -> access_sw stp rstp rootid "32768:00:1c:73:01:00:01" bridgeid "32768:00:1c:73:01:00:01" portid 0x8001 cost 0 flags 0x3c wait 2s
// Downstream access switch relaying root path cost 20000
access_sw -> rogue_port stp rstp rootid "32768:00:1c:73:01:00:01" bridgeid "32768:00:1c:73:02:00:10" portid 0x8018 cost 20000 flags 0x3c wait 500ms
// Rogue device injecting a superior Root ID (priority 4096, cost 0)
rogue_port -> access_sw stp rstp rootid "4096:00:50:56:99:99:99" bridgeid "4096:00:50:56:99:99:99" portid 0x8001 cost 0 flags 0x0e
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show stp_rogue_root_audit.frasm

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

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

All stp Keywords & Header Options

Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after stp:

src_host -> dst_host stp [rstp] [rootid "<text>"] [bridgeid "<text>"] [portid <0..65535>] [cost <number>] [maxage <0..65535>] [hellotime <0..65535>] [forwarddelay <0..65535>] [flags <0..255>]
Keyword / OptionAccepted ValueDefaultEffect on Packet
rstpBare boolean flagOmitted (classic 802.1D v0)Emits IEEE 802.1w Rapid STP BPDU (Protocol Version 2, BPDU Type 0x02, plus trailing 1-byte Version 1 Length 0x00).
rootid "<text>"Bridge ID string ("<prio>:<mac>" or "<mac>")"32768:<src_mac>"Encodes the 8-byte Root Identifier (2-byte priority + 6-byte MAC).
bridgeid "<text>"Bridge ID string ("<prio>:<mac>" or "<mac>")"32768:<src_mac>"Encodes the 8-byte Bridge Identifier of the transmitting switch.
portid <0..65535>Whole number (0..65535)0x8001Sets the 2-byte Port Identifier (4-bit priority + 12-bit port number).
cost <number>Whole number0Sets the 4-byte Root Path Cost (20000 = 1GbE, 2000 = 10GbE).
maxage <0..65535> | hellotime <0..65535> | forwarddelay <0..65535>16-bit unsigned integers (seconds)maxage 20, hellotime 2, forwarddelay 15Encodes BPDU timers scaled to IEEE 802.1D 1/256s increments.
flags <0..255>8-bit bitmask0 (or RSTP role bits)Sets Topology Change (0x01), Proposal (0x02), Port Role (bits 2..3), Learning (0x10), Forwarding (0x20), Agreement (0x40), and TCA (0x80).

Cross-Layer Wrappers Valid with stp

802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol

6 options
OptionRange / FormatDefaultEffect on Packet
wait <number><ns|us|ms|s|m>Time gap (ns, us, ms, s, m)10msAdvances 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)OmittedAppends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums.
srcmac <mac> | dstmac <mac>Colon, hyphen, or Cisco dot MACHost MAC / RFC multicast MACOverrides the 14-byte Ethernet II source or destination MAC address for this single packet.
vlan <0..4095> [pcp <0..7>] [dei <0|1>]VLAN ID 0..4095, PCP 0..7, DEI 0..1UntaggedWraps 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..4095Untagged (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> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>]Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255Unlabeled (at most 1 mpls tag per packet)Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header.

Gotchas & Quick Fixes

portid on stp Takes a Numeric u16, Not an Interface Name

Avoid
sw1 -> sw2 stp portid "Gi1/0/1"
Valid v3.1.2 Syntax
sw1 -> sw2 stp rstp portid 0x8001

Unlike lldp portid "Gi1/0/1", IEEE 802.1D/1w STP encodes a 16-bit numeric Port Identifier (0x8001 = default priority 128, port 1).

Quote Priority:MAC Strings in rootid and bridgeid

Avoid
sw1 -> sw2 stp rootid 32768:00:1c:73:01:00:01
Valid v3.1.2 Syntax
sw1 -> sw2 stp rootid "32768:00:1c:73:01:00:01"

Composite <priority>:<mac> values have 7 colon-separated groups (rather than a 6-octet MAC literal) and should be enclosed in double quotes.

Field Guide 07
Physical Hardware Labs: Blasting .pcap Captures onto Real Copper & Fiber (tcpreplay)