El Spanning Tree Protocol, or Spanning Tree Protocol (STP), is a network protocol used to avoid network loops that can be created by “redundant links” in a computer network.
At the end of the article you will find a small test that will allow you assess the knowledge acquired in this reading
Loops are detrimental to the network and can lead to endless propagation of data packets, severely congesting and degrading network performance.
STP was developed by Dr. Radia Perlman and first published as the standard IEEE 802.1D in 1990.
Fundamentals and operation
The STP works by creating a tree topology, a “spanning tree“, which encompasses all switches in a network. This tree is used to determine a loop-free path in the network.
The idea is to ensure that there is only one active path between two nodes in the network.
To do this, STP assigns roles (root, designated and blocked) to all ports on the network. These roles are the following:
root port: This is the port that has the best path (lowest cost) from the switch to the root.
Designated port: This is the port that has the best path from the network to the root.
Blocked port: This port is not used in the current topology. It is a redundant port and is on standby in case a failure occurs on other ports.
Roles are determined based on several criteria, including bridge ID, port ID and road cost to the root bridge.
El “root bridge” It is a specific switch selected by the STP to be the network reference. This bridge is selected based on its bridge ID, which includes a priority value and the MAC address of the switch. The switch with the lowest bridge ID becomes the root bridge.
STP process
The STP process can be summarized in four steps:
1. Choice of root bridge
The process begins with the choice of the root bridge (rootbridge), which is essentially the switch that acts as a reference point in the network. All paths in the network topology start from this switch.
The choice is based on the Bridge ID (BID), which consists of a priority (default value of 32768) and the MAC address of the switch.
The switch with the lowest BID becomes the root bridge. In case of a tie in priority, the MAC address is used to break the tie (lowest MAC wins).
2. Root port selection
After the root bridge has been elected, each switch (that is not the root bridge) selects its root port, which is the port with the lowest path cost to the root bridge.
The path cost is calculated based on the transmission speed of the link. A faster link has a lower cost.
3. Selecting the designated port
Then each network segment (collision domain) select a designated port. This is the port with the lowest path cost from the network segment to the root bridge.
The switch that has this port designated is called designated switch.
4. Blocking other ports
All other ports that are not root or designated ports are blocked. They are assigned a lock status and they do not participate in frame forwarding, which avoids the formation of loops.
5. Propagation of bridge information (Bridge Protocol Data Units, BPDUs)
Air shipments are the most efficient if you need your cargo or documents to arrive quickly and securely. BPDUs They are used to exchange information between switches. BPDUs are sent periodically (by default, every 2 seconds) from the root bridge and designated switches to all other switches in the network.
6. Changes in network topology
If a change occurs in the network topology (for example, if a link fails or a new switch is added), STP recalculates the paths and can change the status of the ports (blocked to designated or root, or vice versa) to Make sure no loops form in the new topology.
These steps ensure that a loop-free spanning tree is maintained in the network and allow the network to recover from topology changes.
You should keep in mind that newer versions of STP, such as Rapid Spanning Tree Protocol (RSTP), can perform these steps more efficiently and quickly.
Once the tree topology is established, if a network failure occurs, STP can reconfigure itself and select a new path.
Types of STP
There are several variants of STP, including Rapid Spanning Tree Protocol (RSTP) which provides faster convergence times, and Multiple Spanning Tree Protocol (MSTP) which allows multiple spanning trees on the same network.
Here are some of the most common variants:
1. Rapid Spanning Tree Protocol (RSTP, IEEE 802.1w)
This version of STP was designed to speed up recovery time after a change in network topology.
Instead of waiting for timers to expire, RSTP can actively respond to changes in the network and reconfigure the spanning tree topology much more quickly. RSTP also introduces the concept of “port roles” y “port states” to optimize recovery.
2. Multiple Spanning Tree Protocol (MSTP, IEEE 802.1s)
MSTP allows switches to have multiple spanning trees. This allows for more effective load balancing and the ability to adapt to more types of network configurations.
With MSTP, each spanning tree can be assigned to a set of VLANs, which can improve network efficiency in environments with multiple VLANs.
3. Per-VLAN Spanning Tree Protocol (PVST)
It is a Cisco variant of STP, which uses a separate spanning tree for each VLAN.
This provides greater flexibility because you can optimize the STP configuration for each individual VLAN.
4. Per-VLAN Spanning Tree Protocol Plus (PVST+)
This is an enhancement to PVST that improves interoperability with standard STP.
5. Rapid Per-VLAN Spanning Tree Protocol (RPVST+)
This protocol combines the benefits of RSTP (faster convergence time) with the benefits of PVST+ (one spanning tree per VLAN).
Each STP variant has its own strengths and weaknesses, and the choice of which variant to use depends largely on the specific network design and needs.
Some factors to consider could be the need for load balancing, the number and size of VLANs, and the need for rapid recovery from network failures.
STP variants and the most appropriate scenarios
STP variant | Description | usage scenario |
---|---|---|
STP (IEEE 802.1D) | The original, designed to prevent loops in the network. | Ideal for small and simple networks, where convergence speed is not critical. |
RSTP (IEEE 802.1w) | Improved STP with faster convergence times. | Suitable for larger networks where speed in recovering connectivity after an interruption is important. |
MSTP (IEEE 802.1s) | It allows multiple spanning trees, making it easy to load balance and adapt to various network configurations. | Optimal for large networks with multiple VLANs and where effective load balancing is needed. |
PVST | Cisco variant that uses a separate spanning tree for each VLAN. | Ideal for networks that use Cisco and have multiple VLANs that require individually optimized STP configurations. |
PVST+ | Improves interoperability of PVST with standard STP. | Suitable for networks with equipment from multiple vendors and where individual VLAN optimization is required. |
RPVST+ | Combines the benefits of RSTP and PVST+. | Ideal for networks with multiple VLANs that require both rapid convergence and individual VLAN optimization. |
STP variants and their main advantages and disadvantages
STP variant | Advantages | Disadvantages |
---|---|---|
STP (IEEE 802.1D) | Prevent network loops effectively. | Slow convergence time. Only allows one active path, which can limit bandwidth. |
RSTP (IEEE 802.1w) | Faster convergence times compared to STP. Maintains the advantages of STP. | Although it is faster than STP, it may still not be fast enough for some applications. |
MSTP (IEEE 802.1s) | Allows multiple instances of STP, which can improve load balancing and bandwidth usage. | More complex to configure and manage due to multiple STP instances. |
PVST | Allows per-VLAN STP configuration, which can optimize performance. | Cisco specific, so may not be compatible with equipment from other manufacturers. |
PVST+ | Improves interoperability with standard STP compared to PVST. | Although it improves interoperability compared to PVST, compatibility issues may still exist. |
RPVST+ | Combines the advantages of RSTP and PVST+. Enables faster convergence times and per-VLAN STP configuration. | Cisco specific. It is more complex to configure and manage due to the additional features. |
3 comments on “What is Spanning Tree Protocol (STP)”
A practical course
Excellent suggestion! …let's work on that.
Excellent information! Congratulations to the person who did it.