STP Concepts and Election

Key Takeaways

  • Layer 2 Ethernet has no TTL; redundant switch links without STP create broadcast storms, MAC flapping, and network collapse.
  • STP elects one root bridge per spanning tree using the lowest Bridge ID (priority + MAC); default priority is 32768 and configurable steps are multiples of 4096.
  • Each non-root switch elects one root port (lowest path cost to the root); each segment elects one designated port; remaining ports become alternate/blocked to break loops.
  • Classic 802.1D port states include Blocking, Listening, Learning, and Forwarding; timer-based convergence can take tens of seconds after a topology change.
  • On Huawei VRP, control root placement with stp priority or stp root primary/secondary and verify with display stp brief and display stp.
Last updated: July 2026

STP Concepts and Election

Quick Answer: Spanning Tree Protocol (STP) prevents Layer 2 loops by electing one root bridge, choosing one best path toward that root on each switch, and blocking redundant links. Bridge ID = priority (default 32768, steps of 4096) + MAC address; lowest wins. Port roles are root, designated, and alternate (blocked). Classic states progress Blocking → Listening → Learning → Forwarding.

Campus switches almost always have redundant uplinks for high availability. Without a loop-prevention protocol, that redundancy becomes a liability: broadcast and unknown unicast frames circulate forever, MAC tables thrash, and the VLAN becomes unusable. STP (and its faster descendants RSTP/MSTP covered next) is the standard solution HCIA-Datacom expects you to understand at both conceptual and basic configuration depth.

Why Layer 2 loops are catastrophic

IP packets have a TTL field that decrements at each hop and is discarded at zero. Ethernet frames do not. If Switch A floods a broadcast to Switch B, and Switch B floods it back to Switch A over a second link in the same VLAN, the frame multiplies and never dies. Symptoms you must associate with a Layer 2 loop include:

  • Broadcast storm: utilization on links and CPUs climbs toward 100%; even unicast applications fail because the fabric is busy flooding.
  • MAC address flapping: the same source MAC is learned on alternating ports as the frame reappears, so the switch keeps rewriting its MAC table.
  • Intermittent reachability: some frames take path A, some take path B; sessions reset and ARP becomes unstable.

Redundant physical topology is good. Uncontrolled active redundancy at Layer 2 is not. STP’s job is to leave a logical tree: enough links remain forwarding so every switch is still reachable, but every loop is broken by blocking at least one port per loop.

STP goals and BPDUs

STP builds a loop-free topology by exchanging Bridge Protocol Data Units (BPDUs). Classic STP uses multicast destination 01-80-C2-00-00-00. Each BPDU carries the sender’s view of:

  • Root Bridge ID
  • Path cost to that root
  • Sender Bridge ID
  • Port ID (priority + port number)
  • Timers (Hello, Max Age, Forward Delay)

Switches compare these values using a strict hierarchy so every device converges on the same root and the same set of forwarding links.

Root bridge election

Every STP instance elects exactly one root bridge. The winner is the switch with the lowest Bridge ID (BID):

BID componentDefault / range (exam focus)Notes
Bridge priorityDefault 32768Configurable in multiples of 4096 (0, 4096, 8192, …, 61440)
System MACHardware base MACTie-breaker when priorities are equal

Exam trap: if two candidates have the same priority, the switch with the lower MAC address becomes root. Operators almost never leave root election to the lowest MAC by accident—designated core or aggregation switches should be forced to win with a lower priority (for example 0 or 4096).

On Huawei VRP you will see patterns such as:

[SW] stp enable
[SW] stp mode stp
[SW] stp priority 4096

or the convenient role shortcuts:

[Core] stp root primary
[Agg]  stp root secondary

stp root primary sets a low priority so the device is preferred as root; secondary sets a value suitable as backup root if the primary fails. Always verify with display stp brief or display stp after changes.

Path cost and root port election

Once the root is known, every non-root switch elects exactly one root port (RP)—the port with the lowest cumulative path cost to the root. Path cost is based on link bandwidth (higher speed = lower cost). If costs tie, STP compares:

  1. Lowest upstream (sender) Bridge ID
  2. Lowest port priority / Port ID on the neighbor
  3. Local port ID as final tie-breaker

The root port is always in a forwarding state once convergence completes (except during transitional states).

Typical path-cost intuition (exam level)

Exact default tables vary by standard revision and vendor defaults, but the relationship is what HCIA tests: 10 Gbit/s costs less than 1 Gbit/s, which costs less than 100 Mbit/s. Preferring a GE uplink over FE is automatic when costs are left at defaults. Engineers can override cost with interface-level configuration when design requires a non-default path, but understand that arbitrary cost changes affect the entire tree.

Designated ports and alternate (blocked) ports

For every network segment (link or shared LAN), STP elects one designated port (DP)—the port that advertises the best path to the root on that segment. On a point-to-point switch-to-switch link, one side becomes DP and the other becomes either RP (if that switch uses the link toward the root) or an alternate/blocked port.

Port roleWho has itForwarding user traffic?Purpose
Root portNon-root switches (one each)Yes (after convergence)Best path toward the root
Designated portOne per segmentYesForwards toward leaves / other switches
Alternate (non-designated)Losers on redundant segmentsNo (blocking)Backup path if RP or DP fails
DisabledAdmin down / STP disabled contextsNoOut of service

All switches on a shared segment compare BID and root path cost; the switch with the best claim places its DP in forwarding. Other ports facing that segment block, which is exactly how the loop is broken.

Classic 802.1D port states

HCIA still expects the classic state machine even though modern campus gear usually runs RSTP/MSTP:

StateLearns MACs?Forwards frames?Role in convergence
BlockingNoNoReceives BPDUs only; breaks loops
ListeningNoNoTransitional; prepares to participate after Max Age / topology change
LearningYesNoBuilds MAC table before forwarding to reduce flooding
ForwardingYesYesNormal data plane operation
DisabledNoNoPort administratively down or STP not running on it

Timers that drive classic convergence include Hello (default 2 s), Max Age (default 20 s), and Forward Delay (default 15 s). A topology change can force ports through Listening and Learning for roughly 2 × Forward Delay, so full reconvergence on the order of 30–50 seconds is normal for pure 802.1D. That delay is a major reason vendors adopted RSTP.

Worked election example

Imagine three switches in a triangle, all links GE, same default costs:

  • SW1 priority 4096, MAC ends in …0011
  • SW2 priority 32768, MAC ends in …00AA
  • SW3 priority 32768, MAC ends in …00BB

Root: SW1 wins immediately because 4096 is lower than 32768.

Root ports: SW2 and SW3 each choose their direct link toward SW1 as RP (one hop, lowest cost).

Designated ports: On the SW1–SW2 and SW1–SW3 links, SW1’s ports are designated. On the SW2–SW3 link, both switches compare path cost to root (equal: both already have cost of the direct GE to SW1). They then compare Bridge IDs; SW2’s MAC …00AA is lower than SW3’s …00BB, so SW2’s port on the SW2–SW3 link becomes designated and SW3’s port blocks. The logical topology is a tree rooted at SW1 with the SW2–SW3 link as a standby path.

If the SW1–SW2 link fails, SW2 loses its root port, ages out old information, and (after classic timers or faster RSTP signaling) unblocks toward SW3, using SW3 as the new path to the root. Understanding this sequence—root first, then RPs, then DPs, then blockers—is the core exam skill.

Huawei verification and design notes

Useful VRP checks:

[SW] display stp brief
[SW] display stp
[SW] display stp interface GigabitEthernet0/0/1

Confirm which device is root, which local ports are ROOT / DESI / ALTE, and whether the priority you configured took effect. Design guidelines for HCIA-level campus networks:

  • Place the root on the core or distribution layer, never on a random access switch that happens to have a low MAC.
  • Configure a secondary root so failover is predictable.
  • Keep access-layer downlinks from becoming transit paths for other switches unless the design intentionally uses them.
  • Remember that STP operates per VLAN or per instance depending on mode (PVST-style thinking vs MSTP instances—covered in the next section). Classic single STP still builds one tree for the whole bridge, which can leave some VLANs on suboptimal links; that limitation motivates MSTP.

Exam checklist

  • State why Ethernet loops cause storms (no TTL) and name the three classic symptoms.
  • Compute root from priority and MAC; know the 4096 priority step and default 32768.
  • Map roles: root port, designated port, alternate/blocked.
  • Order classic states and explain why Learning exists before Forwarding.
  • On Huawei, associate stp enable, stp priority, stp root primary/secondary, and display stp with root control and verification.

Master election mechanics here; RSTP and MSTP reuse the same Bridge ID and cost comparisons while improving speed and VLAN load sharing.

Test Your Knowledge

Two Huawei switches have identical STP priority values. Which attribute elects the root bridge?

A
B
C
D
Test Your Knowledge

What is the primary purpose of the Learning state in classic 802.1D STP?

A
B
C
D
Test Your Knowledge

On Huawei VRP, bridge priority values for STP must be configured in which step size?

A
B
C
D
Test Your Knowledge

After root election, how does a non-root switch choose its root port?

A
B
C
D