You built VLANs. You added redundant switch links so a single cable failure doesn't bring down the network. The moment you did that, you introduced loops — and Ethernet loops will take down an entire network in milliseconds.

Spanning Tree Protocol is the mechanism that prevents it. STP runs automatically, elects one switch as Root Bridge, assigns a role to every port, and shuts off the ports that would create loops. No configuration required on a default network — but you need to understand the election algorithm, because you'll be asked to predict it on the CCNA exam and you'll need to influence it in production.

★ WHAT HAPPENS WITHOUT STP

Switch A receives a broadcast frame. It floods it out every port. Switch B receives it, floods it out every port — including back toward Switch A. Switch A receives it again. Floods it again. This loop runs at line rate.

Within milliseconds: bandwidth is consumed by the storm. MAC address tables flip continuously as the switch sees the same source MAC arriving on multiple ports simultaneously. End devices receive the same frame dozens of times. The network stops passing user traffic. The only fix is to physically disconnect a cable.

[ ⚠ BROADCAST STORM ] A single unblocked loop can saturate a 1 Gbps link in under a second. Redundant links are essential for resilience — STP is what makes them safe to have.

★ THE 4-STEP STP ELECTION

Every time switches boot or a topology changes, STP runs this algorithm. It always produces the same result given the same inputs — deterministic and predictable. You need to be able to trace it manually on any topology.

1 ELECT THE ROOT BRIDGE

Every switch has a Bridge ID — an 8-byte value made of its priority (2 bytes) and MAC address (6 bytes). The switch with the lowest Bridge ID wins and becomes Root Bridge.

Default priority is 32768 on all switches. When priorities tie — which they do on a default network — the switch with the lowest MAC address wins. All ports on the Root Bridge become Designated Ports and forward traffic.

2 ELECT ROOT PORTS

Every non-root switch selects exactly one Root Port (RP) — the port with the lowest cumulative path cost back to the Root Bridge. Path cost is additive: each link adds its cost based on speed.

Tie-breaker 1: lower sender Bridge ID. Tie-breaker 2: lower port ID. Trace every available path and sum every hop.

3 ELECT DESIGNATED PORTS

On each network segment, one port must be the Designated Port (DP). The switch with the lower root path cost on that segment wins. If both sides have equal cost, the lower Bridge ID wins.

Designated Ports forward traffic. The Root Bridge wins the DP election on every directly connected segment since its path cost to itself is zero.

4 BLOCK EVERYTHING ELSE

Any port that is neither a Root Port nor a Designated Port enters Blocking state. It still receives BPDUs so STP can react to topology changes, but it does not forward user traffic. The loop is broken.

[ THE ONE-LINE VERSION ] One Root Bridge. One Root Port per non-root switch. One Designated Port per segment. Everything else blocks.

★ 802.1D DEFAULT PORT COSTS

Path cost is determined by the physical link speed. These are the 802.1D values the CCNA exam tests. Memorise them — you will be tracing paths and adding costs under time pressure.

LINK SPEED 802.1D COST WHERE YOU'LL SEE IT
10 Mbps100Legacy — rarely seen now
100 Mbps (FastEthernet)19Most CCNA lab topologies
1 Gbps (GigabitEthernet)4Trunk uplinks, modern access
10 Gbps2Core and distribution links
[ ⚠ COST IS CUMULATIVE ] A path through two 100 Mbps links has a total cost of 38 (19 + 19). A path through one 1 Gbps link has a cost of 4. Always trace the full path and sum every hop — the numbers that look obvious are the ones that trip people up under exam pressure.

★ PORT ROLES

RP

Root Port — best path to the root. One per non-root switch. Forwards traffic.

DP

Designated Port — best port on each segment. Forwards traffic. All root bridge ports are DPs.

BLK

Blocking — neither RP nor DP. Receives BPDUs only. Does not forward frames.

★ PORT STATES (802.1D)

When STP decides a port should forward, it doesn't happen immediately. The port transitions through states — this is why pings take a while to work after a switch boots or a link comes up.

[ PORT STATE TRANSITIONS ] BlockingListeningLearningForwarding

Blocking: receives BPDUs, does not forward frames
Listening: sends/receives BPDUs, no MAC learning, no forwarding
Learning: builds MAC table, no forwarding yet
Forwarding: fully operational

After a link failure, convergence takes ~50 seconds total:
Max Age (20s) — switch stops receiving BPDUs from the root and waits 20 seconds before declaring it gone and triggering a new election
Listening (15s) — Forward Delay: new topology elected, ports transition
Learning (15s) — Forward Delay: MAC table rebuilt before forwarding begins

RSTP (802.1w) eliminates Max Age and collapses the delay states, converging in under 1 second — covered in a later lab.

★ INFLUENCING STP

On a default network, the switch with the lowest MAC address wins. In production that's effectively random. You want to control which switch is Root Bridge — typically your most capable distribution switch.

SET PRIORITY MANUALLY

! Priority must be a multiple of 4096 (0, 4096, 8192 ... 61440) SW1(config)# spanning-tree vlan 1 priority 4096 ! Cisco macro — sets priority to 24576 automatically SW1(config)# spanning-tree vlan 1 root primary ! Backup root — sets priority to 28672 SW1(config)# spanning-tree vlan 1 root secondary

ADJUST PORT COST

SW2(config)# interface fastethernet 0/1 SW2(config-if)# spanning-tree cost 10 SW2# show spanning-tree
[ ⚠ PVST+ ] Cisco runs Per-VLAN Spanning Tree Plus (PVST+) by default — one STP instance per VLAN. Each VLAN can have a different Root Bridge. You can load-balance by making SW1 root for VLAN 10 and SW2 root for VLAN 20. The commands above target a specific VLAN: spanning-tree vlan 10 priority 4096

★ INTERACTIVE LAB

Reading about STP is one thing. Being able to look at a topology, trace the paths, and correctly predict every port role is what the exam actually tests. The interactive lab puts four different topologies in front of you — quiz mode to test yourself, step-by-step walkthrough, a sandbox where you can change priorities and costs and watch STP recalculate in real time, and a reference tab for quick lookups.

No Packet Tracer required. Runs entirely in your browser.

► INTERACTIVE LAB — STP ROOT BRIDGE ELECTION Quiz · Walkthrough · Sandbox · Reference
4 topologies: Triangle, Line, Mesh (4 switches), Trunk Uplinks
INTERMEDIATE FREE BROWSER
► LAUNCH INTERACTIVE LAB
[ ★ STUDY RESOURCES ]