Learn about the Spanning Tree Protocol through interactive visualizations. Understand how STP prevents network loops, selects root bridges, and manages port states to ensure a loop-free logical topology.
STP operates by exchanging Bridge Protocol Data Units (BPDU) between switches to determine the network topology. The protocol elects a root bridge and calculates the shortest path to it from each switch. Ports are then placed in specific states to prevent loops while maintaining redundancy.
STP defines five port states that determine how a port behaves in the spanning tree. Each state has specific characteristics and transitions to the next state based on timers and network conditions.
In this state, the port discards frames received from the network segment and does not forward frames to the network segment. It listens for BPDUs to check if the switch is the root or designated bridge. This state prevents loops.
In this state, the port prepares to forward frames and participates in the spanning tree algorithm. It listens for BPDUs to determine the network topology and discards user frames. This state lasts for the forward delay timer (15 seconds).
In this state, the port continues to participate in the spanning tree algorithm and learns MAC addresses from incoming frames. It still discards user frames but builds the MAC address table. This state also lasts for the forward delay timer (15 seconds).
In this state, the port forwards frames and learns MAC addresses. It is fully functional and participates in normal frame forwarding operations. This is the desired state for active ports in the spanning tree.
In this state, the port is administratively shut down and does not participate in frame forwarding or the spanning tree algorithm. This state is not part of the normal STP operation but is used when a port is manually disabled.
The root bridge is the central reference point in the spanning tree. All path calculations are made with respect to the root bridge. The selection process is based on bridge priority and MAC address.
Each switch has a unique Bridge ID consisting of a priority value (0-65535) and the switch's MAC address. The switch with the lowest Bridge ID becomes the root bridge.
The priority value is the first comparison factor. Lower priority values are preferred. The default priority is 32768. Administrators can change this value to influence root selection.
If two switches have the same priority, the switch with the lower MAC address becomes the root bridge. This ensures deterministic root bridge selection in case of priority ties.
Switches exchange BPDUs containing their Bridge IDs. Each switch compares the received Bridge IDs with its own. The switch with the lowest Bridge ID declares itself as the root.
Several enhanced versions of STP have been developed to improve convergence time and network efficiency. These variants maintain the core loop prevention functionality while introducing optimizations.
The original STP standard with five port states and slow convergence times (30-50 seconds). Uses a single spanning tree for the entire network.
An enhanced version of STP with faster convergence (3-6 seconds). Introduces new port roles and reduces port states to three. Backward compatible with STP.
Allows multiple spanning trees to be created based on VLANs. Provides better load balancing and faster convergence. MSTP is backward compatible with both STP and RSTP.
STP can be configured and optimized through various parameters. Proper configuration ensures optimal network performance and redundancy while maintaining loop-free operation.
Configure the root bridge priority to ensure the most appropriate switch becomes the root.
Example command:
spanning-tree vlan 1 priority 4096
Adjust port costs to influence path selection. Lower costs are preferred. Example command:
spanning-tree cost 10
Configure port priorities to influence designated port selection. Example command:
spanning-tree port-priority 64
Adjust STP timers for optimal convergence. Example command:
spanning-tree vlan 1 forward-time 10