STP Path Cost Method (short vs long)

The path cost is the metric Spanning Tree (STP) uses to calculate the shortest path to the elected root bridge. The slower the interface, the higher the cost is. The path with the lowest cost will be used to reach the root bridge.

In this post, you’re going to learn about the short and long STP Path Cost Methods, and how they differ.

Short vs Long

The path cost is based on the speed of the switch’s port or interface. When Spanning Tree was developed, a field of 16 bits was assigned to the Spanning Tree path cost, which is also known as the short method. The following table shows the default cost values assigned to interfaces using the short method.

Port SpeedDefault Cost Value
10 Mbps100
100 Mbps19
1 Gbps4
10 Gbps2
25 Gbps1
40 Gbps1
100 Gbps1
STP Path Cost Short Mode

NOTE: These STP costs can be manually configured on every interface. See below how you can change interface G0/0, a 1 Gbps port with a default STP cost of 4, to an STP cost of 10.

Switch#show interface gi0/0 | i BW
  MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec, 
Switch#
Switch#show spanning-tree interface gi0/0

Vlan                Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
VLAN0001            Root FWD 4         128.1    P2p 
Switch#
Switch#config term
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#interface gi0/0
Switch(config-if)#spanning-tree cost 10
Switch(config-if)#end
Switch#
*Feb 16 20:33:40.824: %SYS-5-CONFIG_I: Configured from console by console             
Switch#show spanning-tree interface gi0/0

Vlan                Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
VLAN0001            Altn BLK 10        128.1    P2p 
Switch#

As interface bandwidths increased, the 16-bit value did not provide room for newer high-speed interfaces. In the table above, notice that Spanning Tree assigns a cost of 1 to 25, 40, and 100 Gbps Ethernet interfaces and therefore cannot judge what link is better over the other to reach the root bridge. STP treats all three links the same and as a result, Spanning Tree may not prefer a 100 Gbps over a 25 Gbps interface based on the local STP cost of the interfaces. This limitation can be overcome with the Spanning Tree long method.

The newer Spanning Tree long mode path cost method increased the port cost field from 16 to 32 bits. The short method uses a 16-bit format that yields values from 1-65535 whereas the long method uses a 32-bit format that yields values from 1-200,000,000, which provides more granularity in data centers that use extremely high-speed interfaces.

The Cisco command to enable the long method is spanning-tree path cost method long. This command increases the path cost field from 16 to 32 bits.

Port SpeedDefault Cost Value
100 Kbps200000000
1 Mbps20000000
10 Mbps2000000
100 Gbps200000
1 Gbps20000
10 Gbps2000
25 Gbps800
40 Gbps500
100 Gbps200
1 Tbps20
10 Tbps2
STP Path Cost Long Mode

But, how do you calculate the STP Port Cost? Let’s take a look.

How to Manually Calculate the STP Path Cost Long Method?

The maximum value is 20,000,000,000, so to calculate the STP cost value in long mode, you divide this value by the port speed in Kbps. See the table below.

Port SpeedSTP Cost Calculation
100 Kbps20,000,000,000 / 100 Kbps = 200,000,000
1 Mbps20,000,000,000 / 1,000 Kbps = 20,000,000
10 Mbps20,000,000,000 / 10,000 Kbps = 2,000,000
100 Mbps20,000,000,000 / 100,000 Kbps = 200,000
1 Gbps20,000,000,000 / 1,000,000 Kbps = 20,000
10 Gbps20,000,000,000 / 10,000,000 Kbps = 2,000
25 Gbps20,000,000,000 / 25,000,000 Kbps = 800
40 Gbps20,000,000,000 / 40,000,000 Kbps = 500
100 Gbps20,000,000,000 / 100,000,000 Kbps = 200
1 Tbps20,000,000,000 / 1,000,000,000 Kbps = 20
10 Tbps20,000,000,000 / 10,000,000,000 Kbps = 2
STP Path Cost Table Long Mode Calculation

How to Enable the STP Path Cost Long Method?

Here’s how to enable STP Path Cost Long on a Cisco Catalyst switch.

Cat9500-SW01#config term
Cat9500-SW01(config)#spanning-tree pathcost method long
Cat9500-SW01(config)#end
Cat9500-SW01#show spanning-tree summary
Switch is in rapid-pvst mode
Root bridge for: VLAN0001, VLAN0003, VLAN0016
Extended system ID                      is enabled
Portfast Default                        is disabled
Portfast Edge BPDU Guard Default        is disabled
Portfast Edge BPDU Filter Default       is disabled
Loopguard Default                       is disabled
PVST Simulation Default                 is enabled but inactive in rapid-pvst mode
Bridge Assurance                        is enabled
EtherChannel misconfig guard            is enabled
UplinkFast                              is disabled
BackboneFast                            is disabled
Configured Pathcost method used is long
 
Name                   Blocking Listening Learning Forwarding STP Active
---------------------- -------- --------- -------- ---------- ----------
VLAN0001                     1         0        0          0          1
VLAN0003                     1         0        0          0          1
VLAN0016                     1         0        0          0          1
VLAN0040                     0         0        0          1          1
VLAN0041                     0         0        0          1          1
VLAN0042                     0         0        0          1          1
VLAN0043                     0         0        0          1          1
VLAN0044                     0         0        0          1          1
VLAN3967                     0         0        0          1          1
---------------------- -------- --------- -------- ---------- ----------
9 vlans                      3         0        0          6          9
Cat9500-SW01#

Here’s how to enable the STP Patch Cost Long on a Nexus switch.

NX93180-Core(config)# show spanning-tree summary
Switch is in rapid-pvst mode
Root bridge for: VLAN0001, VLAN0016, VLAN0040-VLAN0044, VLAN3967
L2 Gateway STP                           is disabled
Port Type Default                        is disable
Edge Port [PortFast] BPDU Guard Default  is disabled
Edge Port [PortFast] BPDU Filter Default is disabled
Bridge Assurance                         is enabled
Loopguard Default                        is disabled
Pathcost method used                     is short
vPC peer-switch                          is enabled (operational)
STP-Lite                                 is disabled
 
Name                   Blocking Listening Learning Forwarding STP Active
---------------------- -------- --------- -------- ---------- ----------
VLAN0001                     0         0        0          2          2
VLAN0016                     0         0        0          2          2
VLAN0040                     0         0        0          2          2
VLAN0041                     0         0        0          2          2
VLAN0042                     0         0        0          2          2
VLAN0043                     0         0        0          2          2
VLAN0044                     0         0        0          2          2
VLAN3967                     0         0        0          2          2
---------------------- -------- --------- -------- ---------- ----------
8 vlans                      0         0        0         16         16
NX93180-Core(config)# 
 

NX93180-Core(config)# spanning-tree pathcost method long
NX93180-Core(config)# show spanning-tree summary
Switch is in rapid-pvst mode
Root bridge for: VLAN0001, VLAN0016, VLAN0040-VLAN0044, VLAN3967
L2 Gateway STP                           is disabled
Port Type Default                        is disable
Edge Port [PortFast] BPDU Guard Default  is disabled
Edge Port [PortFast] BPDU Filter Default is disabled
Bridge Assurance                         is enabled
Loopguard Default                        is disabled
Pathcost method used                     is long
vPC peer-switch                          is enabled (operational)
STP-Lite                                 is disabled
 
Name                   Blocking Listening Learning Forwarding STP Active
---------------------- -------- --------- -------- ---------- ----------
VLAN0001                     0         0        0          2          2
VLAN0016                     0         0        0          2          2
VLAN0040                     0         0        0          2          2
VLAN0041                     0         0        0          2          2
VLAN0042                     0         0        0          2          2
VLAN0043                     0         0        0          2          2
VLAN0044                     0         0        0          2          2
VLAN3967                     0         0        0          2          2
---------------------- -------- --------- -------- ---------- ----------
8 vlans                      0         0        0         16         16
NX93180-Core(config)#

Thoughts on Network Design

With today’s high speed Ethernet interfaces, it is a good practice to set STP Path Cost method to long; however, you have to remember to switch the mode from short to long on all the switches in your network.

It is unlikely that modern data center designs rely on Spanning Tree for redundancy. Today’s data centers implement dual connections to their redundant network core with port channels and routed interfaces.

Data Center Design with No Reliance on Spanning Tree
Data Center Core Design with No Reliance on Spanning Tree

Although possible, it is unlikely to see switches with 100 Gbps and 40 Gbps as possible paths to the root switch and relying on Spanning Tree for Ethernet loop prevention.

ABOUT THE AUTHOR

Alirio Zavarce, CCIE #28672, is a seasoned enterprise route-switch consultant with 30 years of experience with data networks. Alirio started this networking blog to help his peers become better network engineers and share all his everyday experiences and troubleshooting tips. More about me...

If Alirio had to prepare to take it again, here's what he would do to pass the CCIE lab.

Please Share

Leave a Comment

Share to...