LANs, Ethernet & Switching

the Spanning Tree Protocol

/ SPAN-ing tree /

The Spanning Tree Protocol stops a switched network from looping back on itself and melting down. People often wire extra cables between switches for backup, but loops are deadly at layer 2: a broadcast frame sent into a loop circles forever, multiplying each time it passes a switch, until the network drowns in copies (a broadcast storm). STP is the agreement among switches that says: keep the redundant links, but logically switch some off so that exactly one path connects any two points — a loop-free tree.

Here is the idea in plain steps. The switches elect one switch as the root of the tree (the one with the lowest bridge ID). Every other switch then works out its lowest-cost path back to the root and keeps only the port on that best path active; ports that would create a second path to somewhere are put into a blocking state, where they carry no data frames but still listen. The switches discover all this by exchanging little messages called BPDUs. The result is a single tree that spans (reaches) every switch with no loops. If an active link fails, a previously blocked port wakes up and takes over, restoring connectivity — which is why people built the redundant links in the first place.

Classic STP could take tens of seconds to reconverge after a change, so it was replaced in practice by Rapid Spanning Tree (RSTP, 802.1w), which is much faster, and by per-VLAN variants. The honest caveat: STP fixes loops by leaving expensive links idle, so in modern datacenters it is often replaced by designs (like leaf-spine with equal-cost multipath or link aggregation) that use all the links at once instead of blocking them.

Three switches wired in a triangle for redundancy. STP elects a root, then blocks one port so the active topology is a line, not a triangle — no loop. Cut the active cable between two of them, and the blocked port unblocks within moments to restore the path.

Redundant cabling stays in place; STP keeps just one loop-free path active at a time.

STP prevents layer-2 loops, which IP's TTL does not — Ethernet frames have no hop count, so without STP a loop never stops. The cost is that blocked links sit idle until a failure.

Also called
STPIEEE 802.1DRSTPrapid spanning tree生成樹