STP stands for Spanning Tree Protocol. It is a network protocol that prevents loops in Ethernet networks with redundant paths. Without STP, multiple active paths can cause broadcast storms and duplicate frames, slowing or crashing the network. It selects the best path for data and blocks extra links, organizing devices into a tree-like structure. This ensures stable, loop-free communication in large-scale networks with multiple switches.
In this article, we have explained the Spanning Tree Protocol (STP), its features, working, and uses. We have also covered different types of spanning tree protocol, and an STP configuration example 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.
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.
It 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.

1. Loop Prevention: STP eliminates network loops by blocking redundant paths, ensuring stable and efficient data transmission.
2. Dynamic Path Selection: Uses an algorithm to select the best path for data and automatically reconfigures if a link fails.
3. Root Bridge Election: Organizes switches into a tree structure with a central device (root bridge) as the starting point for all paths.
4. Redundancy Handling: Keeps backup links in a blocked state, activating them only when the primary path fails.
5. Standardized Protocol: Defined by IEEE 802.1D, ensuring compatibility across different networking devices.
● 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; the default is 32768.
Port states in STP define how a switch port behaves during the process of building a loop-free network topology. It helps 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: In this 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: In this 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: In this 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: In this state, the port actively forwards frames and processes BPDUs. It stays in this state until a topology change occurs.
5. Disabled State: In this state, when manually disabled by an administrator, the port does not forward frames or learn addresses, and it doesn’t process BPDUs.
The Spanning Tree Protocol (STP) works by selecting optimal paths and blocking redundant links in seven 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.
.png)
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.
1. CST (Common Spanning Tree): Uses a single spanning tree for the entire network, even if multiple VLANs exist. Simple but less efficient for large networks.
2. PVST (Per-VLAN Spanning Tree): Creates a separate spanning tree for each VLAN, allowing better load balancing and optimized paths for different VLANs.
3. RSTP (Rapid Spanning Tree Protocol): An improved version of STP that converges much faster, reducing downtime during topology changes.
4. MSTP (Multiple Spanning Tree Protocol): Groups multiple VLANs into a few spanning trees, balancing efficiency and scalability for complex networks.
| Feature | STP (802.1D) | RSTP (802.1w) |
|---|---|---|
| Convergence Time | Slow (30-50 seconds) | Fast (1-10 seconds) |
| Port Roles | 5 roles | 3 roles |
| Port States | 5 states | 3 states |
| Reconfiguration | Slower reconfiguration | Faster reconfiguration |
| BPDU Handling | Periodic BPDUs | Frequent BPDUs, faster detection |
| Compatibility | Older standard (802.1D) | Backward compatible with STP (802.1w) |
| Link Types | Assumes point-to-point | Distinguishes point-to-point and shared |
| Efficiency | Less efficient | More efficient |
● 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.
● 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.
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:
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:
3. Configuring Per-VLAN Spanning Tree (PVST+)
PVST+ allows separate STP instances for each VLAN:
4. Configuring Rapid Spanning Tree Protocol (RSTP)
To enable RSTP, which offers faster convergence:
Read our detailed guide on Rapid PVST+ Configuration in Cisco
5. Configuring Multiple Spanning Tree Protocol (MSTP)
MSTP enables multiple spanning tree instances:
6. Adjusting Port Roles and Path Costs
Adjusting the port path cost influences which path STP will select:
To enable PortFast (for edge ports):
7. Disabling STP on a Port
To disable STP on a specific port:
8. Verification
Use these commands to verify your STP configuration:
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.
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