
Server Room, Network and Switching
Introduction:
Spanning tree protocols are used in Layer 2 networks to prevent loops and ensure that there is only one active path between two devices. The most widely used spanning tree protocols are Spanning Tree Protocol (STP), Rapid Spanning Tree Protocol (RSTP), and Multiple Spanning Tree (MST). In this article, we will discuss the history, IEEE standards, use cases, features, and benefits of each of these protocols, as well as the pros and cons of each.
Spanning Tree Protocol (STP)
STP is the original spanning tree protocol, first defined in IEEE 802.1D. It was developed to prevent loops in a network by identifying and disabling links that would cause a loop. STP works by electing a “root bridge” and then determining the best path to the root bridge for each device on the network. The best path is determined by comparing the “bridge ID” of each device, which is a combination of the device’s MAC address and a configurable “priority” value.
STP has been widely adopted and is the most widely used spanning tree protocol. However, it has a number of limitations, including slow convergence in the event of a topology change, and the inability to handle multiple VLANs on a single physical topology.
Rapid Spanning Tree Protocol (RSTP)
RSTP was developed as an evolution of STP, and it is defined in IEEE 802.1w. It provides faster convergence in the event of a topology change and eliminates the need for the complex “root bridge” election process used by STP. RSTP also introduced the concept of “edge ports” and “point-to-point links,” which allow for faster convergence.
RSTP is backward-compatible with STP and can coexist with it on the same network. However, it still does not support multiple VLANs on a single physical topology.
Multiple Spanning Tree (MST)
MST is a variation of the Spanning Tree Protocol (STP) that allows for multiple VLANs to share a single physical topology while still maintaining loop-free paths. MST allows for multiple logical topologies to exist on a single physical topology, allowing for more efficient use of network resources and improved scalability.
MST regions are created by grouping a set of VLANs together and treating them as a single entity when running the Spanning Tree Protocol. This allows for multiple instances of STP to run simultaneously, with each instance managing a different set of VLANs.
MST is an IEEE standard, and it is defined in IEEE 802.1s, while the version supported by Cisco Systems is MSTP (Cisco proprietary).

Use Cases:
- STP is useful in environments where there is a need to prevent loops in a network, and where there is only one VLAN.
- RSTP is useful in environments where there is a need for faster convergence in the event of a topology change, and where there is only one VLAN.
- MST is useful in environments where there is a need to prevent loops in a network, and where there are multiple VLANs on a single physical topology.
Features and Benefits:
Spanning Tree Protocol (STP)
- Prevents loops in a network by identifying and disabling links that would cause a loop
- Provides a single active path between two devices
- Widely adopted and supported
- Simple and easy to understand and implement
- Low overhead
Rapid Spanning Tree Protocol (RSTP)
- Provides faster convergence in the event of a topology change
- Eliminates the need for the complex “root bridge” election process used by STP
- Introduces the concept of “edge ports” and “point-to-point links” for faster convergence
- Backward-compatible with STP
- Improves network stability and availability
Multiple Spanning Tree (MST)
- Allows for multiple VLANs to share a single physical topology while still maintaining loop-free paths
- Allows for multiple logical topologies to exist on a single physical topology
- Improves scalability and resource utilization
- Provides more granular control over the network
- Increases security by isolating different VLANs
It’s important to note that while all of these protocols help to prevent loops and provide a single active path, each protocol has its own unique features and benefits. It’s also important to consider the specific requirements of your network when choosing which protocol to use.

A Deeper Dive into the terms used in Spanning Tree
Edge Ports:
An edge port is a term used in the Rapid Spanning Tree Protocol (RSTP) to refer to a port that is connected to a single end station or a switch. Edge ports are used to connect devices such as servers, workstations, and printers to the network.
In RSTP, edge ports are assumed to be connected to a single device and are not expected to participate in the formation of loops. As a result, RSTP can transition edge ports to the forwarding state much faster than non-edge ports. This results in faster convergence in the event of a topology change and improved network stability.
Edge ports are identified by the switch and are configured in such a way that they transition to the forwarding state faster than non-edge ports. This is done by disabling the listening and learning states of an edge port, and skipping the listening and learning state.
It’s important to note that edge ports are different than “root ports” or “designated ports” which are used to forward traffic to the root bridge in STP and RSTP. Edge ports are used to connect end devices to the network and do not participate in the formation of loops.
BPDU, BPDU Guard and BPDU Filter
A Bridge Protocol Data Unit (BPDU) is a data packet that is used by the Spanning Tree Protocol (STP) and Rapid Spanning Tree Protocol (RSTP) to exchange information between switches in a network. BPDUs are used to elect a root bridge, determine the best path to the root bridge, and detect and prevent loops in the network.
BPDU Guard is a feature that is used to protect against malicious or accidental misconfigurations on a network. It works by monitoring BPDUs on a port and disabling the port if it receives a BPDU when it is not expected to. This helps to prevent loops from forming on the network.
BPDU guard can be enabled on a per-port basis, and is typically used on edge ports, which are ports that connect to end devices such as servers, workstations, and printers. When BPDU guard is enabled on an edge port, the port is put into a “errdisable” state if it receives a BPDU, this way it is protected from loops and bridging loops.
It is important to note that BPDU guard is a security feature that can be used to prevent accidental or malicious loops in the network, it is not a replacement for STP or RSTP, but it works as a complement of those protocols.
BPDU Filtering
BPDU Filtering is a feature that is used to prevent the flooding of Bridge Protocol Data Units (BPDUs) on a network. BPDUs are packets that are used by the Spanning Tree Protocol (STP) and Rapid Spanning Tree Protocol (RSTP) to exchange information between switches in a network. BPDUs are used to elect a root bridge, determine the best path to the root bridge, and detect and prevent loops in the network.
When BPDU filtering is enabled on a switch, it will stop forwarding BPDUs on certain ports, typically on access ports that connect to end devices such as servers, workstations, and printers. This helps to reduce the amount of unnecessary BPDU traffic on the network, and also reduces the risk of loops forming on the network.
BPDU filtering can be enabled on a per-port basis, and it is typically used on edge ports. By default, BPDU filtering is disabled on most switches. It is important to note that BPDU filtering should only be enabled on ports that do not participate in the formation of loops, such as access ports. It is not recommended to enable BPDU filtering on ports that are used to connect switches together, as it can prevent the switches from properly exchanging BPDU information and can lead to network instability.
Spanning Tree Root
The “root” refers to the bridge (switch) that is at the top of the spanning tree hierarchy. This bridge is responsible for forwarding traffic and making decisions about the topology of the network. All other bridges in the network will base their forwarding decisions on the information they receive from the root bridge. The root bridge is elected by the bridges in the network through the exchange of Bridge Protocol Data Units (BPDUs). The bridge with the lowest Bridge ID, which is a combination of the bridge’s priority and MAC address, is elected as the root bridge.
Spanning Tree Root Guard
Root guard is a feature in Spanning Tree Protocol (STP) that is used to prevent other bridges from becoming the root bridge. It is used to enforce the position of a specific bridge as the root bridge in a network. When root guard is enabled on a port, the port will be placed into a “root-inconsistent” state if it receives a superior BPDU (Bridge Protocol Data Unit) from another bridge. This means that the port will be blocked, preventing it from forwarding traffic, until the superior BPDU is no longer received. This ensures that the designated root bridge remains the root bridge and prevents loops from occurring in the network.
It can be used to protect the root bridge of a specific VLAN or a specific port in a network, to prevent an unauthorized bridge to become the root bridge. Root guard is typically used to protect the root bridge of a network from being replaced by a rogue bridge or switch that is connected to the network.
Spanning Tree Port Cost and Priority
Spanning Tree Protocol (STP) uses the concept of port cost and port priority to determine the best path for forwarding traffic in a network.
- Port Cost: The port cost is a value assigned to each port that is used to determine the best path to the root bridge. The cost is based on the bandwidth of the link and the lower the cost, the better the path. In general, faster links are assigned lower costs than slower links. The lower the cost of the port, the more likely it is to be chosen as the designated port.
- Port Priority: The port priority is a value assigned to each port that is used to determine which port will be chosen as the designated port in the event of a tie in the port cost. The lower the value of the priority, the higher the priority of the port. The port with the lowest priority will be chosen as the designated port.
When a switch receives a BPDU (Bridge Protocol Data Unit) from another switch, it compares the information in the BPDU to its own information to determine the best path to the root bridge. It looks at the cost to the root bridge, as well as the priority of the sender and the port on which the BPDU was received. The switch will then select the port with the lowest cost and priority as the designated port for forwarding traffic to the root bridge. If there is a tie in the cost and priority, the switch will use the MAC address of the sender to break the tie.

Summary
Spanning Tree Protocol (STP) is a networking protocol that is used to prevent loops in a network by creating a logical tree-like structure. It uses the concept of port cost and port priority to determine the best path for forwarding traffic in a network. While STP is a standard protocol, it can be slow in convergence and may not be suitable for large networks.
Rapid Spanning Tree Protocol (RSTP) is a faster version of STP that improves convergence time by using a new set of port states and eliminating the need for the aging process. RSTP is backward compatible with STP and can be used in networks where STP is already in use.
Multiple Spanning Tree Protocol (MSTP) is an extension of RSTP that allows for multiple instances of the spanning tree to be run on the same physical topology. This allows for more efficient use of network resources and improved scalability for large networks. MSTP creates multiple instances of the spanning tree, each one for a specific VLAN. This allows for different VLANs to use different paths through the network, improving network performance.
In conclusion, Spanning Tree Protocol is a widely used protocol in networking to prevent loops and it’s variants RSTP and MSTP are faster and more scalable alternatives for large and complex networks. They provide improved convergence time and better scalability. It is important to choose the right variant of STP based on the specific needs of the network, and to configure and monitor the STP properly to ensure a stable and efficient network.