Spanning-Tree Cost Calculation

Hello Donald

There could be several things going on here. First of all, the STP cost can be calculated in one of two ways: short method or the long method. The short method uses a 16-bit number and is the default method on Cisco devices. The short method gives the following default cost values:

  • 100 for 10Mbps
  • 19 for 100Mbps
  • 4 for 1 Gbps
  • 2 for 10 Gpbs
  • 1 for anything higher

Because available link speeds are increasing rapidly due to technological advances, these cost values are no longer scalable. This is where the long method comes in, which uses a 32-bit value for the cost, resulting in the following default cost values:

  • 2000000for 10Mbps
  • 200000 for 100Mbps
  • 20000 for 1 Gbps
  • 2000 for 10 Gbps
  • 200 for 100 Gbps
  • 20 for 1 Tbps

Now having said all of that, it may be that the Tenda Wi-Fi device is using the long method while the switches are using the short method. This will obviously cause havoc in the STP configuration. In order for STP to function correctly, the correct cost method must be configured on all devices within the STP domain.

An alternative may be that the link between the Tenda Wi-Fi and SW1 may be considered extensively slow. Using the short method, a cost of 1000 would correspond to an actual bandwidth of 1 Mbps on that connection. Could it be that the link speed is actually 1 Mbps?

A third possibility is that the Tenda device has been manually configured to have a cost of 1000? The cost is something that can be modified, so this may also be a possibility.

You can find out more information about the short and long method of cost calculation at the following Cisco documentation.

I hope this has been helpful!



To solve the problem for now I filtered BPDU’s on the port connecting the tenda wifi to SW1 in the lab. Spanning port costs in the lab are back to normal. I’ll read the configuring spanning-Tree doc.

1 Like

Hi Laz,

Also want to know to why didn’t you use root path selection criteria for the selection of Designated and Non-designated port b/w the link sw4 and sw5, i think it must be the first one then later we will go on bridge-id concept?

Hello Pradyumna

We’re talking about this topology:
The roles of the ports on the link between SW4 and SW5 are determined based on the cost. SW5 must determine the port that leads to the path with the lowest cost. This is via the link with SW4, and that is why that port is chosen as a root port. So for this determination, it is the cost to the root bridge that determines the roles.

I hope this has been helpful!


If in a current infrastructure I decide to add two switches with 10G connections. What are some ways for me to verify and ensure STP is calculating those connections cost correctly?

Hello Marc

Depending on the STP that you are running, you may have different cost values for particular interfaces. For regular STP, a 10 G interface will have a cost of 2, compared to a cost of 4 for 1Gbps interfaces. However, you’re probably not running STP, but something like RSTP, which gives 2000 as the cost for 10 G interfaces as opposed to 20000 for 1 G interfaces.

In order to check out this cost, you can issue the show spanning-tree command with its various keywords, which will output the cost of each individual interface in the list of interfaces and ensure the correct cost. You can also do this on all interfaces along the path to the root bridge and check that the correct costs are being registered.

The following link shows this command and includes additional information on related STP commands.

I hope this has been helpful!



Thank you for the feedback! I thought to myself after posting this that because the BW is inversely related to the cost, what would happened if the BW was inadvertently adjusted. I ran up a lab and sure enough, yes if the BW is adjusted the cost would also be readjusted to reflect it. STP would re-converge afterwards. Thanks


Hello Marc

That’s great! It’s always helpful to lab things up just to see how the features behave and interact. The fact that you doublechecked this with a lab is excellent and is vital for exam preparation…

Good job!


Hi @ReneMolenaar

Typo in the lesson:

What is the cost is equal?

Hello Matthew

Thanks for pointing that out! I will let @ReneMolenaar know to make the correction.

Thanks again!



I want know info about implementation of this command
spanning-tree pathcost method long
why i must to implement this ?


Hello Ugo

Spanning Tree uses the cost calculation to be able to determine which ports will become the root ports on the switches in a topology. You can find out more information about how that is done at the following lesson.

Now concerning the question in your post, when STP was first developed, the STP path cost default was originally calculated by the formula 1 Gbit/s / bandwidth.

When faster speeds than 1Gbps became available, the default values had to be adjusted as otherwise speeds above 1 Gbit/s would have been indistinguishable by STP. This method is the short method. In order to configure the long method, which uses default values that allow for the differentiation of higher speeds, you use the spanning-tree pathcost method long command.

You can find out more about this command at the following Cisco documentation:

I hope this has been helpful!


So, lets say I have two switches connected on G0/1 and G0/2. SW1 is the root, all things being default, G0/2 on SW2 will go into the blocked state. If I want to force traffic to use the G0/2 link, I think I set the port priority on G0/2 on SW2 to 0 or something below 128. Is this right, or should I set it on the root bridge?

Hello Robert

If everything is left to the default values, then STP will choose the interface with the lowest interface number to become the forwarding port. So in your case G0/1 of the non-root switch would go into forwarding and G0/2 of the same switch will be blocked.

If you want to have G0/2 go into the forwarding state, and G0/1 to be blocked, then you must increase the priority value of the G0/2 port. That sounds counterintuitive. Specifically:

  • the higher the priority value, the more likely a port will go into the forwarding state
  • if the priority value is the same, the lower port number will be chosen first

This priority must be configured on the non-root switch. Root switches will never have blocked ports, all their ports are designated.

You can find out more information about this particular configuration at the following Cisco documentation:

I hope this has been helpful!



Nowadays costs values are changed.
Can you provide an example of configuration with Long-mode STP cost ?
For example to optimize STP between 10Gb and 100Gb links


Hello Giovanni

Port costs have indeed changed. Originally, they were calculated using the formula 1Gbps/bandwidth using a 16-bit number. This is called short mode. To accommodate the higher speeds available today and in the future, this has been modified to the use of a 32-bit number with the formula 20 Tbps / bandwidth. This is called long mode.

You can configure a switch to use either the short or long mode using the spanning-tree pathcost method command. More info about this command can be found here:

Keep in mind that most modern switches use the long path cost method by default.

I hope this has been helpful!


The link between SW3 & SW4 is 1000Mbit, so the cost should be 4.

How does this line makes sense - “SW3 will forward BPDUs to SW4. The root path cost field will be 100.”

Is this typo error? If not, can you please explain me?

Hello Ankit

Actually, this statement is correct, but I can understand the confusion. Take a look at the diagram again:

The statement is saying that SW3 will forward a BPDU to SW4. Within that BPDU, we have the path cost field which contains SW3’s distance to the root bridge. The link between SW3 and SW1 is a 10Mbps link, so SW3 is actually telling SW4 “I have a link to the root bridge with a cost of 100”.

Does that make sense?

I hope this has been helpful!


Laz - That makes sense to me now. Thanks for explanation. I really appreciate it.

1 Like

Hello Andrew,

When a switch (non-route bridge) forwards BPDU downstream, it is obvious that it has to add its own cost to reach the root bridge from the root, right?

If it doesn’t, then how the downstream switches do the cost calculation without knowing the upstream switch cost to reach root ?.

I had read this somewhere in the STP forum that switch adds its own cost to reach root bridge when it forwards to downstream.

Now its confusing ,please clarify