STP Root Bridge Election Process Explained | How STP selects the root bridge

This video explains the STP root bridge election process. Learn how to manipulate the STP root bridge election process.
This video is based on the following tutorial.
www.computernetworkingnotes.c...
Video description
STP (Spanning Tree Protocol) is a layer two protocol. It finds and removes switching loops from the network. It builds a virtual topology of the entire network and checks all paths. If switches have more than one path to a single destination, it enables only one path and disables all additional paths to remove loops.
STP runs a separate instance for every VLAN. For example, if you have five VLANs, there will be five STP instances. Each instance builds and uses its own virtual topology. The STP virtual topology starts from the root bridge. All STP running switches first elect a root bridge for every VLAN. After electing a root bridge, they use it as a reference to make all other decisions, such as which ports will block to remove loops and which ports will forward frames. STP selects only one switch as a root bridge from all switches for every VLAN. For example, if a network has two VLANs, there will be two root bridges, one in each VLAN.
STP uses BID (Bridge ID) or switch ID to compare and select the root bridge. The BID is an 8-byte value unique to each switch. It consists of three components: the bridge priority (2-byte), system ID (6-byte), and VLAN ID.
The bridge priority is a changeable numeric value. It allows us to manipulate the root bridge selection process. The switch having the lowest bridge priority value becomes the root bridge. The default priority value is 32768. If we want STP to select a particular switch as a root bridge, we can change its priority value to lower than others.
The system ID is a non-changeable value. STP uses the MAC address of the switch as the system ID. A MAC address is a globally unique address. No two switches can have the same MAC address. Using the switch's MAC address as the system ID ensures that each switch’s bridge ID remains always unique.
The system ID makes the BID unique across the switches. But, it does not make unique them across the VLANs. For example, if a switch has two VLANs, the BID will be the same for both.
As we know, STP runs a separate instance for each VLAN and each instance elects its own root bridge. If VLANs use the same BID, STP will fail to select the root bridge. To make the BID unique across the VLANs, STP adds the VLAN ID to the default priority. Adding VLAN-ID to the default priority ID makes the BID unique across all VLANs and switches in the network.
A switch uses the following process to calculate a unique BID.
It checks the running configuration for custom bridge priority. If the custom priority value is set, it uses the configured value.
If the custom priority value is not set, it uses the default priority value.
It adds the VLAN ID to the priority value.
It uses the switch's MAC address with the calculated priority value.
BID calculation process example
The MAC address of the switch is 1111.1111.1111. We did not change the default priority value on it. But, we configured two VLANs on it. Their IDs are 10 and 20.
BID calculation for the first VLAN = 32768 (Default priority) + 10 (VLAN ID) / 1111.1111.1111
BID for the first VLAN = 32778/1111.1111.1111
BID calculation for the second VLAN = 32768 (Default priority) + 20 (VLAN ID) / 1111.1111.1111
BID for the second VLAN = 32888/1111.1111.1111
STP uses the BID of all participating switches to select the root bridge. It chooses the switch having the lowest BID as the root bridge.
Let us take an example.
We have three switches. The MAC address of the first switch is 1111.1111.1111. The MAC address of the second switch is 2222.2222.2222. The MAC address of the third switch is 3333.3333.3333.
We do not update or change the default priority ID. We also did configure any VLANs on these switches. The bridge ID of switches will be the following.
32768 (Default priority) + 1 (Default VLAN ID) / 1111.1111.1111 (MAC address) = 32769/1111.1111.1111 (BID of Switch 1)
32768 (Default priority) + 1 (Default VLAN ID) / 2222.2222.2222 (MAC address) = 32769/2222.2222.2222 (BID of Switch 2)
32768 (Default priority) + 1 (Default VLAN ID) / 3333.3333.3333 (MAC address) = 32769/3333.3333.3333 (BID of Switch 3)
Since the BID of Switch 1 is lower than the BID of Switch 2 and 3, STP selects Switch 1 as the root bridge.
Now let us suppose, we want STP to select Switch 2 as the root bridge. For it, we change the default priority ID of Switch 2 to 4096. After this change, the new BID of Switch 2 will be the following.
4096 (Custom priority) + 1 (Default VLAN ID) / 2222.2222.2222 (MAC address) = 4097/2222.2222.2222 (BID of Switch 2)
Now, the BID of Switch 2 becomes lower than the BID of Switch 1 and 3. STP selects Switch 2 as the root bridge.

Пікірлер