How Spanning Tree Protocol Works – Easiest Guide available.

We hope you are enjoying the series of CCNA/NP Articles written on our website, this are ones of the easiest guides available on the Internet and we are encouraging offline reading as well, there is an option below each article to Save and Download it as a PDF file.

Today we are going to speak about on of the most important protocol on the Layer 2 of the OSI Reference Model, The Spanning Tree Protocol, a link management protocol, which is defined in IEEE 802.1D.

Before we go ahead with the understanding of the STP protocol, we need to know the basic functionality of the Layer 2 devices for eg. Switches.


The functions of an Ethernet LAN switch includes

  • Address learning
    Whenever a frame is received on an interface of a switch remembers and stores its MAC Adress into its database.
  • Address filtering
    Frames are send only to the Port where it is destined to, preserves the bandwidth and it is called frame filtering
  • Forwarding of frames
    Looking at the MAC Address the Frame is forwarded to the respective ports, if the entry for that particular MAC Address is not available in the table it forwards it to all port expect from where it originated
  • Loop avoidance
    Multiple switches are connected for redundancy purposes, network loops or broadcasts storms may occur and eat up the entire bandwidth of the network.

To avoid Broadcast Storms and get the switch to saturate, we use some kind of the mechanism to prevent loops to be formed one of the best used system is the STP or the Spanning tree Protocol

Basically, Spanning Tree finds all the links in the network and shuts down the redundant ones which prevents from occurrences of network loop.

STP does this by electing a ROOT BRIDGE, a reference point for all other devices on the network.

By default the bridge with the lowest Bridge ID is chosen as the Root. The Bridge ID is a 64-bit field made up of the priority (the default is 32768) and the MAC address.

For example, if switches A (MAC=0200.0000.1111) and B (MAC=0200.0000.2222) both have a priority of 10, then switch A will be selected as the root bridge. If the network administrators would like switch B to become the root bridge, they must set its priority to be less than 10.

If the default priority has not been changed then Root will be chosen based on the lowest MAC address. The Root Bridge then sends Bridge Protocol Data Units (BPDUs) out all of its designated (forwarding) ports. If a bridge is not the Root (called a Non-Root Bridge), it will receive regular BPDU on the port that is closest to the Root, called the Root Port, all other ports which are not designated ports will be blocked

In the above network diagram, The top switch is selected as a root since it has the lowest MAC ID (1111.2222.1111), now the Root Bridge sends BPDUs using the out ports FA0/1 and FA0/2 (its designated ports). Switch A receives the BPDU on root port FA0/3 and then sends a BPDU out of port FA0/4. Likewise, Switch B receives a BPDU on root port FA0/6 and sends a BPDU out on port FA0/5. Both Switch A and Switch B have received BPDUs on two different ports. This clearly shows that there is a loop in the network. Since each non-root switch can have only one root port, the loop is identified by the BPDUs on the non-root ports showing a longer distance to the root, indicating that the link must not be used for user frames.

Now, how these distance are measured? The cost of a path is the sum of the costs of the segments on the path. Different technologies have different default costs for network segments. Network administrators can configure the cost of traversing a particular network segment manually as well.

Before considering which ports will be blocked here are few things to keep in mind when learning Spanning Tree

  • Each non-Root Bridge needs a Root Port (a forwarding port).
  • The Root Port is the port that is closest to the Root Bridge in terms of Cost.
  • The port that is farthest away from the Root Bridge will be blocked, i.e. having the highest cost.
  • In the case of a tie, the switch with the highest Bridge ID (BID) will be blocked.

In this case, Switch A’s Root Port would be port Fa0/3, and Switch B’s Root Port would be Fa0/6. Assuming that ALL links are 100 Mbps, Switch A’s path back to the root from Fa0/4 is equal to the path from FA0/5 of Switch B back to the root. Because the path would be equal, the tie breaker will be the MAC address.

The MAC address of Switch B’s port FA0/5 is higher than Switch A’s MAC address for port Fa0/4; therefore, Switch B will block port
Fa0/5. That would make FA0/4 on Switch A a Designated (forwarding) Port.

Data Rate and STP Path cost

Different States of Ports of a Switch in a Spanning Tree organization

There are 5 Stages a port of a Switch in the Spanning Tree Architecture.

  • Blocking

    A blocking port won’t forward frames, it may only listen to BPDUs which are moving around, By default, all port are in blocking state when the switch is powered on. Doesn’t forward Frames.

  • Listening

    The port listens to BPDU to make sure no loops occur on the network before passing the data frames. Doesn’t forward Frames.

  • Learning

    Switch Port listens to BPDU and learns all the paths in the Switched Network. Doesn’t forward Frames.
  • Forwarding

    The port sends and receives all data frames on a bridge port. It learns addresses and Forwards frames
  • Disabled

    It is a non-operational state of a port, it doesn’t participate nor forwards a frame when in this state. It doesn’t even listent o BPDUs

Spanning Tree Overview

  • There can only be one Root Bridge.
  • Root-Bridge ports are called ‘Designated’ and are set to send and receive traffic (forwarding state). All other redundant links to the root bridge are shutdown.
  • Blocked ports still receive BPDUs.
  • Convergence occurs when switches have transitioned to either forwarding or blocking states. No other data is forwarded during this time.
  • Forward delay – Time taken for a switch to go from Listening to Learning (50 seconds default).
  • IEEE default priority = 32,768, this is true for all devices running STP IEEE version, used in CISCO Switches as well
  • Port Fast Mode – Immediately brings a port from blocking to forwarding state by eliminating forward delays.
  • Bridges can only have one spanning tree instance compared to switches which can have many.
  • Bridge Protocol Data Units send confirmation messages using multicast frames.

We have this has been a very informational post, you can now save this as a PDF for offline reading and sharing purposes. Below is the link to save it as PDF

The DNetWorks Team