Path cost
Calculate each candidate root path before using port-ID tie breakers.
Independent lab examples; selected output and frame summaries are illustrative. Port naming and command support vary by switch and software release.
Network and objective
Classic PVST+ is used to expose original STP behavior; rapid-PVST+ and MST are separate lessons.
Use three fresh isolated switches with Gigabit trunks: SW1 Gi1/0/23 ↔ SW2 Gi1/0/23; SW1 Gi1/0/24 ↔ SW3 Gi1/0/24; SW2 Gi1/0/24 ↔ SW3 Gi1/0/23. Both VLANs10/20 exist on every switch. Baseline SW1/SW2/SW3 priorities are4096/8192/12288, with short costs and no extra links. Start independently from the included baseline for each lesson; subsequent repair snippets apply to the named device.
How it works
A receiver adds its incoming port cost to the root cost advertised in a BPDU. With short Gigabit cost4, SW3’s direct path to SW1 is4 and its path through SW2 is8. Raising the direct port’s cost to20 makes the path through SW2 preferable.
Compare root identity, total path cost, sender bridge ID and sender port ID in order; local receiving port ID resolves a remaining tie. Port priority does not override a lower path cost. Short and long cost scales use different values; choose and verify a consistent method rather than mixing a memorized table with actual output.
Configure or inspect
SW1
vlan 10
vlan 20
spanning-tree mode pvst
spanning-tree pathcost method short
spanning-tree vlan 10 priority 4096
spanning-tree vlan 20 priority 4096
interface range GigabitEthernet1/0/23 - 24
switchport mode trunk
switchport trunk allowed vlan 10,20
switchport nonegotiate
no shutdown
exitSW2
vlan 10
vlan 20
spanning-tree mode pvst
spanning-tree pathcost method short
spanning-tree vlan 10 priority 8192
spanning-tree vlan 20 priority 8192
interface range GigabitEthernet1/0/23 - 24
switchport mode trunk
switchport trunk allowed vlan 10,20
switchport nonegotiate
no shutdown
exitSW3
vlan 10
vlan 20
spanning-tree mode pvst
spanning-tree pathcost method short
spanning-tree vlan 10 priority 12288
spanning-tree vlan 20 priority 12288
interface range GigabitEthernet1/0/23 - 24
switchport mode trunk
switchport trunk allowed vlan 10,20
switchport nonegotiate
no shutdown
exit
interface GigabitEthernet1/0/24
spanning-tree vlan 10 cost 20Verify the result
SW3#show spanning-tree vlan 10
Interface Role Sts Cost
Gi1/0/23 Root FWD 4
Gi1/0/24 Altn BLK 20
Root path cost: 8The winning root path is advertised4 plus local4 =8. The direct port still exists but its configured cost20 loses. This change affects VLAN10 only.
Failure and recovery
If the expected direct port does not win, inspect its explicit cost and the root advertised by its neighbor. Do not change port priority first when total costs differ.
SW3
interface GigabitEthernet1/0/24
no spanning-tree vlan 10 costFurther reading
Key Takeaways
- Add local ingress cost to advertised root cost.
- Short Gigabit cost4 is not the long-scale value.
- The lab compares4,8 and20 explicitly.
- Cost precedes sender/port tie breakers.
- A VLAN-specific cost affects only that instance.