Spanning Tree Protocol
Table of Contents
Spanning Tree Protocol
The Spanning Tree Protocol (STP) is a network protocol used to prevent loops in Ethernet networks by ensuring that there is only one active path between two network devices. When a loop is detected, STP automatically disables redundant links, ensuring a loop-free and efficient network structure.
It operates at the Data Link Layer
Diagram
@startuml title Spanning Tree Protocol (STP) [Switch 1] as Switch1 [Switch 2] as Switch2 [Switch 3] as Switch3 [Switch 4] as Switch4 Switch1 - Switch2 : Forwarding Switch1 - Switch3 : Forwarding Switch2 - Switch4 : Forwarding Switch3 - Switch4 : Blocked (Redundant Link) @enduml
Key Functions
- Loop Prevention: STP ensures that redundant paths in a network are disabled to avoid broadcast storms and network congestion.
- Root Bridge Selection: The protocol selects a single Switch (called the root bridge) as the central point for managing the active topology.
- Path Cost Calculation: STP calculates the most efficient path to the root bridge for each switch in the network, based on path cost, and designates it as the active link.
- Redundant Link Blocking: Links that are not part of the shortest path to the root bridge are placed in a "blocking" state to prevent loops.
- Dynamic Reconfiguration: In case the active path fails, STP automatically reconfigures the network to enable redundant links, ensuring minimal downtime.
STP States
- Switch ports in STP transition through several states to ensure loop-free operation:
- Blocking: The port does not forward frames and is waiting for the STP algorithm to complete.
- Listening: The port listens to STP messages to determine the network topology but doesn't forward frames.
- Learning: The port learns MAC addresses but still doesn't forward frames.
- Forwarding: The port forwards frames and is part of the active topology.
- Disabled: The port is administratively disabled and not participating in STP.
Types of Spanning Tree Protocols
- STP (802.1D): The original Spanning Tree Protocol standard.
- Rapid Spanning Tree Protocol (RSTP - 802.1w): An improvement over STP, providing faster convergence and recovery from network changes.
- Multiple Spanning Tree Protocol (MSTP - 802.1s): Allows multiple spanning trees to coexist on a network, supporting VLAN configurations.
Benefits of STP
- Prevents Network Loops: Ensures stable network operation by blocking redundant paths.
- Automatic Path Recovery: Automatically reroutes traffic if the primary link fails, maintaining network availability.
- Optimizes Traffic Flow: Ensures traffic follows the most efficient route based on path costs.
Limitations of STP
- Convergence Time: STP takes time to converge when changes occur, especially in the original 802.1D version, potentially leading to temporary network outages.
- Single Root Bridge: The root bridge becomes a single point of failure; if it fails, re-election takes time.