Spanning Tree Protocol (STP) Explained: Root Bridge, Port Roles and Timers
An exam-focused deep dive into 802.1D Spanning Tree: why Layer 2 loops are catastrophic, how the root bridge is elected, what root, designated and blocking ports actually do, the port states and timers behind that 30–50 second wait, why PortFast exists, and how RSTP fixed it all. Includes five exam-style practice questions with answers.
Why loops happen (and why they're catastrophic)
Redundancy is a good thing at Layer 3: routers run OSPF, each packet has a TTL, and multiple paths just work. At Layer 2 there is no TTL. Switches forward frames based on MAC addresses and flood unknown unicast, multicast and broadcast frames out of every port except the one they arrived on. Connect two switches with two links — or three switches in a triangle — and you have a physical loop. Three things then go wrong, and the exam will test all three:
- Broadcast storms. A broadcast frame enters the loop and is copied forever. Each copy spawns more copies, and the links saturate within seconds. Because broadcasts are flooded, the storm amplifies itself until the network collapses.
- MAC table instability (flapping). The same source MAC arrives on different ports in quick succession as copies of one frame circulate. The switch keeps rewriting its MAC address table, so frames get sent down the wrong port and hosts become unreachable.
- Duplicate frame delivery. Multiple copies of the same frame arrive at the destination. Most protocols tolerate this, but it wastes bandwidth and can break applications that assume one frame, one delivery.
STP's job is simple to state: block redundant ports so there is exactly one active Layer 2 path between any two points, while keeping the blocked ports on standby so the network heals if a link fails. If you want the compact version of this topic first, our CCNA spanning tree study notes cover the essentials in a few minutes; this guide goes deeper for the exam questions that punish shallow knowledge. And if the underlying switching mechanics feel shaky, review CCNA switching fundamentals first.
Root bridge election, step by step
Every STP decision is made relative to one switch: the root bridge. All paths, port roles and costs are calculated as "how do I get to the root?" So the first thing STP does is elect one.
Each switch has a Bridge ID (BID) made of two parts:
- Bridge priority — a 2-byte value, default 32768, configurable in multiples of 4096 (0, 4096, 8192, … 61440).
- MAC address — the switch's lowest MAC address (on Cisco, the base MAC of the switch).
On Cisco switches running PVST+, the bridge ID also folds in the VLAN number (the extended system ID), so the election effectively runs once per VLAN. Election works like this:
- On boot, every switch assumes it is the root and sends BPDUs (Bridge Protocol Data Units) advertising its own BID as the root BID.
- When a switch receives a BPDU advertising a lower root BID than the best it has seen, it adopts that BID as the new root and relays it onward.
- BPDUs advertising a higher root BID are ignored.
- Within seconds, every switch agrees on the same lowest BID. That switch is the root bridge.
The comparison is strict and ordered: lowest priority wins first; if priorities tie, lowest MAC address wins. Default priorities are all 32768, so on an untouched network the switch with the lowest MAC becomes root — which is why best practice is to set the priority manually. On a Cisco switch:
Making a core switch the root bridge
spanning-tree vlan 1 priority 4096 — sets this switch's priority to 4096, the lowest practical value, guaranteeing it wins the election. A backup root is typically set to 8192 with spanning-tree vlan 1 priority 8192. Because PVST+ elects per VLAN, repeat per VLAN (or use spanning-tree vlan 1,10,20 priority 4096). On networks running RSTP, the same command applies under Rapid PVST+.
Exam trap: students memorise "lowest MAC wins" and forget the priority comes first. Priority is always compared before MAC. A switch with priority 4096 beats a switch with priority 32768 regardless of MAC addresses.
STP port roles
Once the root bridge is elected, every port on every switch gets a role. There are three, and the exam loves asking you to assign them on a topology diagram:
- Root port — on each non-root switch, the single port with the lowest-cost path back to the root bridge. It always forwards. (The root bridge has no root port.)
- Designated port — on each network segment (each link), the port with the lowest-cost path to the root bridge. It always forwards. All ports on the root bridge are designated ports.
- Non-designated (blocking) port — every port that is neither a root port nor a designated port. It stays in the blocking state and forwards nothing, which is what breaks the loop.
"Lowest-cost path" uses STP path costs based on link speed. Memorise this table — it is one of the most-tested STP facts on the CCNA:
| Link speed | STP cost (802.1D-2004) |
|---|---|
| 10 Mbps | 100 |
| 100 Mbps | 19 |
| 1 Gbps | 4 |
| 10 Gbps | 2 |
When costs tie, STP breaks the tie in this exact order: lowest path cost to root → lowest sender bridge ID → lowest sender port ID. For the final hop decision on a segment, the port with the lower local port ID wins if everything else is equal.
Worked example: three switches in a triangle
Topology: SW1, SW2 and SW3, all links 1 Gbps. SW1 priority 24576, SW2 and SW3 default 32768. Assign the port roles.
Root bridge: SW1 — priority 24576 beats 32768, so MAC addresses are never compared.
Root ports: On SW2, the port facing SW1 has path cost 4 (one 1 Gbps hop) — lower than going via SW3 (cost 4 + 4 = 8). That port is SW2's root port. Same logic on SW3: its port facing SW1 (cost 4) is its root port.
Designated vs blocking on the SW2–SW3 link: both switches already reach the root at cost 4 through their own root ports, so costs tie. Tie-break: lowest sender bridge ID — SW2's BID is lower than SW3's (both priority 32768, so MAC decides). SW2's port on this link becomes the designated port (forwarding); SW3's port becomes non-designated (blocking).
Result: the loop is broken at SW3's blocked port, but if the SW1–SW3 link fails, that blocked port transitions to forwarding and connectivity is restored — after the STP timers below have run.
Port states and timers
A port doesn't jump straight from blocking to forwarding. It walks through states, spending the forward delay timer in each transitional state so the whole network has time to agree on the new topology before traffic flows:
- Blocking — receives BPDUs, forwards nothing. This is the steady state of a redundant port.
- Listening — sends and receives BPDUs, still forwards nothing. Lasts one forward delay (15 s).
- Learning — still not forwarding user traffic, but now populating the MAC table so it doesn't flood when it starts forwarding. Lasts one forward delay (15 s).
- Forwarding — normal operation: sends, receives, learns and forwards.
- Disabled — administratively shut down; takes no part in STP.
The three timers to memorise:
| Timer | Default | Meaning |
|---|---|---|
Hello time | 2 seconds | How often the root bridge sends BPDUs out of its ports. |
Forward delay | 15 seconds | Time spent in each of the Listening and Learning states. |
Max age | 20 seconds | How long a switch waits without hearing BPDUs before declaring the neighbour dead and recalculating. |
That gives the famous convergence figure: 30–50 seconds for classic 802.1D STP (15 + 15 through the transitional states, plus up to 20 seconds of max age in the worst case). On the exam, "30 to 50 seconds" is the number they want when they ask about 802.1D convergence.
PortFast: skipping the wait (carefully)
Waiting 30–50 seconds every time a PC boots or a printer wakes up is painful — DHCP times out, users complain. PortFast lets you mark an access port connected to a single end device so it transitions straight to forwarding, skipping Listening and Learning entirely.
The rule the exam tests relentlessly: PortFast goes on edge ports only — never on ports connected to another switch or hub. An end device can't create a loop, but a switch can, and with PortFast active the port starts forwarding before BPDUs have a chance to detect the loop. That is how broadcast storms are born in real networks.
The safety net is BPDU Guard: if a PortFast port ever receives a BPDU (proof that a switch, not a PC, is on the other end), the port is immediately error-disabled. On Cisco, the exam-standard pairing is:
PortFast + BPDU Guard on an access port
spanning-tree portfast on the interface (or spanning-tree portfast default globally for all access ports), plus spanning-tree bpduguard enable. Verify with show spanning-tree interface Gi0/1 detail. A port in err-disabled state after someone plugged in a rogue switch is BPDU Guard doing exactly its job.
RSTP: how 802.1w fixed the wait
Rapid Spanning Tree Protocol (802.1w) keeps the same loop-free goal but converges in about a second instead of 30–50. The improvements to know:
- Three port states instead of five. Blocking and Listening merge into Discarding; the states are Discarding, Learning, Forwarding.
- Two new port roles. Alternate port — a backup root port, already in discarding state, ready to take over instantly. Backup port — a backup designated port on a segment where the switch already has a designated port (e.g. a hub with two links to the same switch).
- Proposal/agreement handshake. Instead of passively waiting out timers, switches actively negotiate: a switch proposes a new topology on a port and the neighbour agrees once its side is synced. Convergence propagates link by link in roughly a second.
- Edge ports. RSTP's built-in equivalent of PortFast — an edge port goes straight to forwarding.
Cisco's default is Rapid PVST+ — per-VLAN rapid spanning tree — enabled with spanning-tree mode rapid-pvst. For the exam: 802.1D = 30–50 s convergence; 802.1w = ~1 s; PortFast pairs with BPDU Guard; root election is priority-then-MAC.
STP interacts with the rest of the LAN too: trunks carry it per VLAN, which is why VLANs and trunking matter here, and misconfigured STP is a favourite troubleshooting scenario in the CCNA 200-301 practice questions bank.
Quick-fire practice questions
Five exam-style questions. Cover the answer, commit to one from memory, then click to reveal.
Q1. SW-A has priority 32768 and MAC 0001.96ab.3c40. SW-B has priority 8192 and MAC 000f.22de.9910. Which becomes the root bridge, and why?
SW-B. Priority is compared before MAC: 8192 < 32768, so SW-B wins and the MAC addresses are never compared. This is the most common root-election trap on the exam — "lowest MAC wins" is only the tie-breaker when priorities are equal.
Q2. A non-root switch has two uplinks to the root: a 1 Gbps link (cost 4) and a 100 Mbps link (cost 19). Which port becomes the root port?
The 1 Gbps port. The root port is the port with the lowest-cost path to the root bridge — cost 4 beats cost 19. If both links were the same speed, the tie-break would fall to the lowest sender bridge ID, then the lowest sender port ID.
Q3. A port on a classic 802.1D switch moves from blocking toward forwarding after a topology change. How long before it forwards user traffic, and why?
30 seconds (15 s Listening + 15 s Learning). The forward delay timer (default 15 s) is spent in each transitional state so BPDUs can propagate and the whole switched network agrees on the loop-free topology before the port forwards. Worst-case convergence including max age is 50 seconds.
Q4. A junior engineer enables PortFast on every switchport, including uplinks to other switches. What is the risk, and what should have been configured instead?
Risk: temporary (or permanent) Layer 2 loops and broadcast storms, because PortFast ports forward before BPDUs converge. Fix: PortFast on access/edge ports only, always paired with BPDU Guard (spanning-tree bpduguard enable) so any port that receives a BPDU is error-disabled immediately.
Q5. Which two RSTP features explain its ~1 second convergence compared with 802.1D's 30–50 seconds?
The proposal/agreement handshake and pre-computed alternate/backup port roles. Instead of waiting out forward-delay timers, switches actively negotiate topology changes link by link, and alternate ports (backup root ports) are already selected and waiting in discarding state, so failover is near-instant. RSTP also collapses the port states to Discarding, Learning and Forwarding.
STP for the CCNA 200-301 exam
STP sits in the LAN switching portion of the blueprint, and the questions reward precise memorisation over vague understanding. Lock in these facts: default priority 32768; election order priority → MAC; costs 10M=100, 100M=19, 1G=4, 10G=2; timers hello 2 s, forward delay 15 s, max age 20 s; 802.1D convergence 30–50 s; RSTP ~1 s; PortFast edge ports only + BPDU Guard. Then drill them: the flashcards have an STP deck, and the practice question bank covers root election and port-role scenarios in exam format.
Keep studying: STP study notes Switching fundamentals VLANs and trunking Flashcards Practice questions
Ready to test yourself?
STP is one piece of the CCNA 200-301. Take the free 25-question mock test — no sign-up — and find out where you stand. One subscription (£5/month or £39/year) unlocks all 370 exam-style questions, 20 in-browser labs and 300 flashcards across all 10 certifications.
Start the free mock test →