Spanning Tree Protocol

Spanning Tree Protocol Visually

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.

Loop Prevention Loop Prevention Network Redundancy Switched Networks Root Bridge IEEE 802.1D

How Spanning Tree Protocol Works

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.

Forwarding Port
Blocking Port
Listening Port
Learning Port
Root Bridge

STP Port States

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.

STP Port State Transitions

1

Blocking State

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.

2

Listening State

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).

3

Learning State

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).

4

Forwarding State

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.

5

Disabled State

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.

Root Bridge Selection

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.

Root Bridge Selection Process

1

Bridge ID Comparison

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.

2

Priority Value Check

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.

3

MAC Address Tiebreaker

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.

4

BPDU Exchange

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.

STP Variants

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.

STP Variant Comparison

1

Spanning Tree Protocol (STP) - IEEE 802.1D

The original STP standard with five port states and slow convergence times (30-50 seconds). Uses a single spanning tree for the entire network.

Convergence: 30-50 seconds
Port States: 5
Trees: 1 per network
2

Rapid Spanning Tree Protocol (RSTP) - IEEE 802.1w

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.

Convergence: 3-6 seconds
Port States: 3
Port Roles: Root, Designated, Alternate, Backup
3

Multiple Spanning Tree Protocol (MSTP) - IEEE 802.1s

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.

Convergence: 3-6 seconds
Multiple Trees: Based on VLANs
Load Balancing: Yes

STP Configuration

STP can be configured and optimized through various parameters. Proper configuration ensures optimal network performance and redundancy while maintaining loop-free operation.

STP Configuration Steps

1

Root Bridge Selection

Configure the root bridge priority to ensure the most appropriate switch becomes the root. Example command: spanning-tree vlan 1 priority 4096

2

Port Cost Configuration

Adjust port costs to influence path selection. Lower costs are preferred. Example command: spanning-tree cost 10

3

Port Priority Configuration

Configure port priorities to influence designated port selection. Example command: spanning-tree port-priority 64

4

Timer Configuration

Adjust STP timers for optimal convergence. Example command: spanning-tree vlan 1 forward-time 10

Hello Time: 2 seconds (BPDU interval)
Forward Delay: 15 seconds (Listening + Learning)
Max Age: 20 seconds (BPDU timeout)