How Spanning Tree Protocol Actually Works | Shaznation
← Back to Blog
IT & Networking

How Spanning Tree Protocol Actually Works

How Spanning Tree Protocol Actually Works

If you have ever plugged two switches together in more than one place to add redundancy, you have created a problem without knowing it. Ethernet frames have no built-in time-to-live mechanism the way IP packets do. Left unchecked, a loop in a switched network causes frames to circulate forever, multiplying with every pass until every port on every switch is flooded and the whole network grinds to a halt. That storm can bring down a business in seconds. Spanning Tree Protocol, or STP, exists specifically to stop that from happening — and the way it does it is surprisingly elegant.

STP works by making switches talk to each other and then collectively agree to block certain ports so that only one logical path exists between any two points on the network at a time. The protocol uses small control messages called Bridge Protocol Data Units, or BPDUs, to do this. Every switch sends BPDUs out of all its ports at regular intervals, and those messages carry information about the switch's identity and cost to reach other parts of the network.

The first thing switches do when STP runs is elect a root bridge. Think of it as the reference point for the whole topology. Every switch compares the BPDUs it receives and votes for the switch with the lowest bridge ID, which combines a configurable priority value and a MAC address. Once a root bridge is elected, every other switch figures out which of its ports offers the cheapest path back to that root — that port becomes its root port and stays forwarding. Then, on each network segment, the switch closest to the root is designated to forward traffic. Any port that is not a root port or a designated port gets put into a blocking state. It receives BPDUs but sends no traffic, cleanly breaking the loop.

The original version of STP defined in IEEE 802.1D was notoriously slow to converge — it could take up to 50 seconds for the network to settle after a topology change, which is an eternity in a live environment. Rapid Spanning Tree Protocol, or RSTP, defined in IEEE 802.1w and later folded into the updated 802.1D standard, addressed this by allowing switches to negotiate port roles directly with their neighbors rather than waiting out fixed timers. Convergence dropped to just a few seconds in most cases.

Modern networks also commonly run Multiple Spanning Tree Protocol, or MSTP, which lets you map groups of VLANs to separate spanning tree instances. This matters because a single STP instance blocks the same ports for all traffic, potentially wasting bandwidth. With MSTP, you can load-balance across physically redundant links by having different VLANs use different active paths.

For anyone building or managing a network — whether that is a small office setup or something more complex running through ShazConnect infrastructure — understanding STP means understanding why your switches behave the way they do when a cable goes down or a new link comes up. The protocol runs silently in the background, but it is the reason your redundant connections work instead of melting your network into chaos.