Spanning-Tree Cost Calculation

In one lesson you state that to chose what port to block, STP will find the switch with the lowest bridge ID but in another lesson you mention it is cost and port priority, which one is it?

Hi Rene,

I have a question to the description on the third topology. You say:

“SW3 will receive BPDUs on its 10 Mbit interface (cost 100) and on its 1000 Mbit interface (cost 4). It will use its 1000 Mbit interface as its root port.”

Should SW3 receive on 10Mbit interface BPDUs of 0 instead of 100 because they are generated by the root? And then SW3 add its port cost of 100 and send it to SW4 and SW5?

Is it correct that the BPDU sending SW don’t add the costs of the outgoing interface/link, only the links that left behind? So the receiving SW has to add the cost of the link where it receives the bpdu and then it will forward?

thanks and regards

Hello Thomas.

Yes you are right that the BPDU that actually enters the 10 Mbps port of SW3 will have a root path cost of 0. However, @ReneMolenaar here is saying that the cost of the 10 Mbit link is 100, not that the frame will actually have a cost of 100 in the header. Notice that in point number 3 of the same list he mentions that

SW3 will forward BPDUs to SW4. The root path cost field will be 100.

…and in point 5 he says

SW3 will forward BPDUs towards SW5 and inserts a cost of 42 in the root path cost field (19 + 19 + 4).

So yes, you are correct that the costs of the “links that are left behind” are added to the root path cost field and not the links that are being traversed currently.

I will see if Rene can clarify this in the points being made so that there is no misunderstanding.

I hope this helps!

Laz

Hello Francisco

In order for STP to choose which port to block, the first criterion it uses is COST. However, if the cost is the same, it will then use port priority.

The lowest bridge ID is only used to determine which switch will become the ROOT BRIDGE and is not directly involved in chosing which ports will be blocked.

I hope this has been helpful!

Laz

Hello Laz,
I have one question and I am going to use the below topology.

SWITCH_1=================SWITHC_2

FA0/11-------------------------------------FA0/1
FA0/22------------------------------------FA0/2

In this scenario, I have switch 1 connected to switch 2 through two Fast Ethernet links as it is drawn above. Switch 1 is the root bridge. Switch 2 has to pick one link between fa0/1 and fa0/2 links as the root port and block another one. Therefore, Switch 1 will look at the cost of fa0/1 and fa0/2 links and they both are the same which is 19. Now Switch 1 will look at the port priority of fa0/1 and fa0/2, but they both are the same which is 128 by default. So Switch 1 will now look at the port numbers and since fa0/1 is lower than fa0/2 Switch 1 will pick fa0/1 as the root port and block fa0/2.

Question:
If fa0/2 had a port priority of 16 and fa0/1 had a port priority of 128, would fa0/2 not become the root port? As far as my understanding goes, fa0/2 should become the root if it has a port priority less than fa0/1.

However, I have read somewhere, in order to influence the local switch port, the port-priority change has to be done in the upstream switch. In this case Switch 1. I have tried this in my lab and fa0/2 becomes the root port only when I change the port priority of fa0/22 on Switch 1. Would you please explain it to me at your convenient time? Thank you so much.

Azm

Hello Laz once again,
I have one more question to clarify myself. I am going to use the below topology for my question.

In this topology, I have three switches as we see in the topology and Switch 1 is the root switch.
Once we turn on all three switches, all three switches will send BPDUs to each other. Initially, every single switch will think themselves as the root switch. I am going to pick Switch 2 to start off. Switch 2 will receive BPDUs from Switch 1 and Switch 3 both. When Switch 2 will see superior BPDU coming from Switch 1, it will stop sending BPDU and consider Switch 1 as the root switch. At the same time Switch 2 will also pass the BPDU to Switch 3 that it received from Switch 1. Switch 3 will see the superior BPDU coming from Switch 1 so switch 3 will also consider Switch 1 as the root switch and stop sending BPDU. As a result, the root switch(switch 1) has been selected. Now they need to figure out which ports will be the root ports and which ports they will block. As far as my understanding goes, once all the switches in a domain figure out the reference point(root switch), all the switches stop sending BPDUs except for the root switch. I am not quite sure about the selection process of root ports and blocking ports, that is why I need your help to clarify myself. However, I am going to write here what I understand. Please correct me if I am wrong.
Again I am going to start off with Switch 2. Once all the switches agree that Switch 1 is the root switch, Switch 2 will receive BPDU from Switch 1 with root path cost of 0 and the Switch 2 will add its root link’s cost to the root path cost (0+4=4) and send it to Switch 3. On the other hand Switch 3 will also receive BPDU from Switch 1 with the root path cost of 0. At this point, Switch 3 will have two BPDUs. One is from Switch 2(cost 4) another one is from Switch 1(cost 0). Then, Switch 3 will add its each link’s cost to the respective root path cost found in BPDUs on two different ports and come up with two different costs 8 and 19. Since 8 is lower than 19, Switch 3 will pick the link connected to Switch 2 as the root port. Please correct me if I am wrong.

In a converged network, does only root switch send BPDU and other switches just forward it to their respective connected switches?

Thank you so much.

Azm

Hello Azm

In the scenario that you describe above, Fa0/2 will always be blocked and Fa0/1 will always be forwarding because Fa0/1 is lower than Fa0/2. Even if you change the port priority to 16 or anything else for that matter, the lower port will always be chosen as forwarding in the above scenario. Changing the port priority parameter will not change this order.

The port priority is only used to determine which end of a link between two NON-ROOT switches will be DESIGNATED and which will be BLOCKED.

I hope this has been helpful!

Laz

2 Likes

So, is my understanding correct?

Switches will choose the best path based on 4 factors:

  1. Lowest Cost value
  2. Lowest Priority Value
  3. Lowest MAC Address
  4. Lowest Switch port number.

So,

First the switch will consider the Cost-Value of the interface and if the interface has the lowest Cost-Value, that port is considered as the Root-Port.

- If you have a switching topology, where the Cost-Value is same to reach the Root-Bridge, then the Root-Port is chosen from the switch having the lowest Priority-Value. For Example, let’s say, we have SW-A, SW-B and SW-C and SW-C is our Root-Bridge. If Cost-value on both SW-A and SW-B is same but the Priority-Value of SW-A is less than SW-B, then STP chooses a port connected to SW-A as the Root-Port.

- If you have a switching topology, where the Cost-Value and Priority-Value are same, then the Root-Port is chosen from the switch with the lowest MAC address.

- If you have a switching topology, where the Cost-Value, Priority-Value and the MAC address are same, then the Root-Port is chosen from the switch having the lowest switch port.

Hello Bharath.

You’ve almost got it!! Here is a bit of clarification:

  1. When there is only one path to the root bridge, choose the port connected to that path as the root port.

_OK, this one goes without saying…_

  1. When there are multiple paths to the root bridge, choose the port connected to the shortest path to the root bridge based on STP cost.

_You got this one down pat._

  1. If the multiple paths have the same cost, select the port connected to the NEIGHBOUR switch which has the lowest switch ID value as the root port.

_I’m assuming in your explanation above that there is a SW-D as well, connected to both SW-A and SW-B. So when the port connected to SW-A is chosen over that connected to SW-B, it is because SW-A is the NEIGHBOUR switch with the lowest switch ID value. So we’re OK here too._

  1. When the cost and the neighbour switch IDs are the same (this is the case only when when all paths to the root bridge go through the same neighbouring switch), the port which receives the lowest STP priority value from the neighbouring switch will be chosen as the root port.

_Note here that the port priority value for all ports is by default 128. If this is changed, then this priority value will be used to determine the root port. Remember, it is not the priority value of the port itself that is compared, but the priority value RECEIVED by the port from the neighbouring switch that is compared._

  1. When the cost, the neighbour switch ID and the received port priorities are the same, the root port will be chosen based on the port which receives the lowest physical port number from the neighbour switch.

_Here there can be no tie. If we’ve reached this point, then there is only one neighbouring switch, and thus each of its connections will be on different ports. Keep in mind again, that it is not the physical port numbers of the switch in question that determines the root port, but the physical port numbers of the neighbouring switch that are RECEIVED by the port FROM the neighbouring switch that is compared._

I hope this has been helpful!

Laz

Hi Rene,

Could you just explain me the ports roles and states for your mentioned diagram. I have understood about the root port election but i am confused with roles and states. Thanks in advance.

image

Hello Swapnil

You can find a detailed description of the port roles including Root, Designated and Alternate ports at this lesson.

Also you can find detailed information about the port states at this lesson.

These are described in detail. Please review them and if you have additional questions, we’re here to answer!

I hope this has been helpful!

Laz

Hello,
In the Spanning-Tree tutorial, we are looking at layer 3 Cisco switches or Layer 2 switches?
I am designing a network for a three-floor building with no major complexity.
The plan is to have three layer 3 switches on 1st floor, 1 layer 2 on the 2nd floor and 1 layer 2 on the 3rd floor.
Once I connect this switches with a fiber connection and make those ports trunk ports, do spanning tree will work throughout my 5 switches?

Hello Kevin

Great to hear that you’re into designing a production network! Concerning STP, keep in mind that it functions at Layer 2, so the switches in the tutorial can be either Layer 2 or Layer 3, it will not make a difference. As for your topology, STP is enabled on Cisco switches by default so when you connect your switches, STP will begin to function.

Also note that STP will only function if a Layer 2 loop exists in the topology. If your switches are connected in such a way so that there is no loop, then even though STP is enabled, it won’t actually do anything.

One final note: STP functions on both trunk and access ports by default. This protects switches from accidentily creating a loop by connecting two interfaces of a switch together directly or via an intermediate switch for example.

I hope this has been helpful!

Laz

In that case I would suggest editing this lesson as it’s a bit confusing - it states in this lesson that the bridge ID IS used in calculating the best path to the root:

Whenever spanning-tree has to make a decision, this is the list that it will use. This is something to write down and remember:

Lowest bridge ID: the switch with the lowest bridge ID becomes the root bridge.
Lowest path cost to root bridge: when the switch receives multiple BPDUs it will select the interface that has the lowest cost to reach the root bridge as the root port.
Lowest sender bridge ID: when a switch is connected to two switches that it can use to reach the root bridge and the cost to reach the root bridge is the same, it will select the interface connecting to the switch with the lowest bridge ID as the root port.
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 with the lowest number as the root port.

If this is true then port ID would never be used, as sender bridge ID is always different due to the different MAC address.

EDIT/ Actually I believe the lesson is correct! See http://www.omnisecu.com/cisco-certified-network-associate-ccna/how-spanning-tree-protocol-stp-select-root-port.php

So the bridge ID is indeed used to calculate the best path to the root. In fact the port priority is only used when you have 2 links to the same switch.

I had the same doubt. So if i change the spanning tree cost on a port the outgoing port of the root bridge it wouldn’t change anything , the sending root path cost by root bridge will still 0 ?

Hello Juan

Yes, if the cost on the root bridge is modified, it will still send a BPDU with a cost of 0. If the bridge loses its root status, then BPDUs will start sending the configured cost.

I hope this has been helpful!

Laz

1 Like

How through the exchange of BPDUs, the root switch is elected is not clear.

PS: perhaps it goes like this - each switch starts off by advertising itself as the root. When a switch receives a BPDU, if it is from a better root candidate it does a few things:

  1. Stop advertising itself as root.
  2. Stop forwarding any BPDUs with root worse than the best root candidate it has found so far.
  3. Send BPDUs with its cost to what it has as the best root candidate so far.

I think I can “prove” that with this, the switches will converge on a root. I’m not sure this is the best way to do it, perhaps there are ways that converge on the root faster?

Hello Arun

Yes, your description of the election process is correct. It is also further described in this lesson:


Under the “How Spanning Tree Solves Loops” section.

I hope this has been helpful!

Laz

Is that right?

Hello Mark

Yep, it looks right…

Laz