The purpose of the STP, standardized as IEEE 802.1d, is to prevent loops in bridged or switched networks with redundant links. Bridges or switch ports configured for STP are in one of five different states: blocking, listening, learning, forwarding, and disabled.
Blocking— The port will not send or receive any data traffic across the network segment, but will listen to STP BPDU messages. When a switch or bridge running STP is powered on, all ports are in a blocking state. The port is in the blocking state for 20 seconds before transitioning to the listening state.
Listening— The port is listening to spanning-tree messages in the form of BPDUs and is determining how the network topology is configured. While in the listening state, the port is not forwarding frames. The port is in the listening state for 15 seconds before transitioning to the learning state.
Learning— The port is adding MAC addresses to its MAC address table. While in the learning state, the port is not forwarding frames. The port is in the learning state for 15 seconds before transitioning to the forwarding state.
Forwarding— The port is sending and receiving data across the network segment as normal, and after the network has converged on a topology, the port will be in either the forwarding or blocking state.
Disabled— The port can be administratively disabled at any time by the network administrator and will not receive BPDUs or forward traffic across any network segments. The switch cannot put a port into the disabled state and therefore cannot take a port out of the disabled state; only the network administrator can enable or disable a port. Port does not receive anything!!! Unless turned back on.
The calculation of a spanning-tree topology is a three-step process, and on completion of these three steps the network is loop free. The three steps are as follows:
Step 1. Elect a root bridge lowest (bridge priority/mac address or BID). Each device calculates the best path to the root bridge using port cost.
Step 2. Elect a root port on each nonroot bridge.(roots are never up by the leaves!)
The root bridge is the bridge that is continuously sending network topology information to other bridges in the network. Using the STP, the root bridge notifies all other bridges on the network when topology changes are required. The root bridge should be located centrally in the network to provide the shortest path to other links on the network, and unlike other bridges, the root bridge always forwards frames out all of its ports.