Spanning-tree protocol Notes with Interview Questions

spanning-tree protocol (STP)

What is Spanning tree ?
spanning-tree protocol  is a protocol used in switching network to create a loop-free topology. STP is enabled by default on all VLANs on Catalyst switches. STP switches send BPDU’s (Bridge Protocol Data Units) to each other to form their topology databases. BPDU’s are sent out all ports every two seconds, are forwarded to a specific MAC multicast address: 0180.c200.0000.

What causes a loop in a switched network?

When two switches connected via a single cable there will be no loops in switching network.Below topology is a example

Loops occur when we add redundancy to avoid single point failure(means connecting two switches via two or more cable to give back up in the case of a failure to one of the link).When a loop is introduced into the network, a highly destructive broadcast storm can develop within seconds and it will slow down or block off all other traffic.

Lets see how loop happening in below topology

  1. Computer A which is connected to switch A sends an ARP request because it’s looking for the MAC address of a computer connected to switch B. An ARP request is a broadcast frame. 
  2. Switch A will forward this broadcast frame on all it interfaces, except the link where the frame originated from. 
  3. Switch B will receive both broadcast frames from switch A
  4. Switch B will forward it out of every link except the interface where it originated from. 
  5. This means that the frame that was received on Interface fa0/1 will be forwarded on Interface fa0/2. 
  6. The frame that was received on Interface fa0/2 will be forwarded on Interface fa0/1.
So a loop will occur in the network.Both switches will keep forwarding over and over unitl we disconnect one of the cable or switch will crash due to overburden traffic

So how STP block or prevent loop ?
STP enabled switch will block port if a loop exist and blocked port will be activated again if needed.Check below topology
The STP Process
To maintain a loop-free environment, STP performs the following functions:
•  A Root Bridge is elected
•  Root Ports are identified
•  Designated Ports are identified
•  If a loop exists, a port is placed in Blocking state. If the loop is removed the blocked port is activated again. 

If multiple loops exist in the switching environment, multiple ports will be placed in a blocking state

Switches exchange BPDU’s to perform the election process. By default, all switches “believe” they are the Root Bridge, until a switch with a lower Bridge ID is discovered. Root Bridge elections are a continuous process. If a new switch with a lower Bridge ID is added to the topology, it will be elected as the new Root Bridge.

Electing an STP Root Bridge
First STP has to elect a root bridge from the network.The root bridge is the switch with the lowest bridge identifier(Bridge-ID)

Bridge Identifier = Bridge priority + MAC Address

In normal case bridge priority will be same for all switches (ie 32768 by default).Range of bridge priority is from 0 - 65535.As all switches having same priority,Switches having lowest MAC address in the network will be elected as "ROOT Bridge".One thing we must keep in mind is that, latest switches always having higher MAC address than old switches.So normally oldest switch in your network or datacenter might be elected as Root bridge instead of new switch.To avoid this we can change default bridge priority of switches.

We can elect Root bridge manually by two method.

The spanning-tree vlan root primary command is the first one
Switch(config)#spanning-tree vlan <Vlan Number> root primary
spanning-tree vlan priority command is the second one
Switch(config)#spanning-tree vlan <Vlan number> priority 4096
Commands used in Spanning tree 
Switch#show spanning-tree
Switch#show spanning-tree summary
Switch#debug spanning-tree
Switch#debug spanning-tree events 

NOTE : We know default bridge priority is 32768.But in real environment,when you type command "show spanning-tree" you may see like below

Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)

The sys-id-ext value that you see is the VLAN number. The priority is 32768 but spanning-tree will add the VLAN number 1 so we end up with priority value 32769( 32768+ 1 ).if its for VLAN 10 it may be like 32778 (32768 +10)

Interfaces that forward traffic are called designated ports in spanning-tree. On a root bridge the interfaces are always in forwarding mode because the non-root switches will need to find the root bridge.
Identifying Root Ports 
After finding the root bridge,All other switches in the network(non-root bridges) have to find the shortest path to the root bridge.This shortest path to root bridge is find out by calculating path cost.Always lowest path cost is better.Path cost of a Gigabit interface is less than a fast Ethernet link.So STP will choose a Gigabit link over fast Ethernet. The interface that leads to the root bridge is called the root port.

Root port always forward traffic to the root bridge Each switch has only one Root Port, and the Root Bridge cannot have a Root Port.

Spanning-tree uses cost to determine the shortest path to the root bridge. The slower the interface, the higher the cost is. The path with the lowest cost will be used to reach the root bridge.Below is the cost table

10 Mbit
100 Mbit
1000 Mbit

Identifying Designated Ports 
The third and final step in the STP process is to identify Designated Ports. Each network segment requires a single Designated Port, which has the lowest path cost leading to the Root Bridge. This port will not be placed in a blocking state. A port cannot be both a Designated Port and a Root Port. Ports on the Root Bridge are never placed in a blocking state and always designated ports
Port ID 
In certain circumstances, a tie will occur in both Path Cost and Bridge ID.Consider the following example:
If the bandwidth of both links are equal, then both of Switch 2’s interfaces have an equal path cost to the Root Bridge. Which interface will become the Root Port? The tiebreaker should be the lowest Bridge ID, but that cannot be used in this circumstance  

In this circumstance, Port ID will be used as the tiebreaker. An interface’s Port ID consists of two parts - a 6-bit port priority value, and the MAC address for that port. Whichever interface has the lowest Port ID will become the Root Port. 

By default, the port priority of an interface is 128. Lowering this value will ensure a specific interface becomes the Root Port:  
Switch(config)#  int fa0/22
Switch(config-if)#  spanning-tree port-priority 60
 Remember, that port priority is the last tiebreaker STP will consider. STP decides Root and Designated Ports based on the following criteria, and in this order:

•  Lowest Path Cost to the Root Bridge
•  Lowest Bridge ID
•  Lowest Port ID 

Consider the below example
For simplicity the MAC of switches is taken as below

MAC of Switch A : AAA
MAC of Switch B : BBB
MAC of Switch C : CCC

Identifying Root bridge
In the above example priority of all switches are default (32768).So we have to look at the lowest MAC address to find the root bridge.Switch A having the lowest Mac address among all and elected as Root Bridge.We know all ports of Root bridge will be designated ports(Forwarding state) and represented by D

Identifying Root Ports
Fa 0/14 of switch B and Fa 0/14 of switch C are the Root port here because they are the shortest path to reach Root Bridge.

Identifying the designated ports
Now we have to find which port have to designated and which port have to be blocked between Switch B and Switch C.As we know the switch having lowest MAC Address will be the designated port here and other switch will be in blocked state.Here Switch B has lowest MAC address than Switch C.So Fa 0/16 of switch B become designated port and Fa 0/16 of switch C will be alternative port(Blocked Port)

Points to remember

  • STP is also called IEEE 802.1D
  • STP is used to avoid loops
  • Ethernet has no capacity for detecting loops.If a loop exist,broadcast storm will appear
  • STP prevents loop formation by detecting redundant links and disabling them until needed.
  • STP is enabled by default in switches
  • STP works by selecting a switch in the network as a root bridge
  • A STP network must select
    • One root bridge
    • One root port per non-root bridge
    • One designated port per network segment
  • Designated port (DP) : All ports in root bridge must be DP.All designated ports will be in forwarding state
  • Root Port (RP) : Root port is the port in the non-root bridge that connects the best path to root bridge
  • Blocked port (BP) : Such ports will be in blocked will receive informations from Designated ports but will not send any information through it
  • One end of every link must be designated port.Other end may be Blocked Port OR Root Port

Interview Questions 
  1. What is Spanning tree aka STP ?
  2. How does STP maintain a loop-free network?
  3. What parameters can be tuned to influence the selection of a port as a Root or Designated Port?
  4. What is BDPU ?what is the basics function of BPDU?
  5. Using the default STP timers, how long does it take for a port to move from the Blocking state to the Forwarding state?
  6. What is the STP listening state?
  7. Which command enables RSTP on a switch?
  8. what is Per-VLAN Spanning Tree Protocol (PVST)
  9. What is the default bridge priority in a Bridge ID for all Cisco switches?
  10. Which STP version run default on cisco switches ?
  11. What is the purpose of Spanning Tree Protocol in a switched LAN?
  12. Difference between Spanning Tree Protocol (STP) and Rapid Spanning Tree Protocol (RSTP)?
  13. What is the STP blocking state?
  14. What is the STP Forwarding state?
  15. Difference between Root Port and Designated Port?
  16. What is the difference between path cost and root path cost?
  17. What is the difference between STP, MSTP, PVST and RSTP?
  18.  What is path cost?
  19. Define selection criteria of STP root bridge.
  20. What are the four spanning tree port states?
  21. How to non bridge decide which port will elect as root port?
  22. If a nonroot bridge has two redundant ports with the same root path cost, how does the bridge choose which port will be the root port?
  23. Port states of spanning tree protocol.
  24. If the users face delay during initial login, what you will suggest to implement?
  25. Why spanning tree BPDU filter is used?
  26. Can I use BPDU filter on trunk ports?
  27. Which port state is introduced by Rapid-PVST?
  28. What is Spanning Tree Protocol (STP) PortFast?
  29. What does STP do when it detects a topology change in the network due to a bridge or link failure?

Did You Enjoy this Article ?

If yes, Then enter your email below to get
more articles on CCNA and CCNP in your inbox
For FREE !


  1. Nice ... long Ways to go ... Manick

  2. Its awesome shabeer.

    Thanks for the post.

  3. Nice Post Shabber.

    Simple illustrative.

    Good Work!!!

  4. excellent notes ,it simple

  5. Thank You, Simple and informative :)

  6. hi shabeer, ur blogging is excellect and this article is very informative.
    i thnk there is some typing mistake in point no 10, under "Points to Remember" heading


  7. Oh brother thank you so much for this article specially the portion at the last in which you put some question which could be asked from us in interview.

  8. Excellent post. Simple and informative.