Spanning Tree Protocol (STP) is a critical Layer 2 technology used in switched networks to prevent loops and ensure a loop-free topology. This section will explain the basic operations of spanning tree protocol including root bridge selection, port roles, port states, and Port Fast behaviour.
Introduction
In computer networks, multiple paths exist between switches and bridges to make them more reliable. But too many paths can cause problems like network loops and broadcast storms, which can slow down or even crash the network.
To solve this issue, networks use the Spanning Tree Protocol (STP). STP is a Layer 2 protocol that helps prevent loops while keeping backup paths ready.
What is Spanning Tree Protocol?
Spanning Tree Protocol (STP) is a Layer 2 network protocol designed to prevent loops in a network topology. It was created to solve problems that can occur when devices communicate over redundant links in a Local Area Network (LAN). Without STP, data can get trapped in a loop, circulating endlessly between switches. This can slow down the network, reduce performance, or even bring traffic to a complete halt.
You may have noticed that when switches are first connected, the status of the link on the switch ports often show an orange or amber light, which changes to green after 15–30 seconds. This is because of STP is calculating the best loop-free path before allowing full traffic flow.
How Spanning Tree Protocol (STP) Works
Spanning Tree Protocol (STP) uses Bridge Protocol Data Units (BPDUs) to exchange network information between switches to prevent loops in a network by creating a single, loop-free path between switches.
Switches exchange BPDUs (Bridge Protocol Data Units) containing information like: MAC address, Priority number and Port numbers. This information plays a very crucial role in the entire operation of STP.
STP operation involves three main steps for loop prevention and best path selection:
- Selection of Root Bridge
- Selecting of the Root Port
- Selection of Designated and Non-Designated Ports

Step 1: Selection of Root Bridge
- The root bridge is the central switch in the network and serves as a reference point for all path calculations.
- Each switch has a Bridge ID (BID), which is a combination of priority + MAC address.
- Default priority on most switches is 32768.
- The switch with the lowest BID becomes the root bridge.
- During the selection process, if the proitoy of bioth the switch are same
- All switches use the root bridge to calculate the shortest path to it.
Step 2: Selection of the Root Port
- Each non-root switch chooses a root port, having lowest cost path to reach the root bridge.
- All the root ports are placed in forwarding states and the best path is selected by adding the individual path cost from the non-root switch to root bridge.
- When the two or more best path cost becomes equal, tie brakers are used to decide the best path using the following conditions: lowest neighbour bridge ID, lowest neighbour port priority and lowest internal port neighbour.
The following are the cost value of different speeds of Ethernet Interface.
| Speed | Cost |
| 10 Mbps | 100 |
| 100 Mbps | 19 |
| 1 Gbps | 4 |
| 10 Gbps | 2 |
Step 3: Selection of the Designated and Non-Designated Ports
- There can be only one root port on a switch, while there can be multiple designated port in that switch.
- The designated port is selected on the basis of lowest path cast to root bridge on a particular LAN segment.
- Remember, a designated port can never be root port.
- The spanning tree algorithm selects one end of the switch port as designated port that is always in forwarding state and the other end of the port as non-designated port.
- The non-designated port is kept in blocking state, to avoid switching loop.
- This ensures that there is only one active path between any two devices by blocking redundant path.
- The designated and the non-designated ports are also selected on the basis of lowest path cost. If path cost ties, lowest switch port ID is taken as the tie breaker.
Different STP States of Switch Port
Suring STP operations, switch port transitions to different states. During theses states, switches running STP learns network topology, selects root port, designated and non-designated ports and blocks redundant ports to avoid swithcing loops.
- Blocking State: Initially, switch does not enable its ports immediately. It keeps them in blocking state for 20 seconds. During this period, it only listens to BPDU frames. BPDU contains information regarding bridge ID, port ID, hello timings, max age and frame delay. After 20 seconds, root port and designated port move to the next STP state, while all other ports continue to remain in the blocking state to prevent loops.
- Listening State: During this state, the port checks the network topology and ensures that root port and designated ports are assigned and not causing any switching loops. It lasts for 15 seconds and during this period, it does not lean mac address and doesn’t process any user frames. It only listens and forwards BPDU.
- Learning State: During this STP state, switch pot starts learning incoming user frames and makes entry of source mac address in the mac address (CAM) table. It remains in this state for 15 seconds but doesn’t forward frames.
- Forwarding State: In this state, switch pot processes incoming frames and starts forwarding and receiving both user frames and BPDU. Only the root port and the designated ports reach the forwarding state, while all other ports disabled by STP. It is also called convergence process.
Types of Spanning Tree Protocol (STP)
Spanning Tree Protocol (STP) is essential for preventing loops in Layer 2 networks. Over time, several versions and types of STP have been developed to improve network efficiency and convergence speed.
Here are the main types of STP you should know:
- STP (Standard Spanning Tree Protocol)
- The original STP standard is defined by IEEE 802.1D
- Slower convergence: It takes 30–50 seconds to detect and fix network changes
- It operates per switch and blocks redundant paths to prevent loops
- Uses listening, learning, forwarding, and blocking port states
- Mainly used in older networks
- RSTP (Rapid Spanning Tree Protocol)
- It is defined by IEEE 802.1w
- It is the Faster version of STP
- Converges is faster than standard STP.
- It simplifies port states (only forwarding and blocking for most ports)
- RSTP provides rapid recovery in case of link failure
- Compatible with standard STP
- MSTP (Multiple Spanning Tree Protocol) –
- MSTP is define by IEEE 802.1s
- It allows multiple VLANs to share a single STP instance
- It maps VLANs into spanning tree instances for efficiency
- It reduces CPU load and improves network performance
- Commonly used in large enterprise networks
- PVST+ (Per VLAN Spanning Tree Plus) – Cisco Proprietary
- It is Cisco’s proprietary STP version
- It runs one STP instance per VLAN
- Compatible with standard STP for interoperability
- It allows different root bridges for each VLAN, improving traffic load balancing
- Rapid PVST+ – Cisco Proprietary
- It combines the features of PVST+ and RSTP
- It runs rapid STP per VLAN for faster convergence
- It improves network stability and redundancy
- Commonly used in modern Cisco networks
Quick Comparison Table
| Type | Convergence Time | VLAN Support | Standard/Proprietary |
|---|---|---|---|
| STP (802.1D) | 30–50 sec | No | Standard |
| RSTP (802.1w) | ~1–10 sec | No | Standard |
| MSTP (802.1s) | Fast | Multiple VLANs | Standard |
| PVST+ | Slow | Per VLAN | Cisco Proprietary |
| Rapid PVST+ | Fast | Per VLAN | Cisco Proprietary |
STP Verification Commands
| Command | Purpose |
|---|---|
show spanning-tree | Displays STP topology |
show spanning-tree root | Shows root bridge info |
show spanning-tree vlan 1 | Per-VLAN STP details |
show spanning-tree interface f0/1 | Port-specific STP info |
show spanning-tree detail | In-depth STP information |
Output Example:
Switch# show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol rstp
Root ID Priority 32769
Address 0050.0f12.3456
Cost 4
Port 1 (FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 0050.0f12.7890
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- ------------------------
Fa0/1 Root FWD 4 128.1 P2p
Fa0/2 Altn BLK 4 128.2 P2p
What is PortFast
- During STP operation, when a switch port comes up, it normally goes through the blocking, listening, and learning states before reaching the forwarding state, which can take up to 30–50 seconds. This timing covers all the processes like selection of root brioge, root port and designate ports.
- To skip these time consuming STP states and move directly to the forwarding state as soon as the link becomes active, you can use the feature of PortFast allows a switch port to transition from blocking to the forwarding state immediately. The feature of PortFast is Cisco Proprietary extension to 802.1d standard.
- The PortFast can be implemented only when the port is connected to an end device and not to another switch, because end devices do not create network loops.
- PortFast improves network performance by reducing delays, especially for devices like computers that expect immediate network access.
- However, if PortFast is mistakenly enabled on a port connected to another switch, it can cause network loops, which is why it is commonly used together with BPDU Guard for protection.
Conclusion
Spanning Tree Protocol (STP) plays a vital role in maintaining a loop-free and stable Ethernet network by intelligently managing redundant links between switches.
Through the exchange of Bridge Protocol Data Units (BPDUs), STP elects a Root Bridge, calculates the best paths to reach it, and assigns appropriate port roles and states such as root, designated, and blocked ports. By temporarily blocking certain links while keeping backup paths available, STP prevents problems like broadcast storms and MAC table instability without sacrificing network redundancy.
Although the convergence process in traditional STP can be slow, its fundamental operation ensures reliable network performance and forms the foundation for faster protocols like RSTP and MSTP. Overall, STP remains a core networking concept essential for designing safe, efficient, and resilient switched networks.








