STP Operations
Steps to a Loop-Free Topology
Now you know how loops are created and the basics of using spanning tree protocol to prevent them. This topic will take you, step by step, through the operation of STP. Using the STA, STP builds a loop-free topology in a four-step process:
- Elect the root bridge.
- Elect the root ports.
- Elect designated ports.
- Elect alternate (blocked) ports.
During STA and STP functions, switches use Bridge Protocol Data Units (BPDUs) to share information about themselves and their connections. BPDUs are used to elect the root bridge, root ports, designated ports, and alternate ports. Each BPDU contains a bridge ID (BID) that identifies which switch sent the BPDU. The BID is involved in making many of the STA decisions including root bridge and port roles. As shown in the figure, the BID contains a priority value, an extended system ID, and the MAC address of the switch. The lowest BID value is determined by the combination of these three fields.
The graphic shows three boxes, each representing a component of the bridge ID. From left to right the first box is Bridge Priority which is 4 bits in length, the second box is Extended System ID which is 12 bits in length, and the third box is the MAC address which is 48 bits in length. Text to the right of the boxes reads Bridge ID with the Extended System ID. Text at the bottom of the graphic reads The BID includes the Bridge Priority, the Extended System ID, and the MAC address of the switch.
The Fa0/2 interface of S2 is the designated port on the segment with S3.
4. Elect Alternate (Blocked) Ports
If a port is not a root port or a designated port, then it becomes an alternate (or backup) port. Alternate ports and backup ports are in discarding or blocking state to prevent loops. In the figure, the STA has configured port F0/2 on S3 in the alternate role. Port F0/2 on S3 is in the blocking state and will not forward Ethernet frames. All other inter-switch ports are in forwarding state. This is the loop-prevention part of STP.
The Fa0/2 interface of S3 is not a root port or a designated port, so it becomes an alternate or blocked port
Elect a Root Port from Multiple Equal-Cost Paths
Root port and designated ports are based on the lowest path cost to the root bridge. But what happens if the switch has multiple equal-cost paths to the root bridge? How does a switch designate a root port?
When a switch has multiple equal-cost paths to the root bridge, the switch will determine a port using the following criteria:
- Lowest sender BID
- Lowest sender port priority
- Lowest sender port ID