← Interview Prep

STP / RSTP / MSTP — Theory

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.

802.1D STP

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.

RSTP (802.1w)

Rapid STP converges in sub-second by replacing timers with an active handshake.

RSTP port roleMeaning
RootBest path to the root (same as STP).
DesignatedForwards onto a segment (same as STP).
AlternateA backup to the root — a blocked path that can take over instantly.
BackupA backup for a designated port on a shared segment.

MSTP (802.1s)

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.

Protecting the topology

FeatureProtects against
BPDU GuardA switch plugged into an edge/PortFast port — err-disables the port on any BPDU.
Root GuardA downstream switch trying to become root — blocks superior BPDUs.
Loop GuardA blocked port going forwarding when BPDUs stop (unidirectional link) — keeps it blocking.
UDLDUnidirectional fiber (TX/RX mismatch) that STP can't see.
BPDU Filter / Storm-controlSuppress BPDUs on edge ports / cap broadcast rates.

The modern data center: less STP

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.

Likely interview questions

Related: VLAN & VXLAN · Office Network Architecture · L2 Forwarding.