Spanning-Tree Cost Calculation

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