Skip to content
Tech News
← Back to articles

An interactive tour of the spanning tree protocol

read original get NETGEAR GS308E Managed Gigabit Switch → more articles
Why This Matters

A hands-on explainer that runs a real spanning tree protocol implementation directly in the browser, letting readers watch STP block redundant links and rebuild a loop-free topology when a cable is pulled. It matters because STP is foundational but poorly understood plumbing in every Ethernet network, and interactive simulation is a far more effective teaching tool than static diagrams.

Key Takeaways
Worth a Look

NETGEAR GS308E Managed Gigabit Switch — If reading about spanning tree makes you want to build your own loop-free network, this compact 8-port managed switch lets you experiment with STP, VLANs and port settings on real hardware. It's a great, quiet desktop-sized way to learn switching without a rack. Pair it with a few spare Ethernet cables and you can even recreate the 'Stan kicks out a cable' test yourself.

See NETGEAR GS308E Managed Gigabit Switch on Amazon → Affiliate link — we may earn a commission on purchases, at no extra cost to you. Product picked by AI based on this article; it is not a tested recommendation.

Warning This post contains interactive examples. To visualize and interact with them, you need to leave your RSS reader.

Warning This post contains interactive examples. To visualize and interact with them, you need to enable JavaScript.

Imagine you rent office space for a three-day event. You quickly set up a few Ethernet switches and tape some cables on the floor to get everyone online. Unfortunately, Stan, your clumsiest coworker, kicks out a cable every time he gets up for coffee. You could add extra cables, but then you’d get a broadcast storm: Ethernet packets that loop and multiply until nothing else gets through.

That’s where the spanning tree protocol ( STP ) comes in. STP blocks just enough of your spare cables to leave a loop-free tree. When Stan strikes again, it rebuilds the tree in a second, leaving some time for Blobby, your one-person support crew, to reconnect the cable.1 See for yourself: the diagram below runs a real STP implementation in your browser!

1 The sprites for Stan and Blobby come from Craftpix, the coffee cups from Yanin. ❦

:demo A1 @0,0 prio=4096 A2 @0,1 A3 @0,2 A4 @0,3 B1 @1,0 prio=8192 B2 @1,1 B3 @1,2 B4 @1,3 C1 @2,0 prio=8192 C2 @2,1 C3 @2,2 C4 @2,3 A1 -- A2 hazard=0 A2 -- A3 hazard=0 A3 -- A4 hazard=0 B1 -- B2 B2 -- B3 B3 -- B4 C1 -- C2 hazard=0 C2 -- C3 hazard=0 C3 -- C4 hazard=0 A1 -- B1 cost=10 B1 -- C1 cost=10 A4 -- B4 cost=20 B4 -- C4 cost=20 Leo @-0.3,0.7 proto=none icon=👦🏻 Mia @-0.3,1.3 proto=none icon=👧🏽 Joy @0.3,0.7 proto=none icon=👱🏻‍♀️ Roy @0.3,1.3 proto=none icon=👨🏾 A2 -- Leo hazard=0 A2:edge A2 -- Mia hazard=0 A2:edge A2 -- Joy hazard=0 A2:edge A2 -- Roy hazard=0 A2:edge Max @-0.3,1.7 proto=none icon=👨🏽 Zoe @-0.3,2.3 proto=none icon=👩🏾 Ada @0.3,1.7 proto=none icon=👵🏾 Amy @0.3,2.3 proto=none icon=👩🏼 A3 -- Max hazard=0 A3:edge A3 -- Zoe hazard=0 A3:edge A3 -- Ada hazard=0 A3:edge A3 -- Amy hazard=0 A3:edge Eli @0.7,0.7 proto=none icon=👦🏼 Jay @0.7,1.3 proto=none icon=👨🏻 Kai @1.3,0.7 proto=none icon=🧑🏽 Ben @1.3,1.3 proto=none icon=👱🏼 B2 -- Eli hazard=0.2 B2:edge B2 -- Jay hazard=0.2 B2:edge B2 -- Kai hazard=0.2 B2:edge B2 -- Ben hazard=0.2 B2:edge Ava @0.7,1.7 proto=none icon=👩🏻 Lea @0.7,2.3 proto=none icon=🧑🏾‍🦱 Ivy @1.3,1.7 proto=none icon=🧕🏽 Rex @1.3,2.3 proto=none icon=👴🏿 B3 -- Ava hazard=0.2 B3:edge B3 -- Lea hazard=0.2 B3:edge B3 -- Ivy hazard=0.2 B3:edge B3 -- Rex hazard=0.2 B3:edge Ana @1.7,0.7 proto=none icon=👩🏿 Eve @1.7,1.3 proto=none icon=👧🏼 Abe @2.3,0.7 proto=none icon=🧓🏿 Ian @2.3,1.3 proto=none icon=🧔🏾 C2 -- Ana hazard=0 C2:edge C2 -- Eve hazard=0 C2:edge C2 -- Abe hazard=0 C2:edge C2 -- Ian hazard=0 C2:edge Ned @1.7,1.7 proto=none icon=👨🏼‍🦳 Lou @1.7,2.3 proto=none icon=🧑🏿 Fay @2.3,1.7 proto=none icon=👧🏻 Sue @2.3,2.3 proto=none icon=👩🏽‍🦰 C3 -- Ned hazard=0 C3:edge C3 -- Lou hazard=0 C3:edge C3 -- Fay hazard=0 C3:edge C3 -- Sue hazard=0 C3:edge

Note This article is also available as a video, but I advise you to keep reading here to try the interactive demonstrations.

The basics#

Designed in the ’80s, the spanning tree protocol has evolved into a “rapid” flavor ( RSTP ) and a “VLAN-aware” variation ( MSTP ).2 Any sound-minded network engineer knows there are better alternatives, like BGP EVPN VXLAN. Yet, because any switch speaks it, the venerable spanning tree protocol still fills a niche.

We focus on RSTP : it replaced the original protocol in 2004. To eliminate network loops, RSTP implements a complex state machine. Timers, link state changes, and the link-local control frames a bridge receives from its neighbors drive its transitions. These Ethernet frames are the Bridge Protocol Data Units ( BPDUs ). You can watch them in action below: hit the “Start” button.

... continue reading