Back when I was getting started in IT, Spanning Tree Protocol was a lightly touched upon topic. “Just remember it’s on by default and it does most of the work for you.” Most small networks won’t have to configure STP. If you’re planning redundant network links then you have to pay attention to STP.
STP starts with 802.1D. It provides a loop-free topology on a Layer 2 network. When a failure occurs, the network can recover without the intervention from an administrator. A switch with STP will look for redundant links to other switches. When redundant links are found, the switch blocks one of those links to prevent a loop from occurring.
A switch listens on incoming frames to find out what network devices reside on which ports. A table is built with source MAC addresses with the port numbers where the switch found other network devices.
When switches aren’t aware of each other, a bridging loop can occur. This is when a frame is forwarded continuously between switches.
Switches communicate with each other via BPDUs, or bridge protocol data units. They are sent out every 2 seconds from the switch’s MAC address to a multicast address of 01:80:C2:00:00:00.
Two types of BPDUs can be transmitted:
- Configuration BPDU – for STP computation.
- Topology Change Notification (TCN) – sent when changes occur in the network topology.
Each loop-free topology has one root bridge. A root bridge is elected based on the lowest bridge ID. A bridge ID consists of the Bridge Priority — the default priority for all switches is 32,768. The other portion of the bridge ID is the MAC address of the switch.
Each non-root bridge has a root port that points toward the current root bridge. Just remember that a switch with root ports is not a root bridge. Can be confusing at first. A root port is chosen based on a port’s cost to the root bridge.
The following table lists the STP port cost to reach the root bridge based on the link bandwidth:
[table id=4 /]
A designated port is a port on each network segment with the lowest cumulative root path cost to the root bridge. The purpose of this port is to remove the possibility of a bridging loop.
What happens when there is a tie? The following is the tie-breaking STP process:
1. Lowest root bridge ID
2. Lowest root path cost to the root bridge
3. Lowest sender bridge ID
4. Lowest sender port ID
STP Port States
Each port participating in STP undergoes different STP states. The order of the states follows:
1. Disabled – port is shut down.
2. Blocking – State after port initializes. In this state, no data can be received or transmitted. BPDUs can be received but it cannot add MAC addresses to the bridge table.
3. Listening – The port still cannot send or receive data but is able to send and receive BPDUs.
4. Learning – The port can now add MAC addresses to the bridging table but cannot yet send or receive data.
5. Forwarding – The port can send and receive data, collect MAC addresses to add to the bridging table, and send and receive BPDUs.