6 Spanning Tree Protocol (STP) Explained
1. Key Concepts of Spanning Tree Protocol (STP)
Spanning Tree Protocol (STP) is a network protocol that ensures a loop-free topology for Ethernet networks. Key concepts include:
- Root Bridge: The central switch that all other switches use as a reference point.
- Bridge ID: A unique identifier for each switch, consisting of a priority and MAC address.
- Port Roles: Different roles assigned to switch ports, such as Root Port, Designated Port, and Alternate Port.
- Port States: Various states a port can be in, including Blocking, Listening, Learning, and Forwarding.
- BPDU (Bridge Protocol Data Unit): Messages exchanged between switches to determine the topology.
- Convergence: The process by which the network stabilizes after a change.
2. Root Bridge
The Root Bridge is the central switch in the STP topology. All other switches in the network use the Root Bridge as a reference point to determine the best path to reach it. The Root Bridge is chosen based on the lowest Bridge ID.
Example: In a network with three switches, the switch with the lowest Bridge ID (e.g., priority 32768 and MAC address 00:1A:2B:3C:4D:5E) will be elected as the Root Bridge. This switch will then serve as the central point for all STP calculations.
3. Bridge ID
The Bridge ID is a unique identifier for each switch, consisting of an 8-bit priority value and a 48-bit MAC address. The priority value can be manually configured, and the MAC address is unique to each switch. The switch with the lowest Bridge ID is elected as the Root Bridge.
Example: If two switches have the same priority (e.g., 32768), the switch with the lower MAC address (e.g., 00:1A:2B:3C:4D:5E vs. 00:23:45:67:89:AB) will be chosen as the Root Bridge.
4. Port Roles
Port roles determine how each switch port participates in the STP topology. Common port roles include:
- Root Port: The port on a switch that provides the best path to the Root Bridge.
- Designated Port: The port on a segment that forwards traffic to and from the Root Bridge.
- Alternate Port: A port that provides an alternative path to the Root Bridge and is placed in the Blocking state to prevent loops.
Example: In a network with three switches connected in a triangle, each switch will have one Root Port pointing towards the Root Bridge, one Designated Port facing away from the Root Bridge, and one Alternate Port in the Blocking state to prevent loops.
5. Port States
Port states define the operational status of a switch port in the STP process. Common port states include:
- Blocking: The port does not forward traffic and only listens for BPDU messages.
- Listening: The port is preparing to forward traffic and exchanges BPDU messages.
- Learning: The port learns MAC addresses and prepares to forward traffic.
- Forwarding: The port actively forwards traffic.
Example: When a new switch is connected to the network, its ports will initially be in the Blocking state. After exchanging BPDU messages, the ports will transition to Listening, then Learning, and finally to Forwarding, allowing traffic to flow.
6. BPDU (Bridge Protocol Data Unit)
BPDU messages are exchanged between switches to determine the STP topology. These messages contain information about the switch's Bridge ID, Root Bridge ID, and path cost. BPDUs help switches make decisions about which ports to block, listen, learn, or forward.
Example: When a switch receives a BPDU with a lower Root Bridge ID than its own, it will update its Root Bridge ID and recalculate the best path to the Root Bridge. This process ensures that the network remains loop-free and optimized.
7. Convergence
Convergence is the process by which the network stabilizes after a change, such as a link failure or the addition of a new switch. During convergence, switches exchange BPDUs and update their port roles and states to maintain a loop-free topology.
Example: If a link to the Root Bridge fails, the switches will enter a convergence phase. During this phase, they will exchange BPDUs to determine the new best path to the Root Bridge, update their port roles, and transition their ports to the appropriate states to maintain network connectivity.