Network Kings

Multi-Access Year Deal

Get 55+ courses now at the best price ever! Use Code:    MULTIYEAR

d :
h :

Understanding the STP Election Process & How it Takes Place!


Redundancy in any network is necessary to provide a backup path if one link goes down, but it may also lead to a loop in a network and hence network congestion.   

Networks get configured with redundant paths. Although redundancy is a crucial aspect of network design, it may also lead to form a loop. The loop can occur when data travels from source to destination but gets stuck in a circle due to the redundant link provided. To avoid data looping, the Spanning Tree Protocol gets used.   

Spanning Tree Protocol (STP) works on Layer 2 of the OSI Model and prevents loops in network topology and prevents ethernet network loops while providing redundancy.   

Switches S1 and S2

Let us take an example of the above Network Topology.   

Switches S1 and S2 are connected via link 1.  

S3 is a redundant switch providing redundancy in a network.   

If the link between S1 and S2 goes down for any reason, Data can travel to S2 via S3.     

Suppose S1 sends data to S2 via link 1.   

Data will also travel to S3 via link 2, then to S2 via link 3, and again back to S1. 

Hence a loop is formed where data travels from S1 to S3 to S2 and again to S1.   

Hence in the absence of STP, there would be no redundancy. STP blocks some ports of switches with the help of STP election to prevent looping. The blocked port can enable itself when there is a change in topology or case of link failure and hence providing redundancy.   

NOTE: To understand how STP Election works, how the port is blocked, which port to block, and dive into the world of STP, we need to understand some basic terminologies and concepts used in Spanning Tree Protocol.   

What is Bridge ID?

Bridge ID is a combination of Bridge Priority and MAC Address which is unique for every switch. Bridge ID is a numerical value that ranges from 0 to 65535. 

MAC Address also called Media Access Control Address is a unique number assigned to the Network Interface Controller (NIC) of a device. It is a sort of Hardware address and is used at the data link layer. It is a 48-bit address.  

What is Root Bridge?

The switch with the lowest priority becomes a Root Bridge. If, in case, the priority of 2 or more than 2 switches is the same, then the switch with the lowest Bridge ID becomes Root Bridge.

What are Port Roles?

The port roles are as follows- 

  • Root Port – Root port is the port on the non-root switch. It is directly connected to the root bridge and provides the shortest path with the least cost to the root bridge.  

A non-root switch always has at least 1 root port.  

  • Designated Port – Designated port never blocks the traffic (Frames). The Port that connects the link having the least cost becomes Designated Port. The ports on the Root Bridge are always Designated Ports. But all the ports of the non-root bridge cannot be designated ports.   
  • Forwarding Port – These ports always forward Frames. Designated ports are in the state of forwarding port.  
  • Blocked Port – Blocked ports do not forward frames and help in preventing loops. It only listens to BPDUs. Any port other than the root port & designated port is a blocked port.

What are STP Timers?

3 types of STP timers help in loop prevention, namely- 

  • Hello Timer – The Hello Timer determines the interval at which the root bridge sends out STP Bridge Protocol Data Units (BPDUs). BPDUs are crucial for bridges to exchange information, establish the root bridge, and maintain the network’s topology. The Hello Timer is set to 2 seconds.  
  • Forward Delay – The Forward Delay represents the time it takes for a port to transition from the listening state to the learning state and finally to the forwarding state. During the Forward Delay period, a bridge listens for BPDUs to detect any changes in the network topology and ensure network stability. By default, the Forward Delay is set to 15 seconds.  
  • Maximum Age – Maximum Age is the maximum time allowed for a bridge to receive a BPDU before it considers the topology has changed. If a bridge does not receive a BPDU within the Max Age interval, it assumes that the root bridge or connectivity has been lost. The Max Age timer is to 20 seconds.  
  • Forwarding Delay – The Forwarding Delay signifies the time required for a port to transition from the blocking state to the forwarding state when a topology change occurs. It allows bridges to converge and stabilize the network after a topology change. The Forwarding Delay timer is 15 seconds.

What are Port States?

  • Disabled – It is the state where switches get connected for the very first time and hence, they are not forwarding any frames.  
  • Blocking – In this state, the port to do forwards any frames and discards if frames are received but listens and processes BPDU.   
  • Listening – After the Blocking state, the port enters the Listening state. In this state, the port still does not forward frames but actively listens to BPDUs. The port uses this time to learn about the network’s topology changes and prepares for the transition to the next state.  
  • Learning – In the Learning state, the port starts to learn MAC addresses by observing the source MAC addresses of received frames. It continues to listen to BPDUs and builds its MAC address table. However, it still does not forward frames during this state.  
  • Forwarding – The port comes to the forwarding state from the learning state and starts frame forwarding in a network. Port also processes the BPDU, and hence address table remains updated. 

What is BPDU?

BPDU also known as Bridge Protocol Data Unit is an essential component of the Spanning Tree Protocol. BPDU is a message transmitted by each switch which helps to exchange information about the network topology and hence helps in STP Election.   

There are two types of BPDU, namely- 

Configuration BPDU – This BPDU gets exchanged when switches are connected or enabled. It is the primary BPDU which includes information about network topology and some following important network information: –    

  • Root Bridge ID: – Bridge ID of the root bridge in a network.   
  • Bridge ID: – Includes Bridge priority and MAC ADDRESS.   
  • Path Cost: – Includes the cost of the path to travel the root bridge.   
  • Port roles: – Includes the roles assigned to each port such as root port, designated port, or blocked port. 

Topology Change Notification BPDU (TCN) – TCN is transmitted when there is any change in the topology of a network such as a link failure, the addition of a new switch, link recovery, etc. When a switch detects a change in a network, it generates TCN and broadcast it to a neighbouring switch. Another switch will respond according to the changes occurred in a network.   

For example: If a link goes down, Switches will reconverge the path to the backup link.   

Hence exchange of Configuration BPDU and TCN BPDU helps switches to maintain a loop-free path along with responding to changes in the network’s topology. The Multicast Destination MAC address used by BPDU is 01:80:C2:00:00:00.

Step-By-Step Guide to Understanding the STP Election Process

Let’s understand how the Spanning Tree Protocol election work and how and which port is blocked to prevent the looping of the network. 


Let’s take an example of the above topology. 

Switches S1, S2 and S3 have MAC ADDRESS: –,, respectively. 

The priority of all the 3 switches is 32768. (By default, Cisco Switches has priority set to 32768 but it can also be changed and configured manually). 

Steps involved in the (Spanning Tree Protocol) STP Election process: –  

1. Bridge Priority Determination: – 

When Switches are turned on, they will start sending Configuration BPDU containing Bridge ID, Cost to the Root Bridge, and STP Timers (Hello Timer, Max Age Timer, Forward Delay Timer) 

The bridge ID is 8 bytes. 
It is a combination of Bridge Priority and MAC ADDRESS. 

Bridge Priority and MAC ADDRESS

2. Root Bridge and Root Port Election: –  

Initially Every Switch consider itself to be a ROOT BRIDGE. When Switch receives BDPU with a lower Bridge ID (Superior BPDU), it will stop its configuration BPDU and start forwarding Superior BPDU to its neighbours. 

Bridge ID (Bridge Priority + MAC ADDRESS) starts with Priority hence Switches with a lower Priority value (Lower the Priority Value, Higher the Priority of the switch) become ROOT BRIDGE. 

Suppose the Priority of 2 or more switches is the same, the Switch with a Lower MAC ADDRESS becomes the ROOT BRIDGE. 

In our example, Switch has the same priority but the MAC ADDRESS OF S1 is lowest, hence it will become ROOT BRIDGE. 

Also, the ports on the ROOT BRIDGE become ROOT PORTS. 

ROOT PORTS never comes to a blocking state and always forwards the ethernet frames. 

These ports do not block traffic. 


3. Designated Port Election: –  

When the Root port Is elected, Designated ports are identified on the NON-ROOT BRIDGE. 

Designated ports are those which are connected via a link having the lowest cost to reach the root port of the root bridge. 

Costs are determined by the type of Link switches that are connected. Some default costs of links are given below: –  


Link Cost 

10 Mbps 


100 Mbps 






4. Blocking Port Election: –  

We now know how root ports and designated ports are elected. Let us now talk about how to select a port that will be blocked. 

Port connected via a link having the highest cost to reach the ROOT BRIDGE will be blocked and it will not transmit any ethernet frame unless a change in the topology takes place. 

CASE 1: -

All the links Connecting Switches have the same cost. 


In the above Topology, Switches are connected via a 1gbps link which has a cost equal to 4. 

The direct cost of Switch 2 to reach ROOT BRIDGE i.e., S1 is 4 and the indirect cost to reach Switch 1 is 8 

For S3 also, the direct cost to reach ROOT BRIDGE i.e., S1 is 4 and the indirect cost to reach Switch 1 is 8. 


Indirect and direct costs for both the switch are equal and hence there is a tie. 

In such cases where there is a tie between direct and indirect costs, the Election process again happens based on Bridge ID. 


Priority of S2 and S3 is equal but the MAC ADDRESS of S2 is lower i.e., 

And hence S2 wins the STP election and it will become Designated Switch on both the port of S2 will become Designated Port. 

Now the port on S3 will be blocked to avoid the loop. 

To decide which port will be blocked, the Cost of both the link to reach S1 i.e., Root Bridge is calculated again. 

The direct cost to reach S1 is 4 which is lower than the indirect cost 

Hence Port connected via a link that has a higher cost will be blocked. 


S1 becomes the Root bridge because the Bridge ID of S1 is the lowest 

S2 becomes a Designated Switch although the cost to reach S1 is the same but because its Bridge ID of it is lower than S3  
S3 has 1 port as the designated port while the other port is blocked. 

CASE 2: -

Links have different costs. 


S1 and S2 are connected with 100 Mbps link which has a cost equal to 19. 

S1 and S3 are connected with 1Gbps which has a cost equal to 4. 

S3 and S2 are connected with 100 Mbps link which has a cost equal to 19. 


The direct cost of S2 to reach S1 is 19. 

The direct cost of S3 to reach S1 is 4. 

Since the Direct cost of S3 is lower hence Ports on S3 will not be blocked and ports on it will become Designated Ports. 

The direct cost of S2 to reach S1 is 19 and the Indirect cost to reach S1 is 23 hence port that has a higher cost path will be blocked. 


In this way, by determining Root Bridge, Root Ports, Designated Ports, and Blocking Ports, the Spanning Tree Protocol creates a loop-free network. 

Traffic flows along the designated paths, ensuring redundancy and fault tolerance in the network.

Why port with a higher cost is blocked?

The higher the Speed of the link, Lower the cost, and vice versa. 

If a port with a higher speed is blocked, then the network will become slow and inefficient. 

Also, if a port with a higher speed is blocked, then there is no sense to invest in a higher-speed link which is also expensive.


As network engineers, our goal is to make network communication more efficient and hassle-free. 

Spanning Tree Protocol is one such protocol that helps to make a loop-free path and remove network congestion at the Data link layer (Layer 2). 

The concept behind blocking a port is to elect a ROOT BRIDGE first and then find the path which has the least cost to reach the ROOT BRIDGE. The port connected to a link with the higher total cost to reach the ROOT BRIDGE is blocked. 

The least cost implies the higher speed of the link and hence it is favourable to block the port with a lower speed (i.e., higher cost) to make the network faster. 

(Please note that the cost mentioned here does not signify the monetary cost but it is a parameter used to find the shortest path.)