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.
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.
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.
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.
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.
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.
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.
● 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.
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:
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 |
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.
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