The switches need one consistent plan
Our triangle has SW1, SW2 and SW3. PC A on SW2 and PC B on SW3 use VLAN 10, with addresses 192.168.10.10/24 and 192.168.10.20/24. All three inter-switch links carry VLAN 10. If every port forwarded its broadcasts around the circle, copied frames could return and be flooded again.
Spanning Tree Protocol (STP) prevents that loop by selecting port roles and forwarding states. The root bridge is its elected reference switch. A root port is a non-root switch's selected path towards that reference. A designated port is the selected port for a segment leading towards the root. The remaining redundant path can stay non-forwarding.
Switches talk using BPDUs
Switches running STP send each other small messages called BPDUs (Bridge Protocol Data Units). These are Layer 2 control messages, not IP routing packets or user data. Their information includes the claimed root ID, the sender's bridge ID and its cost towards the root. A BPDU says something like this:
"I am [my bridge ID]. I believe the root is [root bridge ID], and I'm [cost] away from it."
Each switch compares the BPDUs it sends and receives. In this way, all the switches agree on one tree. No central controller is needed.
The default Hello time is commonly 2 seconds. In classic STP, the root originates periodic configuration information and downstream switches relay updated information on designated ports. In Rapid Spanning Tree Protocol (RSTP), each bridge generates periodic BPDUs using its current information. BPDUs are processed by the protocol rather than flooded like an ordinary ARP broadcast.
The bridge ID: each switch's ranking
Every switch has a bridge ID, a number that ranks it. For root election, the lowest bridge ID wins.
The bridge ID (BID) combines a priority field with a switch MAC address. On Cisco PVST+ and Rapid PVST+, the extended system ID identifies the VLAN. The table describes that per-VLAN form; MST uses instance-related identification instead, so do not assume every STP mode adds the VLAN number in the same way.
| Part | Size | Set by | Example |
|---|---|---|---|
| Bridge priority | 4 bits | You (multiples of 4096, default 32768) | 32768 |
| Extended system ID | 12 bits | Automatically: the VLAN number | 10 |
| MAC address | 48 bits | The switch's base MAC | 0200.0000.0002 |
The first two parts are added together and shown as one "priority". For VLAN 10 that is 32768 + 10 = 32778. Switches compare the priority first. The MAC address is only used when the priorities are the same. So if nobody changes the settings in this same VLAN, the switch with the lowest bridge MAC address becomes root. A MAC address is not a reliable guide to a switch's age or suitability. Set the priority deliberately when a particular switch should be the root.
Our SW1 has configured priority 24576, lower than SW2 and SW3 at 32768. For VLAN 10, those displayed priority values are 24586 and 32778. SW1 therefore wins regardless of its MAC address. For the tie on the SW2–SW3 segment, assume SW2 has the lower bridge MAC than SW3.
The four decisions
Device key: SW1, SW2, SW3 (switch) · PC A, PC B (computer)
Lines show the example’s network connections. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type. Blocked: forwarding prevented by a port or policy. Down: failed link. Read the step for the cause.
- 1. Start: everyone claims root. When the switches start up, each one sends BPDUs saying it is the root.
- 2. Choose the root bridge. SW1's configured priority 24576 beats 32768. SW2 and SW3 advertise information identifying SW1 as root; VLAN 10 adds 10 to the displayed priority.
- 3. Each other switch picks a root port. This is the port with the lowest total cost to the root. For SW2 and SW3, it is the direct link to SW1 (cost 4). Going through the other switch costs 8.
- 4. Each segment selects a designated port. The port advertising the best root information is designated. SW1's ports on these two links are designated because SW1 has root cost zero.
- 5. Block what's left. On the SW2–SW3 link, both ends are cost 4 from the root. It's a tie, so the lower bridge ID wins. SW2 becomes designated and SW3's port is blocked.
Why SW2 wins the remaining segment
Root path cost adds the costs of the links towards the root. With cost 4 per gigabit link in this example, SW2 and SW3 each reach SW1 directly at cost 4; going through the other switch costs 8. Both therefore choose their direct uplink as root port.
On the SW2–SW3 segment they advertise the same root and the same root cost. The next comparison is their sender bridge ID. SW2's is lower by our stated MAC assumption, so SW2's end is designated. SW3's end stays non-forwarding. If the sender bridge ID also tied, sender port ID and, where needed for root-port selection, local receiving port ID complete the comparison.
| Decision | How many | Chosen by |
|---|---|---|
| Root bridge | One per network (per VLAN in PVST+) | Lowest bridge ID |
| Root port | One per connected non-root switch per instance | Best path information towards the root, starting with path cost |
| Designated port | One per segment per instance | Best advertised root information on that segment |
| Non-forwarding redundant port | As required by the topology | Non-designated in classic STP; alternate or backup roles in RSTP |
The Common Spanning Tree lessons explain each decision in detail, including path cost and what happens when there is a tie.
Read the result on a switch
Classic STP uses blocking, listening, learning and forwarding stages for an enabled participating port. RSTP uses discarding, learning and forwarding and supports faster transitions under suitable conditions. Cisco PVST+ and Rapid PVST+ run their respective behaviour per VLAN. Check the actual mode and path-cost method; defaults differ by platform and release.
SW3#show spanning-tree vlan 10 VLAN0010 Spanning tree enabled protocol rstp Root ID Priority 24586 Address 0200.0000.0001 Cost 4 Port 1 (GigabitEthernet1/0/1) Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address 0200.0000.0003 Interface Role Sts Cost Prio.Nbr Type Gi1/0/1 Root FWD 4 128.1 P2p Gi1/0/2 Altn BLK 4 128.2 P2p
Short lab: choose a root and verify the whole triangle
Use an isolated Cisco IOS/IOS XE lab with VLAN 10 present across the three inter-switch links. Leave spanning-tree protection enabled. Record the current mode and root before making a change. The diagram assumes gigabit links using short cost 4, no cost overrides, and SW2's bridge ID lower than SW3's.
show spanning-tree summary
show spanning-tree vlan 10
configure terminal
spanning-tree vlan 10 priority 24576
end
show spanning-tree vlan 10SW1 only. Start in privileged EXEC. Record its original configured priority first, then set 24576. SW2 and SW3 remain at configured priority 32768. Confirm SW1 identifies itself as root after convergence.
On SW2 and SW3, compare Root ID with SW1's Bridge ID. Find each root port, then inspect both ends of the SW2–SW3 link. The lower sender BID should win its designated role. If SW3's real MAC is lower, the non-forwarding side can be opposite to our illustration without being a fault.
Restore SW1's recorded priority if the change was only temporary, and verify the resulting roles before saving. Root changes can move forwarding paths and interrupt traffic; do not use an operational network for this exercise. The trade-off of an explicit root is that the design is predictable but still needs review when switches or link costs change.
Test yourself on bridge IDs and the root
Two switches both have priority 32768 for VLAN 1. One has MAC 0200.0000.0050, the other 0200.0000.0010. Which becomes root?
SW3 has Root ID 24586 and Bridge ID 32778 for VLAN 10. What does that tell you?
What priority does a switch show for VLAN 20 if it's left at the default?
Sources: Cisco bridge IDs, election and verification; Cisco classic STP versus RSTP. Commands and outputs are documentation-based examples, not switch captures.