Spanning-Tree Protocol ( STP )

STP is a layer 2 loop prevention mechanism. Switches using STP use frames called Bridge Protocol Data Unit (BPDU). this allow the switch to create a loop free environment .
Spanning Tree Protocol, Rapid STP port costs and port states are an essential part of the STP algorithm that affect how STP decides to forward or block a port leading to the Root Bridge.

Bridge ID
is the combination of the bridge priority  ( 4 bits  ) + System ID Extention ( 12 bits ) ( vlan number  ) = the Bridge ID  example : Last bit = 32768 + vlan 1 = 32769 + MAC ADDRESS

Root Bridge: A switch with all its ports placed in Forwarding state is a root bridge
Root Port: For a non–root switch, the port that connects this switch to the root switch, with the least cost, is called the root port.
Designated Port: A non – root port, which is forwarding away from the root switch, and has the lowest cost in that Ethernet segment, is called the designated port

STP uses the following criteria to decide whether to place a port in a Forwarding state or Blocking state

  1. STP elects a Root Bridge, and then puts all its working interfaces in a Forwarding state
  2. All other switches are now non–root switches. STP now looks at all the Root Ports from these switches, and finds the one with theLeast Cost. Once this is found, STP places that interface in a Forwarding state.
  3. Now STP finds all the Designated ports on the non–root switches, and places them in a Forwarding state.
  4. Then STP places all other ports in a Blocking state.

The Election for the Root Bridge is done by finding the switch with the lowest BID , Switches sends BPDU Hello with both BID and Root BID and compare with its own BID if its higher then its own it discard the BPDU hello , if it is lower it change the value of the ROOT BID the the new value .

Timer values
Hello Timer ( 2 sec by default)
Max Age ( 10x the hello time sec by default )
Forward Delay ( 15 sec by default )

STP port state
Disable , Blocking , Listening , Learning , Forwarding

RSTP port state
Discarding , Learning , Forwarding

Timer values
Hello Timer ( 2 sec by default)
Max Age ( 3x the hello time sec by default )
Forward Delay ( 15 sec by default )


in a quick word : Disable , Blocking and Listening are replace by Discarding in RSTP  . This is done for faster convergence when a topology change happen .
BPDU’s come from all switches with RSTP whereas with STP it come from the root down to the switches. (these states  do not forward Ethernet frames and they do not learn MAC addresses)

Exmaple :
STP default convergence is so if a port goes into block state mode it stay for 20 sec ( default hello x 10 ) then move to listening state ( 15 sec ) then learning state ( 15 sec ) for a total of 50 sec

RSTP default convergence : there is no more blocking listening and disable , so the max age is 3x the hello ( 6 sec ) then learning state ( 15 sec ) so a tottal of 21 sec .



Leave a Comment