STP Cost Calculation: Path Cost and Root Port Examples
Learn how STP adds link costs, compares paths to the root bridge and selects one root port—without getting lost in the numbers.

How does STP cost calculation work?
root path cost+Local receiving
port cost=Total path cost
to the root
Default port cost is derived from interface speed: faster links normally have lower cost. Each non-root switch chooses exactly one root port—the port that receives the best BPDU and offers the best path toward the root bridge.
STP cost values: short and long methods
The familiar CCNA values 100, 19 and 4 belong to the classic 16-bit short path-cost method. Modern networks may use the 32-bit long method, which distinguishes high-speed links more precisely.
| Link speed | Short method | Long method | Meaning |
|---|---|---|---|
| 10 Mbps | 100 | 2,000,000 | Highest cost of these examples |
| 100 Mbps | 19 | 200,000 | Preferred over 10 Mbps |
| 1 Gbps | 4 | 20,000 | Preferred over 100 Mbps |
| 10 Gbps | 2 | 2,000 | Lowest cost of these examples |
Memory aid Slower interface = higher cost. Faster interface = lower cost.
show spanning-tree.Worked example: compare two paths
SW4 can reach root bridge SW1 through SW2 or SW3. Add the incoming interface costs along each path.
Path A through SW2
Path B through SW3
- SW1 is the root, so it originates BPDUs with root path cost 0.
- SW2 receives the BPDU on a 100 Mbps port, adds 19 and advertises a root path cost of 19.
- SW4 receives SW2’s BPDU on a 1 Gbps port, adds 4 and calculates 23.
- Through SW3, SW4 calculates 19 + 19 = 38.
- Because 23 is lower than 38, the SW4 port toward SW2 becomes its root port.
Where cost appears in a BPDU
A configuration BPDU carries the Root ID and a Root Path Cost field. Switches do not build a link-state map of the entire topology. They compare the BPDU information received on their ports and improve the advertised cost by adding their local receiving-port cost.
19
For the selected path above, SW2 advertises 19. SW4 does not expect SW2 to advertise SW4’s local link cost; SW4 adds its own incoming 1 Gbps port cost of 4 and obtains 23.
What happens when STP costs are equal?
Path cost is not the only comparison. If two candidate BPDUs tie, STP keeps comparing fields until it finds a lower value.
Two parallel links to the same upstream switch
If SW2 receives equal-cost BPDUs over two links from the same upstream switch, the upstream sender port ID normally breaks the tie. Port ID combines port priority and port number. With default priorities, the BPDU sent from the lower-numbered upstream port wins.
Verify and configure STP cost on Cisco switches
Show the selected cost
SW4# show spanning-tree vlan 10
Interface Role Sts Cost Prio.Nbr Type
--------- ---- --- ----- -------- ----
Gi0/1 Root FWD 4 128.1 P2p
Fa0/2 Altn BLK 19 128.2 P2p
SW4# show spanning-tree interface gi0/1 detailChoose short or long method
SW4(config)# spanning-tree pathcost method long ! Return to the platform default SW4(config)# no spanning-tree pathcost method long
Set an interface cost deliberately
SW4(config)# interface GigabitEthernet0/1 SW4(config-if)# spanning-tree vlan 10 cost 50 ! Restore the calculated default SW4(config-if)# no spanning-tree vlan 10 cost
Command syntax and valid ranges depend on platform, spanning-tree mode and whether the interface is an access port or trunk. Always check the device command reference and confirm the result with show spanning-tree vlan 10.
Common STP cost calculation mistakes
- Comparing only one link: add every incoming port cost along the complete path to the root.
- Mixing short and long values: determine the active path-cost method first.
- Adding the outgoing port incorrectly: a switch adds the cost of the local port on which it receives the BPDU.
- Assuming the switch knows the entire topology: STP makes distributed decisions from received BPDUs.
- Stopping when costs tie: continue with sender Bridge ID and sender Port ID.
- Changing cost without verifying VLAN scope: trunk ports may use per-VLAN cost settings.
Spanning Tree Cost Calculation Frequently Asked Questions
How is STP root path cost calculated?
Add the costs of the incoming ports used along the path from the non-root switch toward the root bridge. Operationally, each switch adds its local receiving-port cost to the root path cost advertised in the BPDU.
Why does STP prefer the lowest cost?
Lower default cost represents higher interface speed, so selecting the lowest cumulative cost normally creates the fastest available loop-free path to the root.
What is the STP cost of a 1 Gbps link?
It is 4 with the classic short method and 20,000 with the long method.
What is the STP cost of a 100 Mbps link?
It is 19 with the short method and 200,000 with the long method.
Where is root path cost stored?
Configuration BPDUs include a Root Path Cost field that represents the sender’s cost to reach the root bridge.
Can I change STP cost manually?
Yes. A manual interface or per-VLAN cost can influence path selection, but it should be planned, documented and verified carefully.
Authoritative references
Cost values and path-selection behavior were checked against Cisco’s Spanning Tree Protocol guide, Catalyst STP configuration guide and Cisco short and long path-cost table.