← Enterprise IT Networks Studio
🌲

Spanning Tree Protocol (STP) Convergence Simulator

Root bridge election, port roles, and loop prevention across 4 switches — click any link to fail/restore it

Forwarding
Blocking
Failed
Click a link below to fail / restore it
FORWARDINGFORWARDINGFORWARDINGBLOCKINGBLOCKINGSW-1P:4096 (ROOT)SW-2P:8192SW-3P:8192SW-4P:32768
Convergence Log
STP initialized. Root Bridge elected: SW-1 (priority 4096, lowest Bridge ID wins).
Root bridge election: every switch advertises a Bridge ID (priority + MAC address) in BPDUs. The switch with the numerically lowest Bridge ID becomes root — here SW-1 (priority 4096) beats SW-2/SW-3 (8192) and SW-4 (32768). Lower priority always wins; MAC address is only a tie-breaker.
Port Roles
Root Port (RP)
The port on a non-root switch with the lowest-cost path back to the root bridge — always forwarding.
Designated Port (DP)
The best (lowest-cost) port on each segment — forwards traffic away from the root, one per segment.
Blocked / Alternate Port
A redundant port that discards data frames (but still hears BPDUs) to prevent a Layer 2 loop.
RSTP Alternate → Forwarding
RSTP promotes a blocked alternate port to forwarding almost instantly (sub-second) on failure, vs. up to 50s for legacy 802.1D STP.
Key Facts
IEEE 802.1D defines original STP; 802.1w defines RSTP
BPDUs (Bridge Protocol Data Units) are exchanged every 2s by default
Two redundant links here mean 2 loops exist — both must be broken
PortFast + BPDU Guard protect access ports from accidental loops

About the STP Convergence Simulator

This simulator visualizes the Spanning Tree Protocol (STP) operating on a small 4-switch network with two redundant links. It shows how STP elects a root bridge by lowest Bridge ID, determines root ports and designated ports along the lowest-cost path to that root, and blocks the remaining redundant links to guarantee a loop-free logical topology — then lets you fail any link to watch STP/RSTP reconverge in real time.

Why Ethernet needs a loop-prevention protocol

Physical redundancy — multiple cabled paths between switches — is desirable for reliability, but Ethernet frames have no TTL field and switches flood unknown-unicast and broadcast frames out every port. Without a loop-prevention protocol, a redundant physical loop causes those frames to circulate endlessly, duplicating exponentially and consuming all available bandwidth within seconds — a broadcast storm that can take down an entire Layer 2 segment. Spanning Tree Protocol (IEEE 802.1D) solves this by computing a loop-free logical tree over the physical topology and administratively blocking any link not part of that tree.

The three-step STP algorithm

First, every switch exchanges BPDUs (Bridge Protocol Data Units) advertising its Bridge ID (a priority value plus its MAC address); the switch with the lowest Bridge ID is elected root bridge — in this simulation, SW-1 with priority 4096. Second, every non-root switch determines its Root Port: the single port offering the lowest-cost path back to the root. Third, for every network segment, the switch offering the lowest-cost path to the root on that segment becomes the Designated Port for that segment; any other port on that segment is blocked to prevent a loop.

STP vs. RSTP convergence time

Legacy 802.1D STP takes up to 30–50 seconds to converge after a topology change, cycling every affected port through Listening (15s) and Learning (15s) states before Forwarding — a real availability problem for modern networks. Rapid Spanning Tree Protocol (RSTP, IEEE 802.1w) redesigns the state machine and introduces the Alternate Port role: a pre-computed backup for the root port that can transition to forwarding in under a second when the primary path fails, which is what this simulator's link-failure toggle demonstrates.

Frequently asked questions

How is the root bridge chosen if two switches have the same priority?

The Bridge ID is actually priority (4 bits, in multiples of 4096) concatenated with the switch's MAC address (or system ID extension for per-VLAN Bridge IDs). If priorities tie, the switch with the numerically lowest MAC address wins the root election — MAC address only ever acts as a tie-breaker, never the primary criterion.

Why does STP block a port instead of physically disconnecting the redundant link?

Blocking only stops the port from forwarding data frames — it continues to listen for BPDUs. This lets STP instantly detect if the primary path fails (because expected BPDUs stop arriving on a segment) and transition the blocked port back to forwarding, providing automatic failover without any manual recabling.

What is BPDU Guard and why is it used on access ports?

BPDU Guard immediately disables (err-disable) an access port the instant it receives a BPDU, since end-user devices should never be running STP. It protects against a user accidentally daisy-chaining an unmanaged switch that could otherwise participate in — and potentially disrupt — the spanning tree topology.

Does STP work with VLANs?

Per-VLAN Spanning Tree (PVST+, a Cisco enhancement) runs a separate spanning tree instance per VLAN, allowing different VLANs to use different links as their forwarding path for load balancing. Multiple Spanning Tree Protocol (MSTP, 802.1s) achieves similar load-balancing benefits by mapping multiple VLANs to a smaller number of spanning tree instances, reducing the BPDU/CPU overhead of running one instance per VLAN.

🎓

Try our Enterprise IT Networks Studio

More calculators, simulators, and guides for this discipline.

Related tools & guides

MAC Address Table SimulatorNetwork Topology & Redundancy SimulatorSubnet & VLAN Segmentation VisualizerNetwork Redundancy & Uptime Calculator