Sub topic 7
Choosing root and designated ports, and breaking ties
This chapter assumes you know how the bridge ID and root bridge election work, what BPDUs carry, and how path cost is calculated. It also assumes you can read a switch CLI. Here you apply those pieces to decide which ports forward and which block.
The two decisions
After the root bridge is elected, every switch makes the same two kinds of decision from the BPDUs it receives.
- Each non-root switch picks exactly one root port. This is the port with the best path toward the root bridge.
- Each network segment (each link) picks exactly one designated port. This is the port on that segment with the best path toward the root bridge.
Every port that is neither a root port nor a designated port is a blocking port. In classic 802.1D it is blocked. In RSTP it is an alternate or backup port. Because every switch has one path toward the root and every link has one designated sender, the result is a loop-free tree.
The root bridge has no root port, because it is the destination. All of its ports are designated, since its root path cost of 0 cannot be beaten.
What a switch compares
A switch compares BPDUs by their priority vector. The fields are compared in this order, and the first difference decides:
- Root bridge ID (already settled by the election, so the same on every port in a stable network)
- Root path cost
- Sender bridge ID
- Sender port ID (port priority, then port number)
A lower value always wins. A BPDU that wins the comparison is called superior.
Choosing the root port
A non-root switch compares the BPDUs it receives on its ports. The cost in a received BPDU is the sender's cost to the root. The switch adds the cost of its own receiving port to get the root path cost through that port.
The tie-breakers run in this order:
- Lowest root path cost (received cost plus local port cost)
- Lowest sender bridge ID
- Lowest sender port priority
- Lowest sender port number
The last two are the sender's values, not the local switch's. This surprises many people. The receiving switch cannot choose between two links by looking at its own port numbers. It looks at what the neighbor advertises.
Choosing the designated port
For each segment, the switches attached to it compare the root path cost they would offer on that segment. They compare in this order:
- Lowest root path cost
- Lowest bridge ID of the switch
- Lowest port ID of the port
The winner's port is designated and forwards. The loser's port is not designated. If that switch has a better path through another port, this port becomes alternate (blocked). If the loser has two ports on the same segment, the worse one becomes a backup port.
Worked example: a triangle
Three switches connect in a triangle with gigabit links. Assume the default short path-cost values: 4 for 1 Gbps, 19 for 100 Mbps, 100 for 10 Mbps. SW1 is the root.
Work through each switch:
- SW2 root port. Through Gi0/1 the root path cost is 4. Through Gi0/2 (via SW3) it is 4 + 4 = 8. Gi0/1 wins on cost, so no tie-breaker is needed.
- SW3 root port. The same logic makes Gi0/1 the root port.
- The SW2-SW3 segment. Both switches offer a root path cost of 4 on this segment. The tie goes to the sender bridge ID. Both priorities are 32778 (the default 32768 plus VLAN 10), so the lower MAC address decides. SW2 has the lower MAC, so SW2 Gi0/2 is designated and SW3 Gi0/2 is alternate and blocks.
You can confirm this on SW3:
SW3# show spanning-tree vlan 10
VLAN0010
Spanning tree enabled protocol rstp
Root ID Priority 4106
Address 0011.1111.1111
Cost 4
Port 1 (GigabitEthernet0/1)
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address 0033.3333.3333
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------
Gi0/1 Root FWD 4 128.1 P2p
Gi0/2 Altn BLK 4 128.2 P2pThe Cost 4 in the Root ID block is SW3's root path cost. The Cost column in the table is the cost of each individual port.
When the tie goes all the way down to port ID
Suppose SW2 connects to SW1 with two parallel links, SW1 Gi0/3 to SW2 Gi0/1 and SW1 Gi0/4 to SW2 Gi0/2. Both links have the same speed. SW2 sees the same root path cost, the same sender bridge ID (SW1), and the same sender port priority (128 by default). The decision falls to the sender port number. SW1 Gi0/3 is 128.3 and Gi0/4 is 128.4, so SW2 picks the port connected to SW1 Gi0/3. The port numbers on SW2 are irrelevant.
Two interface commands let you steer this outcome:
! On the upstream switch (SW1): lower sender port priority is preferred
interface GigabitEthernet0/4
spanning-tree vlan 10 port-priority 64
! On the downstream switch (SW2): raise the cost of a port you want to avoid
interface GigabitEthernet0/1
spanning-tree vlan 10 cost 100Port priority is configured in steps of 16 and ranges from 0 to 240. Setting port-priority on SW2 would change the value SW2 sends to its own downstream neighbors. It would not change which of SW2's own ports becomes the root port.
Common errors
- Changing the wrong switch. To prefer one of two parallel links, adjust port priority on the sender side, or cost on the receiver side. Adjusting the receiver's port priority does nothing to its own root port choice.
- Assuming a faster link always wins. Root path cost is a sum. A two-hop gigabit path (4 + 4 = 8) beats a direct 100 Mbps link (19).
- Mismatched cost methods. If one switch uses the long path-cost method and another uses the short one, the sums are not comparable and the tree can pick surprising paths. Use one method across the domain.
- Forgetting that tie-breaking by MAC address is arbitrary. If you have not set priorities, the lowest MAC address decides designated ports and the root. Set priorities where you care about the result.
Quick reference
| Decision | Compared in order |
|---|---|
| Root port (per switch) | Root path cost, sender bridge ID, sender port priority, sender port number |
| Designated port (per segment) | Root path cost, switch bridge ID, port ID |
| Everything else | Alternate or backup (blocking in 802.1D) |
Exercise
SWA is the root. SWB connects to it with two gigabit links: SWA Gi0/3 to SWB Gi0/1, and SWA Gi0/4 to SWB Gi0/2. All port priorities are default. Which SW_B port becomes the root port, and what single command on which switch makes the other port the root port instead?
Show answer
SWB Gi0/1 becomes the root port. Cost, sender bridge ID, and sender port priority are equal, so the lower sender port number decides: SWA Gi0/3 (128.3) beats Gi0/4 (128.4). To make SWB Gi0/2 the root port, lower the port priority on the sender, for example spanning-tree vlan 10 port-priority 64 on SWA Gi0/4. Alternatively, raise the cost on SW_B Gi0/1.
Exercise
SW2 has a 100 Mbps link directly to the root (cost 19) and a gigabit link to SW3, whose own root path cost is 8 over gigabit links. Which SW2 port is the root port, assuming short path-cost values?
Show answer
The direct 100 Mbps port. Its root path cost is 19. The path through SW3 costs 8 + 4 = 12, so the gigabit port toward SW3 is actually lower, and it becomes the root port. Cost is a sum, so compare the totals, not the link speeds.