Ethernet Technology Basics · Topic 3 of 5
STP Concepts and Working Principles
Learn why Layer 2 loops need STP, bridge IDs, path costs, root bridge election, port roles and states, BPDUs and timers for HCIA-Datacom H12-811.
- 5 min
- Includes a diagram
- BID is priority plus MAC. Lowest BID wins the root election.
- Default bridge priority 32768 (steps of 4096); default port priority 128 (steps of 16).
- Root port tie-breakers: root path cost, sender BID, sender PID, local PID.
What it is
Redundant links between switches keep the network up when one link fails, but they create Layer 2 loops. Ethernet frames have no TTL, so a looped broadcast circulates forever, causing a broadcast storm, unstable MAC address tables (MAC flapping) and duplicate frames.
The Spanning Tree Protocol (STP), IEEE 802.1D, solves this by logically blocking some ports so the network becomes a loop-free tree. If an active link fails, a blocked port can start forwarding again.
How it works
Basic concepts
| Term | Meaning |
|---|---|
| Bridge ID (BID) | 2-byte priority plus 6-byte MAC address, 8 bytes in total |
| Bridge priority | Default 32768, set in steps of 4096 (0 to 61440) |
| Root bridge | The switch with the smallest BID |
| Path cost | Cost of a port, based on link speed |
| Root path cost (RPC) | Sum of port costs from a switch to the root |
| Port ID (PID) | 1-byte priority plus port number; port priority default 128, steps of 16 |
| Root port (RP) | The port on a nonroot switch with the best path to the root |
| Designated port (DP) | The port on each segment that forwards toward that segment |
Path cost standards
Huawei switches support three standards, set with stp pathcost-standard { dot1d-1998 | dot1t | legacy }. The default is dot1t (IEEE 802.1t).
| Link speed | IEEE 802.1t | IEEE 802.1D-1998 |
|---|---|---|
| 10 Mbit/s | 2,000,000 | 100 |
| 100 Mbit/s | 200,000 | 19 |
| 1 Gbit/s | 20,000 | 4 |
| 10 Gbit/s | 2,000 | 2 |
A faster link has a lower cost. Use the same standard on all switches in the network.
The election in four steps

- Root bridge. The switch with the smallest BID wins: lowest priority first, then lowest MAC address.
- Root port. Each nonroot switch picks one root port by comparing, in order: lowest root path cost, lowest sender BID, lowest sender PID, then lowest local PID.
- Designated port. Each segment gets one designated port, on the switch with the lowest root path cost to the root, then the lowest BID, then the lowest PID. All ports on the root bridge are designated ports.
- Blocking. Any port that is neither root nor designated is blocked (an alternate port).
BPDUs
Switches exchange configuration BPDUs carrying the root ID, root path cost, sender BID, sender PID and the timers. The root sends them every Hello Time, and other switches relay them out designated ports. A TCN BPDU is sent out the root port toward the root to report a topology change.
When the root learns of a change, it sets the TC flag in its configuration BPDUs. Switches then shorten their MAC aging time to the Forward Delay so stale entries clear quickly.
Port states and timers
| State | Receives BPDUs | Sends BPDUs | Learns MACs | Forwards data |
|---|---|---|---|---|
| Disabled | No | No | No | No |
| Blocking | Yes | No | No | No |
| Listening | Yes | Yes | No | No |
| Learning | Yes | Yes | Yes | No |
| Forwarding | Yes | Yes | Yes | Yes |
| Timer | Default | Purpose |
|---|---|---|
| Hello Time | 2 s | Interval between configuration BPDUs |
| Forward Delay | 15 s | Time spent in Listening and again in Learning |
| Max Age | 20 s | How long stored BPDU information stays valid |
A port moving from Blocking to Forwarding spends 15 s listening and 15 s learning, so STP takes about 30 s. If the change is detected through Max Age, convergence takes up to about 50 s.
A worked example
SW1, SW2 and SW3 form a triangle with 1 Gbit/s links, all priority 32768. SW1 has the lowest MAC and becomes the root, so all its ports are designated ports.
SW2 and SW3 each pick the port facing SW1 as root port, with root path cost 20,000. On the SW2 to SW3 link both sides have the same cost, so the switch with the lower BID, say SW2, gets the designated port. SW3's port on that link becomes the alternate port and is blocked.
How the exam asks about this
- "Which switch becomes the root bridge?" → The one with the lowest bridge priority, and if priorities tie, the lowest MAC address.
- "What is the default STP bridge priority on a Huawei switch?" → 32768.
- "In which STP state does a port learn MAC addresses but not forward data?" → Learning.
What to remember for the exam
- BID is priority plus MAC. Lowest BID wins the root election.
- Default bridge priority 32768 (steps of 4096); default port priority 128 (steps of 16).
- Root port tie-breakers: root path cost, sender BID, sender PID, local PID.
- STP states: Disabled, Blocking, Listening, Learning, Forwarding.
- Timers: Hello 2 s, Forward Delay 15 s, Max Age 20 s; Huawei default cost standard is dot1t.
A port's root path cost is the cost carried in the received BPDU plus the cost of that receiving port. When choosing a root port, a lower cost always beats a lower BID.
Common mistakes
Comparing BIDs before cost. When choosing a root port, root path cost comes first. The sender BID is only a tie-breaker.
Forgetting there is one root port per switch. A nonroot switch has exactly one root port. The root bridge has none.
Mixing up cost standards. A 1 Gbit/s port costs 20,000 under dot1t but 4 under 802.1D-1998. Read which standard the question uses.
Check yourself
Why does a Layer 2 loop cause a broadcast storm?
Ethernet frames have no TTL, so a flooded broadcast keeps circulating and multiplying around the loop.
Which ports on the root bridge are designated ports?
All of its active ports, since its root path cost is 0.
How long does a port take to go from Blocking to Forwarding with default timers?
About 30 seconds: 15 seconds in Listening and 15 seconds in Learning.
Topic 3 of 5 in Ethernet Technology Basics
Test yourself on Ethernet Technology Basics
The full Huawei HCIA-Datacom H12-811 question bank has 600 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Huawei. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.