USD ($)
$
United States Dollar
India Rupee

STP in Networking | Full-Form, Uses and Configuration

Created by Gautam Kumar in Articles 27 Aug 2025
Share
«OSI Model in Computer Networks

The Spanning Tree Protocol (STP) plays a vital role in large-scale networks, preventing broadcast storms, routing loops, and network failures caused by redundant links.

In this article, we have explained about the spanning tree protocol and how it works. We have also covered different types of spanning tree protocol, along with its uses and configuration examples on Cisco Switches.

Further, if you want to learn the practical implementations and master the spanning tree protocol, enrolling in our online networking courses will provide you with most knowledge about the protocol.

What is Spanning Tree Protocol?

The Spanning Tree Protocol is a network protocol that ensures there are no loops in Ethernet networks with redundant paths between network devices, such as switches.

Without it, the existence of multiple active paths could result in broadcast storms and frame duplication, which could severely degrade network performance.

The spanning tree protocol uses an algorithm that dynamically chooses the most optimal path for data to travel, while blocking redundant paths to prevent loops. The protocol organizes network devices in a tree structure, hence the term "spanning tree." The root bridge, the central device in the network topology, serves as the starting point for this tree.

CCNA Online TrainingEnroll in online CCNA certification training course.Explore course
custom banner static image

Why is Spanning Tree Protocol Important?

Spanning Tree Protocol (STP) is important because it prevents loops in a network. In large networks with multiple switches, loops can cause data to circulate endlessly, slowing down or crashing the system.

STP helps by creating a single, loop-free path for data to travel, even if there are multiple connections. It automatically disables extra paths and reactivates them if the main path fails, keeping the network stable and reliable.

Spanning Tree Protocol Basic Concepts

Some important terms that you should know before learning about Spanning Tree Protocol (STP) are:

● Bridge: A network device (switch) that connects multiple LAN segments.

● Bridge ID: A unique identifier for each switch, combining the priority (2 bytes) and MAC address (6 bytes).

● Root Bridge: The switch with the lowest Bridge ID, serving as the central reference for path calculations.

● BPDU (Bridge Protocol Data Unit): Messages exchanged between switches to share network topology and determine the root bridge.

● Bridge Priority: A value used to determine the root bridge; default is 32768.

Spanning Tree Protocol Port States

Port states in STP define how a switch port behaves during the process of building a loop-free network topology. These states help in transitioning ports from inactive to active roles while preventing network loops.

There are 5 port states in the spanning tree protocol:

1. Blocking State: Ports do not forward frames and are kept blocked to prevent loops. Ports in this state stay blocked for 20 seconds before transitioning to the listening state.

2. Listening State: The protocol decides if the port can participate in forwarding frames. Ports remain in this state for 15 seconds before moving to the next state.

3. Learning State: STP begins learning MAC addresses and prepares the port for frame forwarding. During this time, the port does not forward frames but processes BPDUs.

4. Forwarding State: The port actively forwards frames and processes BPDUs. It stays in this state until a topology change occurs.

5. Disabled State: When manually disabled by an administrator, the port does not forward frames or learn addresses, and it doesn’t process BPDUs.

Now that you understand important terms and port states, let's look at the working process of Spanning Tree Protocol to understand how it ensures a loop-free path for data packets.

How Does Spanning Tree Protocol Work?

spanning tree protocol diagram

The Spanning Tree Protocol (STP) ensures a loop-free network topology by selecting optimal paths and blocking redundant links. It works in three key steps:

Step 1: BPDU Exchange Begins

All switches in the network start by sending Bridge Protocol Data Units (BPDUs). These special messages contain information like Bridge ID and path cost. BPDUs help switches discover the network topology and begin the process of electing the Root Bridge.

Step 2: Electing the Root Bridge

The switch with the lowest Bridge ID (priority + MAC address) is elected as the Root Bridge. This switch becomes the central reference point for all path calculations. All its ports are placed in the forwarding state, as it is the most trusted switch in the topology.

Step 3: Selecting Root Ports

Each non-root switch calculates the lowest-cost path to the Root Bridge. The port that offers this best path is selected as the Root Port. This port is used to forward traffic toward the Root Bridge and is always placed in the forwarding state.

Step 4: Selecting Designated Ports

On every network segment, the switch with the lowest path cost to the Root Bridge becomes the Designated Bridge, and its port on that segment is the Designated Port. These ports are responsible for forwarding traffic to and from that segment and are also set to forwarding state.

Step 5: Blocking Non-Designated Ports

Ports that are neither Root Ports nor Designated Ports are placed in the blocking state. These are called Non-Designated Ports and are used to prevent loops. They do not forward traffic unless a topology change occurs that requires them to become active.

Step 6: Port States and Transitions

STP ports transition through several states: Blocking → Listening → Learning → Forwarding. These states help ensure a stable network during topology changes. In the Learning state, switches build their MAC address tables, and in Forwarding, they begin to pass traffic.

Step 7: Convergence

Once all switches agree on the network topology, STP reaches convergence. Only the best paths remain active, and redundant links are safely blocked. If a link fails, STP recalculates the topology and reactivates blocked ports as needed, though this process can take up to 50 seconds in classic STP.

Also, Read About Port Numbers.

Types of Spanning Tree Protocol

The main types of spanning tree protocol used in computer networks are:

1. STP (Standard Spanning Tree Protocol): The original IEEE 802.1D protocol. It prevents loops but has slow convergence (30–50 seconds).

2. RSTP (Rapid Spanning Tree Protocol): Defined in IEEE 802.1w, it improves convergence time to a few seconds and is backward-compatible with STP.

3. MSTP (Multiple Spanning Tree Protocol): Defined in IEEE 802.1s, it allows multiple VLANs to be mapped to a single spanning tree instance, improving scalability and efficiency.

4. PVST (Per VLAN Spanning Tree): A Cisco proprietary version that runs a separate STP instance for each VLAN, allowing better load balancing.

5. RPVST+ (Rapid PVST+): Cisco’s enhancement of RSTP that supports per-VLAN rapid convergence.

Advantages of Spanning Tree Protocol

● STP eliminates loops in Ethernet networks, preventing broadcast storms and ensuring stable network performance.

● It enhances the overall reliability and uptime of the network.

● STP automatically reconfigures the network in case of link failures, maintaining network connectivity without manual intervention.

● It reduces the complexity of managing large networks by automatically handling redundant paths.

● STP allows for the addition of new switches and links without disrupting the existing network, making it easier to scale.

Disadvantages of Spanning Tree Protocol

● STP has slow convergence, often taking 30–50 seconds to recover from topology changes.

● Redundant links are blocked, leading to underutilized bandwidth.

● It doesn’t support load balancing across multiple paths.

● Troubleshooting STP issues can be complex in large networks.

● STP lacks built-in security, making it vulnerable to BPDU spoofing attacks.

RSTP vs STP: What are the Differences?

Spanning Tree Protocol (STP) and Rapid Spanning Tree Protocol (RSTP) are both used to prevent network loops and ensure a loop-free topology in Ethernet networks. However, RSTP offers several improvements over the traditional STP, making it faster and more efficient.

Below is a comparison of the two:


FeatureSTP (802.1D)RSTP (802.1w)
Convergence TimeSlow (30-50 seconds)Fast (1-10 seconds)
Port Roles5 roles3 roles
Port States5 states3 states
ReconfigurationSlower reconfigurationFaster reconfiguration
BPDU HandlingPeriodic BPDUsFrequent BPDUs, faster detection
CompatibilityOlder standard (802.1D)Backward compatible with STP (802.1w)
Link TypesAssumes point-to-pointDistinguishes point-to-point and shared
EfficiencyLess efficientMore efficient

Spanning Tree Protocol in Cisco Environments

Spanning tree in Cisco environments is often configured using Cisco’s proprietary variations of the standard STP. The Cisco STP protocol includes enhancements like PVST+, which allows for a separate STP instance per VLAN, leading to more efficient traffic management and redundancy.

In the Cisco STP protocol, the network administrator can fine-tune the protocol's operation using commands to assign priorities to switches, set path costs, and influence root bridge election. This level of control ensures optimal performance and redundancy in enterprise networks.

How to Configure Spanning Tree Protocol in Cisco Switches

In this section, we have covered basic commands related to STP configuration in Cisco Switches, like basic configuration of different STP protocols, verification, and disabling STP.

1. Basic STP Configuration

STP is enabled by default on Cisco switches. To check its status:


show spanning-tree

2. Selecting the Root Bridge

The root bridge is selected based on the lowest Bridge ID (priority + MAC address). To set the priority for a switch:


spanning-tree vlan 1 priority 12288

3. Configuring Per VLAN Spanning Tree (PVST+)

PVST+ allows separate STP instances for each VLAN:


spanning-tree vlan 10 priority 28672

4. Configuring Rapid Spanning Tree Protocol (RSTP)

To enable RSTP, which offers faster convergence:


spanning-tree mode rapid-pvst

Read our detailed guide on Rapid PVST+ Configuration in Cisco

5. Configuring Multiple Spanning Tree Protocol (MSTP)

MSTP enables multiple spanning tree instances:


spanning-tree mode mst

spanning-tree mst configuration

region-name MSTRegion

instance 1 vlan 10,20

6. Adjusting Port Roles and Path Costs

Adjusting the port path cost influences which path STP will select:


spanning-tree cost 19

To enable PortFast (for edge ports):


spanning-tree portfast

7. Disabling STP on a Port

To disable STP on a specific port:


spanning-tree bpdufilter enable

8. Verification

Use these commands to verify your STP configuration:


show spanning-tree

show spanning-tree vlan 1

show spanning-tree interface gigabitEthernet 1/0/1

Conclusion

The Spanning Tree Protocol is an essential part of modern networking, particularly in environments with redundant paths and multiple network devices. It ensures loop-free, stable, and resilient networks by dynamically blocking and unblocking paths as needed.

Understanding the spanning tree protocol in networking and the types of STP in networking is crucial for network administrators to maintain network reliability and performance.

Whether in a Cisco STP protocol environment or using a standard spanning tree protocol, STP provides the necessary failover and redundancy to keep networks running smoothly.

By leveraging protocols like RSTP, MSTP, and PVST+, businesses can further optimize their network topologies, ensuring both redundancy and efficient load distribution.

What is Quality of Service (QOS) in ...»
Gautam Kumar

Gautam Kumar is a senior network engineer having more than 7 years of experience in different companies in India. His work experience in network support and operation and maintaining of any network makes him one of the most valuable IT professional in industry. He has been involving in planning, supporting the physical and wireless networks, ...

More... | Author`s Bog | Book a Meeting

Related Articles

#Explore latest news and articles

IPv4 vs IPv6: What are the Differences? 9 Sep 2025

IPv4 vs IPv6: What are the Differences?

Explore the differences between IPv4 and IPv6 address. Compare both IP protocol versions and understand how they differ from each other.
What is Hot Standby Router Protocol (HSRP)? 25 Mar 2025

What is Hot Standby Router Protocol (HSRP)?

Discover the meaning of HSRP in networking. Learn how Hot Standby Router Protocol (HSRP) works, its benefits, and its configuration.
Top Network Security Interviews Questions with Answers 25 Aug 2025

Top Network Security Interviews Questions with Answers

Check out the frequently asked network security interview questions with the right answers. Also, read the tips for clearing any network security interview.

FAQ

The five STP stages are Blocking, Listening, Learning, Forwarding, and Disabled. Ports transition through these states to prevent loops, build MAC tables, and eventually forward data.
STP (Spanning Tree Protocol) prevents network loops by electing a root bridge and blocking redundant paths. It uses BPDUs to monitor topology changes and ensures a single active path for data transmission.
STP operates at the Data Link Layer (Layer 2) of the OSI model, managing Ethernet network topology to prevent loops and ensure stable communication.
RSTP introduces four port states: Discarding, Learning, Forwarding, and Backup. These states enhance efficiency compared to STP's slower transitions.
RSTP reduces convergence time to 5-10 seconds by allowing ports to directly enter forwarding states and using frequent BPDU exchanges for quicker topology updates compared to STP's timer-based transitions.
The principle of STP is to prevent network loops by creating a loop-free topology. It elects a root bridge, blocks redundant paths, and ensures stable communication between nodes

Comments (0)

Gautam Kumar

Gautam Kumar

Network Consultant & Full Time Instructor Instructor role
★★★★★ 4.94
Faithful User
Expert Vendor
Golden Classes
King Seller
Fantastic Support
Loyal Writer
+91 8383 96 16 46

Enquire Now

Captcha
Share to your friends

Share

Share this post with others

Contact learning advisor

Captcha image