Spanning Tree Protocol (STP)
Also known as: stp, 802.1d
The Spanning Tree Protocol (STP) is a Layer 2 protocol that prevents switching loops in networks with redundant links. It blocks selected ports so that only one active path exists between any two devices, then reactivates a blocked path if the primary link fails.
Redundant links between switches improve availability but create a serious problem: Ethernet frames have no time-to-live field, so a broadcast frame entering a physical loop circulates forever. The result is a broadcast storm, compounded by duplicate unicast frames and MAC address table instability as the same source address appears on multiple ports. STP, standardized as IEEE 802.1D, solves this by logically pruning the redundant links into a loop-free tree while keeping them physically connected as standby paths.
Switches build the tree by exchanging BPDUs (bridge protocol data units). First they elect a single root bridge — the switch with the lowest bridge ID, which is the bridge priority followed by the MAC address, with the default priority of 32768 meaning the lowest MAC wins by default. Each remaining switch then selects one root port, the interface with the lowest cumulative path cost back to the root. Each network segment elects one designated port, and every remaining port is put into a blocking state. Path cost depends on link speed, so faster links are preferred: a gigabit link costs less than a 100 Mbps link, which costs less than a 10 Mbps link.
Classic 802.1D ports move through blocking, listening, learning, and forwarding states, and the timers involved mean convergence after a topology change can take roughly 30 to 50 seconds. That delay drove several improvements: Rapid Spanning Tree Protocol (802.1w) converges in seconds, while Per-VLAN Spanning Tree Plus and Multiple Spanning Tree adapt the protocol to VLAN-based networks. Optional features harden the edge of the network — PortFast moves an access port to forwarding immediately for end devices, and BPDU Guard shuts down such a port if it unexpectedly receives a BPDU.
STP is core CCNA material in the Layer 2 redundancy domain. Be able to determine which switch becomes the root bridge from a set of bridge IDs, identify root and designated ports, explain the port states and their purpose, and describe how PortFast and BPDU Guard work together on access ports.
Key takeaways
- STP prevents Layer 2 loops, which would otherwise cause broadcast storms, duplicate frames, and MAC table instability.
- Switches exchange BPDUs to elect a root bridge — the switch with the lowest bridge priority, then the lowest MAC address.
- Each non-root switch chooses one root port based on the lowest path cost to the root, and every segment has one designated port; the rest are blocked.
- Classic 802.1D convergence takes about 30 to 50 seconds; RSTP (802.1w) converges far faster.
- PortFast skips the delay on access ports, and BPDU Guard disables such a port if a BPDU arrives on it.
