STP is a Layer 2 protocol that makes a loop-free network topology by blocking the redundant path.

STP elects the root bridge, and it will decide which port will be in forwarding and blocking state.

A switch that has the lowest bridge-id will become a root bridge.

Priority is a decimal number, ranging from 0-65535. By default, the priority is 32768.

What is BPDU (Bridge Protocol Data Unit)?

Root Bridge always generates a hello message after every 2 seconds called BPDU. It is used to elect a root bridge. Two types of BPDU are Configuration BPDU and TCN BPDU.

Port role in STP  

  • Designated Port      
  • Non-Designated Port
  • Alternate
  • Root port.

Note: – In a segment one port is DP and the other non-DP.

What is meant by Root port and Designated port?

A port that receives superior BPDU will become a root port. There can be only a single root port on Non-Root Bridge.

A port that transmits superior BPDU will become DP.

How to identify Superior BPDU?

  • Lowest Root Bridge-ID
  • Lowest Cost
  • Lowest Designated Bridge-ID
  • Lowest Designated Port-ID
  • Lowest Receiver Port-ID

Let us see how STP election take place: –

As the switch comes up, all switches start sending BPDU for the root bridge election. Switch which receives superior BPDU stops sending the BDPU message, but it relays the superior BPDU received at RP port from the DP port. Switch holds both superior and inferior BPDU for max-age time i.e., 20 seconds.

Here in the below diagram, SW1 is elected as Root Bridge as it has the lowest Bridge-ID. Root Bridge has all ports as Designated. Root bridge will decide which port will be forwarding and blocking state, thereby providing loop-free topology.

What are different STP states

  • Disable – When the switch port is down, it is in a disabled state.
  • Blocking – As the switch comes up, it makes it port in a blocking state to end any loop in the network.
  • Listening – In this state root bridge election takes place along with DP, RP, and Alternate port.
  • Learning – In this state switch remain for 15 seconds only DP and RP move to the forwarding state and the port learns the mac address but will not forward data traffic.
  • Forwarding – In this state, DP and RP ports are ready to forward data traffic.

NOTE: – Forward Delay Time = 15 sec i.e., switch remain for 15 seconds in Listening state and for 15 seconds in Learning state.

Let us see for example how DP, RP, and Alternate Port are elected?

Example 1: –

Switch 1 has Bridge-ID 32768+OA and Switch 2 has Bridge-ID 32768+OB. Priority is checked first which is equal by default and then the lowest mac address. Here SW1 is elected as Root Bridge.

All ports of SW1 will be DP as it will send superior BPDU and e1 port of SW2 will RP as it receives superior BPDU and e0 of SW2 will be Alternate port. Both ports of SW2 receive BPDU with the same root bridge-id, same cost, same designated bridge-id but e1 of SW2 receive with lowest Designated Port-ID. (Designated Port-ID means sender port-id).


Here SW1 is the root bridge that will generate superior BPDU. SW2 e1 port will be RP and e2 will be Alternate Port. Both the ports will receive BPDU with the same root bridge-id, same cost, same designated bridge-id, same designated port-id but based on lowest receiver port-id e1 of SW2 will become RP.

IEEE has a predefined cost: –

  • Ethernet = 100
  • Fast Ethernet =19
  • 1 Gigabit = 4
  • 10 Gigabit =2

NOTE: – This cost is directly related to speed, if we decrease fast Ethernet speed to 10Mbps it will have cost 100. Root Bridge always generates zero cost BPDU and on the receiving BPDU, the cost is added.

In the next blog, we are going to explain what different topologies change and how STP convergence time can be minimized.

Zindagi Technologies is an IT consulting company having engineers with decades of experience in planning, designing, and implementing Data Centers along with Managed IT Services, cybersecurity, cloud services. If you want to secure your network, we are just a call away. Please ping us on +91-9773973971 or you can also email us.

Jainul Khan
Associate Consultant

Leave a comment