# How Spanning Tree Protocol (STP) select Root Port, Spanning Tree Root Port selection

If a Switch has multiple paths to reach the Root Bridge (Root Switch), it must select one path and the associated port as the Root Port. Following are the different steps for selecting the Root Bridge (Switch).

Spanning Tree Root Port selection process in a Non-Root Switch involves the following steps.

1. Select the port connected to the path with the lowest accumulated Spanning Tree Path Cost to the Root Bridge (Root Switch) as the Root Port, when a Non-Root Switch has multiple paths to reach the Root Switch.
2. If multiple paths are available to reach the Root Bridge (Root Switch) with the same accumulated Spanning Tree Path Cost in a Non-Root Switch, select the port connected to the neighbor switch which has the lowest Switch ID value as the Root Port.
3. If all the multiple paths go through the same neighboring switch to reach the Root Bridge (Root Switch), Non-Root Switch will select the local port which receives the lowest port Spanning Tree Port Priority value from neighbor Switch as the Root Port.
4. If the received Spanning Tree Port Priority value values are the same between the connecting ports to reach the Root Bridge (Root Switch), Non-Root Switch will select the port which receives the lowest physical port number from neighbor Switch as the Root Port. This is the last tie breaker.

#### 1) Select the port connected to the path with the lowest accumulated Spanning Tree Path Cost to the Root Bridge (Root Switch) as the Root Port, when a Non-Root Switch has multiple paths to reach the Root Switch.

Above topology, omnisecu.com.SW4 has two paths to reach the Root Switch (omnisecu.com.SW1). Total Spanning Tree Path Cost to reach the Root Switch (omnisecu.com.SW1) via left path is 19+4 = 23 (19 is the Spanning Tree Cost for Fast Ethernet Link and 4 is the Spanning Tree Cost for Gigabit Ethernet Link) and the total Spanning Tree Path Cost to reach the Root Switch (Switch 1) via right path is 4+4 = 8 (4 is the Spanning Tree Cost for Gigabit Ethernet Link).

Therefore omnisecu.com.SW4 will select the port with least Spanning Tree Path Cost to reach the Root Switch (omnisecu.com.SW1) as its Root Port (which is marked as RP in omnisecu.com.SW4 in above diagram).

#### 2. If multiple paths are available to reach the Root Bridge (Root Switch) with the same accumulated Spanning Tree Path Cost in a Non-Root Switch, select the port connected to the neighbor switch which has the lowest Switch ID value as the Root Port.

Above topology, omnisecu.com.SW4 has two paths to reach the Root Switch (omnisecu.com.SW1). Total Spanning Tree Path Cost to reach the Root Switch (omnisecu.com.SW1) via left path is 4+4 = 8 (4 is the Spanning Tree Cost for Gigabit Ethernet Link) and the total Spanning Tree Path Cost to reach the Root Switch (omnisecu.com.SW1) via right path is 4+4 = 8 (4 is the Spanning Tree Cost for Gigabit Ethernet Link).

Above topology, both path has the same accumulated Spanning Tree Path Cost to reach the Root Switch (omnisecu.com.SW1). Now the omnisecu.com.SW4 will select the port connected to the Switch which has the lowest Spanning Tree Switch ID, as the Root Port. As shown in above topology, out of the two neighbour switches that can be used to reach the Root Bridge, omnisecu.com.SW2 has the MAC address 0000:0000:0002 and omnisecu.com.SW3 has the MAC address 0000:0000:0003.

Above topology, omnisecu.com.SW2 has the lowest MAC address (0000:0000:0002) and omnisecu.com.SW4 will select the port connected to omnisecu.com.SW2 as the Root Port (which is marked as RP in omnisecu.com.SW4 in above diagram).

#### 3. If all the multiple paths go through the same neighboring switch to reach the Root Bridge (Root Switch), Non-Root Switch will select the local port which receives the lowest port Spanning Tree Port Priority value from neighbor Switch as the Root Port.

Consider the situation where multiple paths are available to reach the Root Bridge (Root Switch) with the same accumulated Spanning Tree Path Cost, and all paths go through the same neighbor switch to reach the Root Bridge. Now both the cases mentioned above are tie.

In this case, Spanning Tree Protocol will choose the local port which recieves the BPDU with lowest Spanning Tree Port Priority value from the neighbour switch as the Root Port. Default Spanning Tree Port Priority value value is 128 and you may change the Port Priority value in increments of 16.

Above topology, omnisecu.com.SW5 has two paths with the same accumulated Spanning Tree Path Cost to reach the Root Switch (omnisecu.com.SW1) and both paths are are connected via omnisecu.com.SW4.

Fa0/24 port in omnisecu.com.SW4 is configured with a Spanning Tree Port Priority value of 16. omnisecu.com.SW5 will select its local port fa0/24 as the Root Port (which is marked as RP in omnisecu.com.SW5), because fa0/24 is the port which recieves the BPDU with lowest Spanning Tree Port Priority value from the neighbour switch omnisecu.com.SW4.

Click the below link to learn how to change the Spanning Tree Port Priority value.

#### 4. If the received Spanning Tree Port Priority value values are the same between the connecting ports to reach the Root Bridge (Root Switch), Non-Root Switch will select the port which receives the lowest physical port number from neighbor Switch as the Root Port.

Consider the situation where multiple paths are available to reach the Root Bridge (Root Switch) with the same accumulated Spanning Tree Path Cost, and all paths go through the same neighbor switch to reach the Root Bridge. All the ports in the neighbour switch are configured with the same Spanning Tree Port Priority value. Now all the cases mentioned above are tie.

In this case, Spanning Tree Protocol will choose the port on the local switch, which recieves the BPDU with lowest physical port number from the neighbour switch as the Root Port. For example, on a 2960, that would be FastEthernet 0/1 or Gigabit 0/1.

Above topology, omnisecu.com.SW5 has two paths with the same accumulated Spanning Tree Path Cost to reach the Root Switch (omnisecu.com.SW1) and both paths are are connected via Switch 4. Both fa0/23 and fa0/24 ports are connected to fa0/23 and fa0/24 ports on omnisecu.com.SW4, which has the same Spanning Tree Port Priority value.

Now omnisecu.com.SW5 will select fa0/23 as the Root Port (which is marked as RP in omnisecu.com.SW5), because fa0/23 is the port on omnisecu.com.SW5, which recieves the BPDU with lowest physical port number from the neighbour switch, omnisecu.com.SW4. This is the last tie breaker.