Spanning-Tree Cost Calculation

This topic is to discuss the following lesson:

1 Like
  1. Lowest sender port ID: when the switch has two interfaces connecting to the same switch, and the cost to reach the root bridge is the same it will use the interface connected to the lowest upstream switch port. Isnt it, Rene?

Andy if I understand your question correctly then I think no. The lowest switch port number is a local decision therefore it is not considering the port numbers of the upstream switch.
I also can be wrong… :slight_smile: Maybe someone will correct me.


In the calculation , the switch , receive a bdpu with root path cost value ( the link cost is given by costs Of the 2 port ,upstream and downstream)
The switch add at this path cost value , cost Of the port whrere receive the bpdu… When sendig this bpdu out another port, the switch shoulds also add the cost Of the port which use to forward??

Hi Francesco,

The switch will add the cost of its root port when it forwards the BPDU. It never adds the cost of the interface that is used to send the BPDU.

The total cost to get to the root will be the sum of all root ports.


thanks so much—

If my topology is SW1 (root) ==> SW2 ==> SW3 The “root path cost” that received the SW3 is the cost that SW2 has to reach the root?
SW3 not add the cost of its interface?

Hi Oscar,

The cost on SW3 will include the cost from SW2 and also the cost of the root port of SW3.

If you want to test this, connect three switches in a row and then use the spanning-tree cost command on the root ports of SW2 and SW3.


Hlw Rene,

When Root Bridge will send BPDU to downside, what will be the cost in path cost field ??

Expecting your so nice explanation as always :slight_smile:


When a switch (including the root) sends a BPDU, it does not add any additional cost to the BPDU. Instead, the receiver of the BPDU adds the cost of the link on its root port to the incoming BPDU.

In the case of a root bridge (since it is the root), the cost would be zero. When the root bridge sends the BPDU, it maintains zero as the cost.

Hlw Rene,

According to your Topology what is the port role between SWC to SWA and SWC to SWE link ??

I have one more question …

Suppose SW1----SW2------SW3 connected serially .We have set SW1 priority 4096 and other SW priority default.First Elect Root bridge by exchanging BPDU to each other, right ?? So, How SW3 will receive superior BPDU of SW1.How SW2 inform SW3? SW3 will reform BPDU ??


You got it right. So in you scenario


where all three switches start up at the same time, all three switches claim that they, themselves, are the root bridge. Once SW2 gets the BPDU from SW1 with a lower priority, SW2 agrees that SW1 is better, and so is the root. In the meantime, if SW3 sends SW2 a bpdu where SW3 is claiming to be the root, SW2 will just ignore that, because SW3 has a worse priority than SW1.

Now, once SW1 starts sending BPDUs (which is the job of the root bridge), SW2 will accept that via its root port (connection to SW1), and send out a copy of that BPDU on all of its ports (in this case the Designated Port to SW3). When SW3 sees that BPDU (the copy sent from SW2), it now knows that SW1 should be the root.

Hi Rene, Andrew,

Just curious on my spanning tree understand,

q1) For STP, can I say that -> for a connection between 2 switches, if both ends are “Designated port” , 1 end will have to be BLOCK.

q2) For the complete diagram above,
Switch C’s interface (10mbits connection) to Switch A will be block (assuming switch A has a lower MAC then C)
Switch E’s interface (10Mbits connection) to Switch C will be block (assuming switch C has a lower MAC then E)
right ?


Hi Alan,

If you only have two switches then you will have a root port on one end and a designated port on the other end. One switch will be the root bridge, that will be the designated port.

Only between non-root switches, one end will be the designated port and the other end the non-designated port.

You are correct about the blocked ports. SwitchA is the root btw so those interfaces are always designated ports.


Hi Rene,

I am not clear about the root bridge. I mean why are we finding the root port(for non-root bridge) to reach the root bridge. Is it like in practical scenario, the root bridge is set as destination to one of the server?

Hello Navjot.

The purpose of finding a root bridge within a topology is to have a point of reference. When calculating the STP, you must begin somewhere, so a root bridge must be chosen. Once that is done, the algorithm can proceed. You can see a detailed description of how STP works at the following lesson:

I hope this was helpful!


1 Like

Hello Rene,

I’m a little bit confused with Cost & Priority.

Is the following statement correct?

Modifying the Port Priority will only act on switches that are direct neighbor to the root switch, and modifying the Cost will have an effect (through the Root Path Cost) on the whole Network topology?


You are very close to an accurate description. What you stated about Cost is correct, but port priority can affect neighbors that aren’t directly connect to the root bridge.

Cost vs Port Priority come into play at different levels of STP’s decision process regarding whether a port needs to be root, designated, or blocking/discarding.

After a root bridge has been elected, other switches must determine which port they have that represents the lowest COST path to the root bridge. When you set a Cost, this change will affect how all other switches see this path that are downstream from the switch where you made the setting. So in this sense, the change doesn’t necessarily affect the entire network topology as you stated, but rather only those switches downstream (from the perspective of the root bridge).

Port Priority is used much further down the decision tree for STP. This really only comes into play when a switch #1 has multiple connections to switch #2 where switch #2 is closer to the root bridge (or is the root bridge itself). In this case, Switch #1 has to decide which of its ports it wants to use as its connection to switch #2. The lower the port priority, the higher preference is given to it. So it really doesn’t matter whether Switch #2 is the root bridge, or happens to be an non-root bridge that switch #1 wants to use to get to the root bridge.

One important point with Port Priority, is that setting a value on switch #1 has NO effect on switch #1. Instead, you have to set the port priority on switch #2, so that switch #1 will learn this from switch #2. So just remember, that port priority set on an upstream port will affect the immediately connected downstream neighbor, but not the switch where it is actually set.

Hi Rene,

In a topology where 2 Non root switches connected with redundant links
and other switch(Root switch) which is connected to both non root switch in triangular toplogy.
How Designated ports and non designated ports elected.

Hello Rohitendu.

The scinario that you described essentially asks the question: What happens when we have two links between two switches that have equal cost paths back to the root? If I’m not mistaken, the topology you are referring to is the following:

Root Switch
|         \
|          \
|           \

where the ==== is essentially two physical links. So the question is, how are the designated ports determined between SW1 and SW2?

If you had only one link between SW1 and SW2, then the designated port will be the port on the switch with the lower Bridge ID. Let’s say SW1 has a bridge ID of AAAA.AAAA.AAAA and SW2 had a bridge ID of BBBB.BBBB.BBBB. The port on SW1 would be designated and the port of SW2 would be blocked.

Now going back to our scinario with two links between SW1 and SW2, the same exact procedure would occur for each link. With the above mentioned Bridge IDs, you would have both interfaces on SW2 as blocked and both interfaces on SW1 as designated.

I hope this has been helpful!


1 Like