Because STP is involved in loop detection, many people refer to the catastrophic loops as “Spanning Tree loops.” This is technically incorrect because the Spanning Tree Protocol’s entire function is to prevent bridging loops. The correct terminology for this condition is a bridging loop.
Spanning-tree operates as switches communicate with on another. Data messages are exchanged in the form of bridge protocol data units (BPDU). A switch sends a BPDU frame out a port using the unique MAC address of the port itself as a source address. BPDUs frames are sent with a destination address of the well-known STP multicast address of 01-80-c2-00-00-00
BPDUs from DL-1 – Frame Format
The exchange of BPDU messages work toward the goal of electing reference points as a foundation for a stable STP. Loops can be identified and removed by placing specific redundant ports in a blocking or standby state.
By default BPDUs are sent out all switch ports every 2 seconds so that currently topology information is exchanged and loops are identified quickly.
Ports start in the disable state moving through several “passive” states then into an “active” state if it is allowed to forward data.
Disabled – ports are manually shutdown or in a fault state. This state is NOT part of the normal STP process.
Blocking – after a port is in the up state it begins blocking so that no bridging loops can form. In the blocking state, a port CANNOT receive or transmit data and CANNOT add MAC addresses to its address table. The port is only allowed to “receive” BPDUs so that the switch and hear/learn form other switches.
Listening – The port is moved from blocking to listening if the switch believes that the port can be selected as a root port or designated port. The port is looking to transition into a forwarding state if possible.
In the listening state the port still CANNOT send or receive data frames. The port is ONLY allowed to receive and send BPDUs so that it can actively participate in the spanning-tree protocol . The port is finally allowed to become a root or designated port because the switch can advertise the port by sending BPDUs to other switches. If the port loses its root or designated port status it returns to the blocking state.
Learning – After a period of time called the “forwarding delay” in the listening state, the port is allowed to move into the learning state. The port still sends and receives BPDUs as before. In addition, the port can now learn new MAC addresses to add to its address table. The port cannot yet send any data frames.
Forward – After another “forwarding delay” period of time in the learning state the port is allowed to move into the forwarding state. The port CAN NOW send and receive data frames, collect MAC addresses in its address table and send and and receive BPDUs. The port is now fully functional.
In the example below a ping was sent to the broadcast address of the 1979 – 22.214.171.124 subnet. With each icmp reply the switch will learn the MAC addresses of the devices and in turn build it’s MAC address table
The output above should correlate with the port states below: DL-1’s MAC address table shows that to reach devices on the 126.96.36.199/24 subnet/VLAN 1979 port G0/0 will be used. To reach AL-1 it will use G1/2
What happens if port G0/0 failed?
DL-1s spanning-tree state before G0/0 fails
DL-1s spanning-tree state after G0/0 fails. Port G0/1 which was currently in a ALTN/BLOCKING state quickly transitioned into the forwarding state.
Let’s look at the state of the MAC address table after the port failure
Port G0/0 recovered allowing spanning-tree to re-converge to a “better” port forwarding state