Network Bytes · Episode 33 · CCNA 2.5
Root bridge election
Spanning Tree needs one switch at the center, the root bridge. Switches compare bridge IDs (a priority plus a MAC address), the lowest one wins, and engineers set the priority so the right switch wins on purpose.
Why Spanning Tree needs a leader
Spanning Tree Protocol (STP) breaks loops by building a single loop-free tree across the switches. A tree needs a starting point, and that's the root bridge. Every other switch works out its best path toward the root, and the links that aren't on those best paths get blocked.
The bridge ID: priority + MAC
Each switch has a bridge ID made of two parts:
- a priority,
32768by default, which you can change in steps of4096(0,4096,8192...61440); - the switch's MAC address, which is unique and fixed.
On Cisco switches running PVST+ or Rapid PVST+, the VLAN number is added to the priority (the system ID extension), so in VLAN 1 a default switch shows priority 32769. There is a separate root bridge election for every VLAN.
The election
Switches send each other hello messages called BPDUs (Bridge Protocol Data Units), every 2 seconds by default. Each BPDU carries the bridge ID of the switch the sender believes is the root. When a switch hears about a lower bridge ID than its own, it stops claiming to be root and passes the better one on. Soon every switch agrees: the lowest bridge ID wins.
The priority is compared first. Only if the priorities are equal does the MAC address break the tie, and the lowest MAC wins. Because manufacturers hand out MAC addresses in rough order, the lowest MAC often belongs to the oldest switch, which may be a small, slow box in a closet.
Winning on purpose
Leaving the election to chance is risky: all traffic between parts of the network tends to flow through the root. So engineers lower the priority on a strong, central core switch, for example to 24576, so it wins regardless of MAC addresses. On Cisco switches, spanning-tree vlan 1 root primary does this for you, and root secondary picks a backup. Once the root is set, each switch chooses its port with the lowest path cost to the root, and the extra links are blocked.
Try it yourself
In the free Cisco Packet Tracer, connect three switches in a triangle and run show spanning-tree on each. Look for the line "This bridge is the root" and note which switch got it, then compare the three MAC addresses. Now pick a different switch and type spanning-tree vlan 1 priority 24576 in global configuration mode. Run show spanning-tree again: the root has moved to the switch you chose, and the blocked port may have moved too.
Good to know
- The bridge ID is the priority (default 32768, settable in steps of 4096) plus the MAC address.
- Cisco's PVST+ and Rapid PVST+ add the VLAN number to the priority (the system ID extension), so VLAN 1 shows 32769, and there is one election per VLAN.
- The "hello messages" are BPDUs, sent every 2 seconds by default.
- "Often the oldest switch" is a rule of thumb: lower MACs tend to belong to older hardware, but not always.
- After the root is chosen, ports are picked by the lowest root path cost; that's a topic for a later episode.
For CCNA learners
This covers CCNA 200-301 exam topic 2.5.a (root port, root bridge primary/secondary, and other port names): know that the lowest bridge ID wins, that priority is compared before MAC, and how to make a switch the root on purpose.
Answer to the comment question
4096. The lowest bridge ID wins, and the priority is compared first, so the switch with priority 4096 beats the one with 8192. The MAC addresses only matter when the priorities tie.
Test your knowledge
Quick quiz: Root bridge election
4 multiple-choice questions. Pick one answer for each, then check how you did.
Sources
- Cisco, "Configuring Spanning Tree Protocol" (Catalyst 9200, IOS XE 17.17): the root is the switch with the lowest bridge ID; bridge ID = priority + system ID extension + MAC; default priority 32768;
spanning-tree vlan root primary - Cisco, "Configuring STP" (Catalyst 2960, 15.2(1)E): BPDUs carry bridge IDs; the lowest MAC breaks a priority tie; priority set in steps of 4096; hello time 2 seconds
- IEEE SA, "IEEE 802.1Q Bridges and Bridged Networks": the current home of the spanning tree protocols
- Cisco, CCNA 200-301 v1.1 exam topics: 2.5.a root port, root bridge (primary/secondary) and other port names
Video transcript
How do switches pick a leader?
Spanning Tree needs one switch at the center, called the root bridge. Every other switch works out its best path toward it.
Each switch has a bridge ID: a priority number, then its MAC address. Out of the box, the priority is 32768.
The switches swap hello messages and compare. The lowest bridge ID wins. If the priorities tie, the lowest MAC address breaks the tie. Often, that's just the oldest switch.
That's risky, so engineers lower the priority on a strong core switch to make it win on purpose. Then extra links get blocked, based on paths to the root.
One switch has priority 8192, another has 4096. Which priority wins? Comment your answer below!
That's your byte.
More from Network Bytes
- EP31Trunk ports and 802.1Q tags
- EP32"Spanning Tree: why loops kill networks"
- EP34EtherChannel
- EP35CDP and LLDP