Spanning Tree end to end: why Ethernet needs it, 802.1D root/port election, states & timers, RSTP (802.1w) roles & proposal/agreement fast convergence, MSTP (802.1s) regions & instances, and protection (BPDU/Root/Loop Guard, UDLD).
Ethernet has no TTL — a single L2 loop means frames circulate forever, broadcasts multiply into a storm, and MAC tables thrash. Spanning Tree exists to kill loops by pruning a physical mesh into a logical tree. The interview arc is the evolution: STP (slow) → RSTP (fast) → MSTP (fast and scalable across many VLANs).
The invariant across all three: elect one root bridge, then every other switch keeps its single best path to the root and blocks the rest — leaving a loop-free active topology.
Switches exchange BPDUs and converge on a tree:
Classic STP is slow: ports walk blocking → listening → learning →
forwarding on timers (hello 2s, max-age 20s, forward-delay 15s) — 30–50 seconds to
converge. A Topology Change (TCN) flushes MAC tables so traffic re-learns the new path.
Rapid STP converges in sub-second by replacing timers with an active handshake.
| RSTP port role | Meaning |
|---|---|
| Root | Best path to the root (same as STP). |
| Designated | Forwards onto a segment (same as STP). |
| Alternate | A backup to the root — a blocked path that can take over instantly. |
| Backup | A backup for a designated port on a shared segment. |
Per-VLAN spanning tree (Rapid-PVST) runs one instance per VLAN — 1000 VLANs = 1000 trees = huge CPU. MSTP maps many VLANs onto a few instances (MSTIs), so you get per-instance load-balancing without the per-VLAN cost.
| Feature | Protects against |
|---|---|
| BPDU Guard | A switch plugged into an edge/PortFast port — err-disables the port on any BPDU. |
| Root Guard | A downstream switch trying to become root — blocks superior BPDUs. |
| Loop Guard | A blocked port going forwarding when BPDUs stop (unidirectional link) — keeps it blocking. |
| UDLD | Unidirectional fiber (TX/RX mismatch) that STP can't see. |
| BPDU Filter / Storm-control | Suppress BPDUs on edge ports / cap broadcast rates. |
STP wastes links (blocking) and scales poorly. Modern fabrics avoid it: MLAG/vPC makes two switches look like one so both uplinks forward (STP still a backstop); routed leaf-spine + EVPN/VXLAN replaces L2 with L3 ECMP entirely — no blocked links, no spanning tree in the fabric. See VLAN & VXLAN.