Selecting STP root port

As we’ve mentioned before, all working interfaces on the root switch are placed in forwarding state. All other switches (called nonroot switches) determine the best path to get to the root switch and the port used to reach the root switch is placed in forwarding state. The best path is the one with the lowest cost to reach the root switch. The cost is calculated by adding the individual port costs along the path from the switch to the root.

Take a look the following example:

STP root port selection

SW1 has won the election process and is the root switch. Consider the SW3’s perspective for choosing its root port. Two paths are available to reach the root switch, one direct path over Fa0/1 and the other going out Fa0/2 and through SW2. The direct path has a cost of 19, while the indirect path has the cost of 38 (19+19). That is why Fa0/1 will become the root port on SW3.

In case the best root cost ties for two or more paths, the following tiebreakers are applied:

  • the lowest neighbor bridge ID
  • the lowest neighbor port priority
  • the lowest neighbor internal port number

The default port cost is defined by the operating speed of the interface:

SpeedCost
10 Mbps100
100 Mbps19
1 Gbps4
10 Gbps2

You can override the default value on the per-interface basis using the following command:

(config-if)#spanning-tree cost VALUE