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.
| 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, the switch with the lowest MAC address becomes root. This is often the oldest switch.
The four decisions
- 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 has the lowest bridge ID (24576). SW2 and SW3 stop claiming to be root and pass on SW1's BPDUs instead.
- 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 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. 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.
| Decision | How many | Chosen by |
|---|---|---|
| Root bridge | One per network (per VLAN in PVST+) | Lowest bridge ID |
| Root port | One per non-root switch | Lowest total cost to the root |
| Designated port | One per link | The end with the lowest cost to the root |
| Blocked port | Whatever's left | Any 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
Two switches both have priority 32768 for VLAN 1. One has MAC 0200.0000.0050, the other 0200.0000.0010. Which becomes root?
What priority does a switch show for VLAN 20 if it's left at the default?