Keeping data flow dependable and efficient is essential in modern networking. Spanning Tree Protocol (STP) ensures network stability and minimizes loops in redundant networks.
This protocol plays a vital role in large-scale networks, preventing broadcast storms, routing loops, and network failures caused by redundant links.
This article explains what is Spanning Tree Protocol? How it works with the help of an example and the different types of STP. We have also explained the configuration of Spanning Tree Protocol in 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) Explained: The Spanning Tree Protocol (STP) is a network protocol that ensures there are no loops in Ethernet networks. It was designed to operate in networks with redundant paths between network devices, such as switches.
Without STP, the existence of multiple active paths could result in broadcast storms and frame duplication, which could severely degrade network performance.
The spanning tree protocol in networking 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.
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.
STP uses five states to manage port activity and determine which links should forward traffic:
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.
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:
1. Selecting the Root Bridge
2. Selecting the Root Port
3. Selecting Designated and Non-Designated Ports
● Selecting the Root Bridge: The root bridge is the switch with the lowest Bridge ID (priority + MAC address). This switch serves as the central point for all network path calculations, and no port on the root bridge is blocked.
● Selecting the Root Port: Non-root bridges calculate the path cost to the root bridge. The port with the lowest cost is selected as the root port (the best forwarding path).
● Selecting Designated and Non-Designated Ports:
✓ Designated Ports: These ports forward traffic and have the best path to the root bridge.
✓ Non-Designated Ports: These ports are blocked to prevent loops, especially if the path cost is higher or the Bridge ID is greater.
By following these steps, STP ensures that the network remains loop-free, even in the presence of redundant links.
Also, Read About Port Numbers.
After learning the technical aspects of STP functioning, let's understand the working of Spanning Tree Protocol by looking at a simple example.
Imagine you have three switches: Switch A, Switch B, and Switch C, connected in a triangle. The Spanning Tree Protocol would work by:
First, it will decide the Root Bridge. The switch with the lowest Bridge ID becomes the Root Bridge. Let's say Switch A is elected as the Root Bridge.
Then each switch calculates the cost to reach the Root Bridge. Here, Switch B and Switch C will determine their path costs to Switch A.
After this, the Root Ports are selected, meaning Switch B and Switch C select their ports connected to Switch A as their Root Ports. In the end, to prevent loops, one of the ports between Switch B and Switch C is blocked.
As a result, a loop-free network is formed, with Switch A as the Root Bridge and one of the paths between Switch B and Switch C blocked.
● 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.
There are over six different types of STP protocols, each suited for various network scenarios. Let’s explore each:
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:
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.