STP is the simplest loop prevention protocol. It is a Layer 2 protocol that calculates the best path through a switched network that contains redundant paths. STP uses bridge protocol data unit (BPDU) packets to exchange information with other switches.
When enabling a new port for STP the Spanning Tree Protocol goes through the following port states to get that port to be either forwarding or blocking. The port states are:
- Blocking - Drops all packet and does not forward any frames but still receives BPDUs from other switches.
- Listening - The first state in transition to forwarding states. Unlike Blocking, in Listening mode, the port will send BPDUs.
- Learning - the second state in the transition to Forwarding. State, the switch learns MAC addresses sent on this switch port. Forwarding - transmits and receives frames. This is the normal state for a port.
- Disabled - Does not participate in STP, the switch port is administratively disabled.
To verify port state
Use the command 'show spanning-tree interface' to check the interface state, verify that the ports are in steady state and not flapping between states (ie Forwarding, Blocking or listening). Flapping interfaces will affect the stability and performance of the LAN
user@switch> show spanning-tree interface
Spanning tree interface parameters for instance 0
Interface Port ID Designated Designated Port State Role
port ID bridge ID Cost
ge-0/0/9.0 128:522 128:522 32768.0019e25078a0 20000 FWD DESG
ge-0/0/10.0 128:523 128:523 32768.0019e25078a0 20000 FWD DESG
ge-0/0/11.0 128:524 128:524 32768.0019e25078a0 20000 FWD DESG
To verify correct transmission of BPDU packets
Use the command 'show spanning-tree statistics interface' to verify that BPDU packets are being sent and received correctly, and not discarded without any apparent reason. The example below shows the BPDU sent and received, and the next BPD transmission in seconds
switch@user> show spanning-tree statistics interface
Interface BPDUs sent BPDUs received Next BPD transmission
ge-0/0/9.0 7 5 0
ge-0/0/10.0 7 5 0
ge-0/0/11.0 7 5 0