Definition – Spanning Tree Protocol (STP)
Spanning Tree Protocol (STP) is a network protocol standardized by IEEE 802.1D designed to prevent network loops in Ethernet networks. It creates a loop-free logical topology by selectively blocking certain redundant paths. STP works by electing a root bridge, which serves as the central reference point for all spanning tree calculations. Each switch in the network determines the shortest path to the root bridge and configures its ports accordingly.
Spanning Tree Protocol (STP) uses Bridge Protocol Data Units (BPDUs) to exchange information about network topology among switches. These BPDUs are used to identify the root bridge and to communicate path costs. Each switch designates one of its ports as the root port, which is the port with the lowest cost path to the root bridge. Other ports may become designated ports, forwarding ports, or blocked ports based on their role in maintaining a loop-free topology.
By dynamically adjusting to changes in the network, such as the addition or failure of links and switches, STP ensures continuous network availability and stability. It prevents broadcast storms and ensures that there is only one active path between any two network devices, enhancing the reliability and efficiency of Ethernet networks.

Differnet Stages of Spanning Tree Protocol
Spanning Tree Protocol (STP) operates in different stages as it converges and manages the network topology. These stages help ensure that the network remains loop-free and that traffic flows efficiently along the active paths. Here are the main stages of STP:
- Blocking State:
- In the blocking state, the port does not participate in frame forwarding, effectively blocking traffic from passing through it. This state is used to prevent loops in the network.
- Initially, all ports on each switch are in the blocking state until the spanning tree algorithm determines the topology and identifies the best paths.
- Ports in the blocking state still receive BPDU messages to maintain information about the network topology.
- Listening State:
- After the blocking state, a port transitions to the listening state. During this stage, the port prepares to participate in the spanning tree algorithm.
- Ports in the listening state start to forward and receive BPDU messages. They do not forward normal data frames during this stage.
- This state serves as a transitional phase to ensure that ports are synchronized with the rest of the network before becoming fully operational.
- Learning State:
- Once a port has spent the listening state duration and received sufficient BPDU messages, it transitions to the learning state.
- In the learning state, the port continues to participate in the spanning tree algorithm and can learn MAC addresses by observing source addresses of incoming frames.
- While in the learning state, the port does not yet forward data frames, but it does populate its MAC address table with the MAC addresses it learns from incoming frames.
- Forwarding State:
- The forwarding state is the final stage in which a port becomes fully operational for normal data forwarding.
- Ports in the forwarding state forward both BPDU messages and normal data frames.
- The forwarding state is achieved after a port has successfully passed through the blocking, listening, and learning stages and has determined that it is safe to forward traffic without causing loops in the network.
Summary
These stages ensure that the spanning tree algorithm converges to a loop-free topology and that network traffic flows efficiently along the active paths. When there are changes in the network topology, such as link failures or additions, ports may transition between these stages dynamically to adapt to the new topology and maintain network stability.
Useful Links
https://www.cisco.com/c/en/us/tech/lan-switching/spanning-tree-protocol/index.html
https://sanchitgurukul.com/switch
https://sanchitgurukul.com/tutorials-cat
