A comprehensive interactive lesson for network administration students. Master STP concepts, BPDU structure, port states, and root bridge elections.
Understanding the purpose and history of STP
Ethernet networks use switches to connect devices. When switches are connected in a redundant topology (multiple paths between switches), a Layer 2 loop can form. This causes:
STP (IEEE 802.1D, 1990) solves the loop problem by logically blocking redundant links while maintaining physical redundancy. It:
STP operates at the Data Link Layer (Layer 2) of the OSI model. It uses BPDU (Bridge Protocol Data Unit) frames with a destination MAC of 01:80:C2:00:00:00 (STP multicast) to communicate between switches.
| Standard | Full Name | Year | Convergence | Key Feature |
|---|---|---|---|---|
| 802.1D | Original STP | 1990 | 30–50 sec | Loop prevention baseline |
| PVST+ | Per-VLAN STP Plus | Cisco | 30–50 sec | Instance per VLAN (Cisco) |
| 802.1w | Rapid STP (RSTP) | 2001 | 1–6 sec | New port roles, rapid convergence |
| 802.1s | Multiple STP (MSTP) | 2002 | 1–6 sec | Maps multiple VLANs to instances |
| Rapid PVST+ | Rapid Per-VLAN STP | Cisco | 1–6 sec | RSTP + per-VLAN (Cisco default) |
Key terminology and operational principles
Every switch has a unique Bridge ID consisting of:
The switch with the lowest BID becomes the Root Bridge — the reference point for the entire spanning tree topology. All paths are calculated relative to it.
STP calculates the best path to the root based on cumulative port costs. Lower cost = preferred path.
| Speed | Cost (IEEE) |
|---|---|
| 10 Mbps | 100 |
| 100 Mbps | 19 |
| 1 Gbps | 4 |
| 10 Gbps | 2 |
PortFast Bypasses Listening/Learning on access ports (connected to end devices). Instantly moves to Forwarding.
BPDU Guard Disables a PortFast-enabled port if a BPDU is received — prevents unauthorized switch connections.
Root Guard Prevents external switches from becoming root bridge on a protected port.
Loop Guard Prevents Alternate/Root ports from becoming Designated if BPDUs stop arriving (prevents unidirectional link loops).
Step-by-step walk-through of how STP selects the Root Bridge
Enter switch parameters to compute Bridge IDs and determine the Root Bridge winner.
On each non-root switch, the port with the lowest Root Path Cost becomes the Root Port. Ties are broken by:
For each network segment, the port with the lowest Root Path Cost on that segment becomes the Designated Port. If costs are equal, the switch with the lower BID wins. All Root Bridge ports are automatically Designated.
Understanding how ports transition through STP states
| State | Receives BPDUs | Sends BPDUs | Learns MACs | Forwards Data | Duration |
|---|---|---|---|---|---|
| Disabled | No | No | No | No | Until enabled |
| Blocking | Yes ✓ | No | No | No | Max Age (20s) |
| Listening | Yes ✓ | Yes ✓ | No | No | Fwd Delay (15s) |
| Learning | Yes ✓ | Yes ✓ | Yes ✓ | No | Fwd Delay (15s) |
| Forwarding | Yes ✓ | Yes ✓ | Yes ✓ | Yes ✓ | Normal operation |
RSTP (802.1w) reduces states to just 3:
RSTP achieves rapid convergence through proposal/agreement handshake mechanism.
Click any port state to learn what happens at that stage.
Anatomy of the STP control message
01:80:C2:00:00:00.
Each colored block represents a field. Hover for details. Width is proportional to byte length.
| Field | Size | Value / Description |
|---|---|---|
| Protocol Identifier | 2 bytes | Always 0x0000 (Spanning Tree Protocol) |
| Protocol Version | 1 byte | 0x00 = STP, 0x02 = RSTP, 0x03 = MSTP |
| BPDU Type | 1 byte | 0x00 = Config, 0x80 = TCN (Topology Change Notification) |
| Flags | 1 byte | TC bit (bit 0), TCA bit (bit 7); RSTP adds bits 1–6 |
| Root Bridge ID | 8 bytes | Priority + Extended SysID + MAC of Root Bridge |
| Root Path Cost | 4 bytes | Cumulative cost from sender to Root Bridge |
| Bridge ID | 8 bytes | Sender's own Bridge ID |
| Port ID | 2 bytes | Sender's port priority + port number |
| Message Age | 2 bytes | Hops from Root Bridge (in 1/256 sec increments) |
| Max Age | 2 bytes | Maximum age for stored BPDU info (default 20s) |
| Hello Time | 2 bytes | Hello interval (default 2s) |
| Forward Delay | 2 bytes | Listening/Learning duration (default 15s) |
TC=Topology Change, TCA=TC Ack, Agr=Agreement, Fwd=Forwarding, Lrn=Learning, Prop=Proposal (RSTP bits 1-6)
Construct a complete BPDU frame field by field
IEEE 802.1D Configuration BPDU — 35 bytes total
Watch STP elect a root bridge and converge on a loop-free topology
Key terms and definitions for network administrators
Test your understanding of Spanning Tree Protocol