Routelearn.net
Course menu

Course 6: Spanning Tree ProtocolLesson 1.3 (3 of 24 in this course)24 of 91 in the CCNA series

How Spanning Tree works

BPDUs, bridge IDs and the four decisions every switch makes.

Beginner · 7 min read

A BPDU (Bridge Protocol Data Unit) is the message switches running Spanning Tree exchange to share their bridge ID, the root bridge they believe in and their path cost to it. From the BPDUs they receive, switches elect a root bridge and decide each port’s role.

In simple terms: BPDUs are the small notes switches pass to each other to agree on who is in charge and which links to use, so that the network has no loops.

Switches talk using BPDUs

Switches running STP send each other small messages called BPDUs (Bridge Protocol Data Units). By default a BPDU goes out every 2 seconds. This is called the hello time. BPDUs go to a special MAC address. A switch reads them itself and does not pass them on. 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 bridge ID: each switch's ranking

Every switch has a bridge ID, a number that ranks it. In STP, the lower number always wins.

PartSizeSet byExample
Bridge priority4 bitsYou (multiples of 4096, default 32768)32768
Extended system ID12 bitsAutomatically: the VLAN number10
MAC address48 bitsThe switch's base MAC0200.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, the switch with the lowest MAC address becomes root. This is often the oldest switch.

The four decisions

SW1priority 24576SW2priority 32768SW3priority 32768PC APC B
  1. 1. Start: everyone claims root. When the switches start up, each one sends BPDUs saying it is the root.
  2. 2. Choose the root bridge. SW1 has the lowest bridge ID (24576). SW2 and SW3 stop claiming to be root and pass on SW1's BPDUs instead.
  3. 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. 4. Each link picks a designated port. On each link, the end closest to the root sends traffic onto that link. All the root's own ports are designated.
  5. 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.
DecisionHow manyChosen by
Root bridgeOne per network (per VLAN in PVST+)Lowest bridge ID
Root portOne per non-root switchLowest total cost to the root
Designated portOne per linkThe end with the lowest cost to the root
Blocked portWhatever's leftAny port that is not a root port or a designated port

the Common Spanning Tree lessons explains each decision in detail, including path cost and what happens when there is a tie.

Check yourself

Predict · scenario 1

Two switches both have priority 32768 for VLAN 1. One has MAC 0200.0000.0050, the other 0200.0000.0010. Which becomes root?

Predict · scenario 2

What priority does a switch show for VLAN 20 if it's left at the default?