In Chapter 2, we’re diving into the Spanning Tree Protocol (STP), an essential topic for maintaining a loop-free Layer 2 network topology. STP is a protocol designed to prevent switching loops in a network with redundant paths, which can lead to broadcast storms, multiple frame copies, and MAC table instability. Let’s go over the fundamentals and explore Rapid Spanning Tree Protocol (RSTP) as well!
🔗 What is Spanning Tree Protocol (STP)?
The Spanning Tree Protocol (STP), defined in IEEE 802.1D, is used to ensure a loop-free network by selectively blocking redundant paths. STP performs this by designating certain switch ports as active or in standby mode. This process helps prevent broadcast storms and keeps your network running smoothly.
🧩 Key Components of STP
To fully understand how STP operates, let’s go over some key terms and components.
The following are some common scenarios for Layer 2 forwarding loops:
- STP disabled on a switch
- A misconfigured load balancer that transmits traffic out multiple ports with the same MACaddress
- A misconfigured virtual switch that bridges two physical ports (Virtual switches typically do not
- participate in STP.)
- End users using a dumb network switch or hub
STP Key Terminology
- Root Bridge 🌲: The central switch in an STP topology. All switches in the network select one Root Bridge, which serves as a reference point for all path calculations. The switch with the lowest Bridge ID becomes the Root Bridge.
- Bridge ID 🆔: A unique identifier that each switch has, comprising a priority value and the MAC address. The switch with the lowest Bridge ID becomes the Root Bridge.
- Path Cost 💰: A value assigned to each port to determine the shortest path to the Root Bridge. Lower path costs are preferred.
- Root Port (RP) 🔌: The port on a non-root switch with the lowest path cost to the Root Bridge. Each non-root switch has one Root Port, which points towards the Root Bridge.
- Designated Port (DP) 🚦: The port on each segment that has the lowest path cost to the Root Bridge. The DP is responsible for forwarding traffic toward and away from the Root Bridge.
- Blocking Port 🚧: Ports that do not forward traffic and remain in a standby state to prevent loops. Only the Root Port and Designated Ports are active in a loop-free topology.
802.1D Port Types
STP defines several port roles based on the topology:
- Root Port (RP): Points to the Root Bridge and forwards traffic.
- Designated Port (DP): Forwards traffic for each segment.
- Alternate Port: Acts as a backup port for the Root Port in case of failure.
- Blocking Port: Blocks traffic to prevent loops.
🌲 STP Operation and Processes
- One root bridge per network
- One root port Per bridge
- One Designated port per segment
Root Bridge Election
In a network with multiple switches, STP selects one switch as the Root Bridge by comparing Bridge IDs. The switch with the lowest priority (and in the event of a tie, the lowest MAC address) becomes the Root Bridge. This election process ensures that all switches agree on a central reference point.
Locating Root Ports
After the Root Bridge is elected, each non-root switch determines its Root Port. The Root Port is the port that has the shortest path to the Root Bridge, based on path cost. If there is a tie in cost, switches break the tie based on the lowest Bridge ID of the neighboring switch or the lowest port number.
Cost calculation
STP Topology Changes
STP constantly monitors the network topology. If a link fails, STP recalculates the best path to the Root Bridge, making necessary adjustments to port states. However, classic STP can be slow to respond to changes, with convergence times around 30–50 seconds. To address this limitation, Rapid Spanning Tree Protocol (RSTP) was introduced.
🚀 Rapid Spanning Tree Protocol (RSTP) – IEEE 802.1W
Rapid Spanning Tree Protocol (RSTP) is an evolution of STP that significantly improves convergence time, allowing the network to recover from topology changes in less than a second. RSTP, defined in IEEE 802.1W, introduces new port roles and states, making it faster and more efficient.
RSTP Port Roles
In addition to the original STP port types, RSTP introduces:
- Alternate Port: Serves as a backup to the Root Port. If the Root Port fails, the Alternate Port quickly takes over.
- Backup Port: Functions as a backup to the Designated Port on a shared segment.
RSTP Port States (802.1W)
RSTP simplifies the port states from STP:
- Discarding 🚫: The port does not forward frames or learn MAC addresses, similar to the Blocking state in STP.
- Learning 📘: The port learns MAC addresses but does not forward frames. This is the transition state before forwarding.
- Forwarding 🔄: The port forwards frames and learns MAC addresses. This is the active state for data traffic.
Note: RSTP eliminates the need for the Listening state in STP, which improves convergence time significantly.
RSTP Topology Changes
RSTP detects topology changes faster by leveraging its new port roles and states. For example:
- RSTP immediately places a Root Port or Designated Port into the Forwarding state when it recognizes the port as operational.
- The Alternate Port and Backup Port ensure rapid failover, allowing traffic to resume with minimal disruption.
🧩 Building the RSTP Topology
When building a Rapid Spanning Tree Protocol (RSTP) topology, the network elects a Root Bridge and calculates the shortest paths, similar to standard STP. However, with RSTP’s improved convergence mechanisms, network recovery is much faster. RSTP provides a near-instantaneous response to topology changes, making it ideal for modern enterprise networks where downtime is critical.
📋 Key Takeaways
- STP and RSTP: STP (802.1D) prevents loops by blocking redundant paths, but RSTP (802.1W) enhances convergence, making networks more resilient to changes.
- Root Bridge Election: The Root Bridge serves as the center of the STP topology. The switch with the lowest Bridge ID is elected as the Root Bridge.
- STP and RSTP Port Types: STP uses Root, Designated, and Blocking ports, while RSTP adds Alternate and Backup ports for faster convergence.
- Port States: STP has Listening, Learning, and Forwarding states, while RSTP streamlines these to Discarding, Learning, and Forwarding, reducing convergence time.
- Loop Prevention: By carefully managing port states and types, STP and RSTP prevent loops, which are crucial for a stable and efficient network.