Sub topic 6
Port roles in the spanning tree
This chapter assumes you know how switches learn MAC addresses, how BPDUs carry the bridge ID and root path cost, and how the root bridge is elected. Here you learn what each port does once the root is known.
Why ports get roles
Every switch port that takes part in spanning tree gets a role. The role answers one question: does this port lead toward the root, lead away from it, or sit on a redundant path? The role decides whether the port forwards traffic or blocks it. Together, the forwarding ports form a loop-free tree.
The four roles
| Role | Where it sits | Forwards traffic? |
|---|---|---|
| Root port | On a non-root switch, the one port with the best path to the root | Yes |
| Designated port | On each link, the port that offers the best path to the root for that segment | Yes |
| Alternate port | A port that receives a better BPDU from another switch and is a backup path to the root | No |
| Backup port | A port that receives a better BPDU from its own switch on a shared segment | No |
The root bridge has no root port. All of its ports are designated.
Classic 802.1D uses only root, designated and blocking. Alternate and backup are the names Rapid STP (802.1w) gives to blocked ports, and they explain why a port is blocked. Cisco switches show these names in their output.
How a role is chosen
Each switch compares the BPDUs it hears. The comparison goes in this order:
- Lowest root bridge ID.
- Lowest root path cost.
- Lowest sender bridge ID.
- Lowest sender port ID.
A non-root switch picks the port that receives the best BPDU as its root port. On each link, the switch that advertises the lowest root path cost gets the designated port. Any port that is neither root nor designated becomes alternate or backup.
Worked example
In the diagram, SW1 has the lowest bridge ID, so it is the root. Each link costs 4 (Gigabit Ethernet under the default cost table is 4).
- SW2 and SW3 each reach SW1 directly at cost 4. Each makes its direct port the root port.
- On the SW1 to SW2 link, SW1 advertises cost 0, which beats SW2's cost 4. SW1's port is designated. The same holds for the SW1 to SW3 link.
- On the SW2 to SW3 link, both switches advertise root path cost 4. This ties on cost, so the sender bridge ID decides. SW2 has the lower ID, so its port is designated.
- SW3's port on that link is neither root nor designated. It receives a better BPDU from SW2, so it becomes an alternate port and blocks.
If the SW1 to SW3 link fails, SW3's alternate port can become its new root port.
Checking roles
On Cisco IOS, show spanning-tree vlan 10 lists each port with its role (Root, Desg, Altn, Back), state and cost. On SW3 you would expect the root port toward SW1 to show Root FWD and the port toward SW2 to show Altn BLK.
Exercise
A non-root switch has two links to the root bridge. Both have the same cost, and the neighbor's port IDs differ. Which port becomes the root port, and what role does the other port get?
Show answer
The costs tie and the sender bridge ID is identical, because both BPDUs come from the same root switch. The sender port ID breaks the tie, so the port that receives the BPDU with the lower sender port ID becomes the root port. The other port becomes an alternate port and blocks.