PVST/STP Root Bridge Election Process Explained

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.

There are many variations of STP. Digital Equipment Corporation (DEC) created the original version of STP for its switches. It was a proprietory portocol. Later, IEEE created an open standard version of STP. It runs on all switches. However, it has some limitations. The one limit is that it runs only one instance per switch. Running one instance per switch does not effectively scale a large network, especially running multiple VLANs. To overcome this issue, Cisco developed its STP variation based on IEEE's STP. It is called PVST (Per VLAN Spanning Tree). PVST uses the same concepts, terms, and logic the IEEE's STP uses. This tutorial explains the root bridge election process for PVST. STP also uses the same process but with a slight difference in BID. Since STP runs only one instance per switch, it does not include VLAN ID in BID. You can refer to the BID tutorial of this series to learn more about how PVST and STP select BID. Apart from selecting BID, PVST and STP use the same logic and concept for the root bridge selection.

PVST runs a separate instance for every VLAN. For example, if you have five VLANs, there will be five PVST instances. Each instance builds and uses its own virtual topology. The PVST virtual topology starts from the root bridge. All PVST 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. PVST 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.

seprate stp in each vlan

BID (Bridge ID) or switch ID

PVST/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. PVST's BID consists of three components: the bridge priority (2-byte), system ID (6-byte), and VLAN ID. STP's BID consists of only components: the bridge priority (2-byte) and system ID (6-byte). It does not include VLAN ID.

bid

The bridge priority

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 PVST/STP to select a particular switch as a root bridge, we can change its priority value to lower than others.

bridge priority

The system ID

The system ID is a non-changeable value. PVST/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.

system id

The VLAN ID

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.

vlan id

As we know, PVST runs a separate instance for each VLAN and each instance elects its own root bridge. If VLANs use the same BID, PVST will fail to select the root bridge. To make the BID unique across the VLANs, PVST 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.

vlan id and bid

BID calculation process

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.(STP uses the priority value as it is. It does not add 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

bid calculation

Electing Root bridge

PVST/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, PVST selects Switch 1 as the root bridge.

STP root bridge selection

Now let us suppose, we want PVST 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. PVST selects Switch 2 as the root bridge.

root bridge election process

Packet Tracer example

Create a packet tracer lab, as shown in the following image.

packet tracer lab

PVST is by default enabled on all Cisco switches. When we start PVST running switches, they first elect the root bridge and then use it as the starting point to build their virtual topology.

To view whether a switch is a root bridge, we can use the show spanning-tree command in privileged mode. The output of this command includes three sections. The first section provides information about the root bridge. The second section provides information about the local switch. The third section shows the ports' status.

The following image shows the output of this command on Switch 0.

show spanning tree on S1

As the above output shows, this is a non-root bridge.

The following image shows the output of this command on Switch 1.

show spanning tree on S1

As the above output shows, this is also a non-root bridge.

The following image shows the output of this command on Switch 2.

show spanning tree on root bridge

As we can see in the above output, it is a root bridge.

Manipulating the Root Bridge election process

To manipulate the root bridge election process, we have to change the default priority. The spanning tree command in global configuration mode changes the default priority for the specified VLAN. The new priority value must be in multiples of 4096. If we use a value that is not in the multiple of 4096, the command does not accept the value.

The following command changes the default priority on S1 to 0.

Router(Config)spanning-tree vlan 1 priority 0

change default priority

The changes take effect immediately. PVST reruns the root bridge election process. Since we have changed the priority value of this switch to lower than others, PVST selects S1 as the root bridge. We can view the spanning tree information again to verify it.

viewing priority

Conclusion

This way, by using the priority value we can manipulate the PVST/STP root bridge election process. We can select any switch as the root bridge by changing its priority value lower than others. The root bridge is the center point of the PVST/STP virtual topology. By default, PVST/STP selects the switch that has the lowest BID as the root bridge. However, you can manipulate the root bridge election process by changing the default priority ID.

ComputerNetworkingNotes CCNA Study Guide PVST/STP Root Bridge Election Process Explained