Skip to content

Per VLAN Spanning Tree demonstration

Spanning Tree

In computer networks, STP plays a crucial role in maintaining a loop-free and efficient communication path. By preventing redundant links and loops, STP ensures stable and reliable network connectivity. This blog post aims to provide a comprehensive explanation of the Spanning Tree Protocol, its key features, and its significance in network infrastructure.

The Spanning Tree Protocol is a network protocol designed to prevent loops and redundant paths in Ethernet networks. It enables the creation of a loop-free logical topology by selectively blocking redundant links while maintaining alternative paths to ensure network resilience.

STP process

  1. Electing the Root Bridge
    STP establishes a Root Bridge, which serves as the reference point for all other network switches. The Root Bridge is chosen based on criteria such as the lowest bridge ID or the lowest MAC address.
  2. Bridge Protocol Data Unit
    STP uses Bridge Protocol Data Units to exchange information between switches. BPDUs contain vital details such as Bridge IDs, port costs, and information about neighboring switches
  3. Determining the Best Path
    Each switch calculates the shortest path to reach the Root Bridge based on the accumulated costs of its ports. This calculation considers factors like link speeds and bandwidth. The path with the lowest cost becomes the designated path, while the others are put into a blocked state to prevent loops.
  4. Port Roles
    STP defines different port roles for switches, including Root Port, which is a port on non-root switch with lowest port cost leading to root bridge. Designated Port provides the best path to reach a specific segment again, based on port cost. Blocking Port is in a blocked state to prevent loops which is elected based in lowest priority.

There is a difference between port state and role. The port state refers to the operational state of a port in STP, indicating whether it is active, inactive, or transitioning between states. On the other hand, the port role defines the specific function or responsibility that a port assumes within the spanning tree topology, such as being a:

  • Root Port
  • Designated Port
  • Blocking Port

STP port states


Result of an administrative command that will disable the port. Disabled port state in STP indicates that a port is inactive and not participating in the spanning tree operation. It allows network administrators to manually disable ports or isolate segments of the network as needed.


When a device is connected, the port will first enter the blocking state. Max 20 seconds transition time starts before it moves to Listening state. The port is listening to BPDUs, but it does not forward any network traffic. It is in this state to prevent loops and ensure a loop-free topology. The port still participates in the STP calculations and convergence processes. If there is a breakdown or link failure on LAN or reconfiguration, since this state is listening for STP frames, it can get elected as root or designated port after going through transmission.


The switch will listen for and send its own BPDUs and does not forward any regular network traffic and does that for 15 seconds.


The switch will receive a superior BPDU, will stop sending its own BPDUs. Transition lasts for 15 seconds.


Final port state, that is forwarding traffic. From this state, port can transfer into blocking state which is immediate. Each switch in this state is associated with role designated or root port.


In this demonstration we have three Layer 3 switches Cisco 3640. We don’t need layer 3 switches for STP demonstration since it is layer 2 but I didn’t find any other free switch GNS3 image so we will be using only layer 2 functionalities. When STP gets enabled, switches tend to at first elect themselves as root bridge. When they exchange BPDUs with priority number, they find out who is going to be a root bridge.

This time I configured PVST. S1 as root bridge for VLAN 5 and S2 as root bridge for VLAN 10, both with priority ID 1. The S3 has the lowest bridge ID because of the MAC address that is combined with the BID therefore its port f0/1 for VLAN 10 is in blocking state and for VLAN 5 the f0/0 interface is in blocking state.

Images below illustrating PVST for both VLANs in their root bridges. As you can see the associated VLANs for each STP has allocated ports and they are in forwarding STP role.

The image on the left side indicates STP for VLAN 5 on S3. As you can see the port Fast Ethernet 0/0 is in blocking state because the S3 has lower MAC address which is a tie breaker because the BID for VLAN 10 on S1 and S3 is the same.

The STP port priority with the allocated port number is used if there are more links between switches. In this scenario we are using only one path between switches therefore in this demonstration we don’t need port priority.