Bridge Protocols and BPDUs

Spanning Tree Protocol messages and bridge communication mechanisms.

Introduction: Redundancy's Double-Edged Sword

In the world of networking, reliability is paramount. A network that goes down is a network that is useless. To achieve high availability, network designers use a core principle: redundancy. This means creating multiple, alternate paths for data to travel. If one link or device fails, for instance a cable is accidentally cut by construction workers, traffic can automatically be rerouted through a backup path, ensuring continuous service.

In modern Local Area Networks (LANs), this redundancy is achieved by connecting switches (historically called bridges) to each other with multiple links. While this creates a fault-tolerant physical topology, it also introduces a catastrophic problem at the : bridging loops.

Without a control mechanism, these redundant paths would create an infinite feedback loop, bringing the entire network to a grinding halt within seconds. This is where bridge protocols, specifically the Spanning Tree Protocol (STP), come into play. They are the essential traffic controllers that make redundant networks possible.

The Catastrophe: Understanding Broadcast Storms and MAC Table Instability

To understand why bridging loops are so devastating, we need to examine what happens to a simple broadcast frame in a redundant, unmanaged network. A broadcast frame is a message intended for every single device on the LAN. A common example is an ARP request, which a computer sends to find the MAC address of another device.

The Anatomy of a Loop Catastrophe

  1. Initial Broadcast: A computer sends a single broadcast frame. It arrives at Switch A.
  2. The Flood: A switch's fundamental behavior is to forward a broadcast frame out of every port except the one it came in on. Switch A floods the frame towards Switch B and Switch C.
  3. The Loop Begins:
    • Switch B receives the frame from Switch A and floods it out of all its other ports, including the one connected to Switch C.
    • Simultaneously, Switch C receives the frame from Switch A and floods it out, including towards Switch B.
  4. Infinite Amplification: Now Switch B and C are receiving duplicate copies of the same original frame from each other. They see no reason to stop, so they continue to flood these copies back and forth. The single frame has multiplied and is now circling the network endlessly, consuming all available bandwidth. This is known as a broadcast storm.

Consequence 1: MAC Table Instability

Switches learn which devices are connected to which ports by examining the source MAC address of incoming frames. In a loop, a switch will see a frame from the same source computer arriving on multiple different ports. For example, Switch C will see the frame from the computer first from Switch A, and then a moment later from Switch B. This causes the switch to constantly update its MAC address table, frantically changing the port associated with that source MAC address. This is called MAC table flapping, and it effectively renders the switch unable to make correct forwarding decisions for unicast traffic.

Consequence 2: Multiple Frame Transmission

Even if the frame has a specific destination (unicast), the MAC table instability means the destination device may receive multiple copies of the same frame. While some higher-level protocols can handle duplicate data, it causes significant inefficiency and can confuse many applications. The network becomes both completely saturated and unreliable.

The Solution: Spanning Tree Protocol (STP)

The brilliant solution to this problem is the Spanning Tree Protocol (STP), defined in the IEEE 802.1D standard. Invented by Radia Perlman, STP's mission is to prevent bridging loops by creating a single, logical loop-free path through the network.

It does this by starting with the physically redundant network (a graph with cycles) and logically "pruning" it into a spanning tree. A tree is a type of graph that has no loops; there is only one active path between any two nodes. STP intelligently identifies redundant links and places them into a blocking state.

A port in a blocking state does not forward user data frames, effectively breaking the loop. However, it remains physically active and listens for control messages. If the primary, active path fails, STP can automatically detect the failure and transition a previously blocked port into a forwarding state, thus reactivating the redundant path and restoring connectivity. This provides the best of both worlds: a loop-free network during normal operation, with automatic failover capabilities.

How STP Builds the Tree: An Election Process

To create this logical tree, all the switches in the LAN participate in a dynamic election process. They communicate using special control frames called . The entire process happens automatically in a few steps.

  1. Step 1: Elect the Root Bridge

    The first and most important step is to choose a single switch to be the Root Bridge. The Root Bridge acts as the central reference point for the entire spanning tree; all paths will be calculated based on the distance from this switch. It is like electing a president or naming a capital city for the network.

    The election is won by the switch with the lowest Bridge ID. The Bridge ID is an 8-byte value composed of:

    • Bridge Priority (2 bytes): A configurable value from 0 to 65535. The default is 32768. An administrator can influence the election by setting a lower priority on a specific switch.
    • MAC Address (6 bytes): The unique hardware address of the switch. This serves as the tie-breaker if multiple switches have the same priority.

    Bridge ID=Bridge Priority+MAC Address\text{Bridge ID} = \text{Bridge Priority} + \text{MAC Address}

    Initially, every switch boots up thinking it is the Root Bridge. They start sending out BPDUs with their own Bridge ID as the Root ID. When a switch receives a BPDU with a superior (lower) Bridge ID, it stops advertising itself as the root and starts relaying the BPDUs from the better candidate. This process quickly converges, and soon all switches agree on which one is the Root Bridge.

  2. Step 2: Elect Root Ports on Non-Root Bridges

    Every switch that is not the Root Bridge (a non-root bridge) must determine its single best path towards the Root Bridge. The port on that switch that lies on this best path is elected as the Root Port. There can be only one Root Port per non-root bridge.

    The decision is based on the lowest Root Path Cost. The cost is an accumulated value based on the speed of the links along the path:

    • A switch receives BPDUs from the Root Bridge (either directly or relayed). These BPDUs contain the current Root Path Cost.
    • The switch adds the cost of the port on which it received the BPDU to this value. The standard (though now outdated) costs are: 10 Gbps (Cost 2), 1 Gbps (Cost 4), 100 Mbps (Cost 19), 10 Mbps (Cost 100).
    • The port that results in the lowest total accumulated cost to the root is chosen as the Root Port.
    • Tie-breakers: If a switch has multiple paths with the same cost, it will choose the path from the neighbor switch with the lowest Bridge ID. If that is also a tie, it chooses the path connected to the neighbor's port with the lowest Port ID.
  3. Step 3: Elect Designated Ports on Each Segment

    On every network segment (e.g., the cable connecting two switches), one port must be responsible for forwarding traffic onto that segment towards the Root Bridge. This port is elected as the Designated Port. There can be only one Designated Port per segment.

    All ports on the Root Bridge are always Designated Ports. On other segments, the port on the switch with the lower Root Path Cost for that segment becomes the Designated Port. The same tie-breakers (Bridge ID, Port ID) apply if costs are equal.

  4. Step 4: Block All Remaining Ports

    Any port that is not a Root Port or a Designated Port is a redundant link that could create a loop. These ports are placed in the Blocking State. They will not forward any user data but will continue to listen to BPDUs to know when to take over if the active path fails.

The Lifecycle of an STP Port: Port States

An STP-enabled port does not simply turn on and off. It progresses through several distinct states to prevent temporary loops from forming while the network topology is changing.

Blocking
↓
Listening (≈\approx15s)
↓
Learning (≈\approx15s)
↓
Forwarding
Disabled
  • Disabled: The port is administratively shut down. It does not participate in STP.
  • Blocking: This is the initial state for a port, and the state for redundant ports in a stable topology. The port listens to BPDUs to learn about the network topology, but it does not forward user data frames and does not learn MAC addresses. This breaks the loop.
  • Listening: The first transitional state when a port moves from Blocking towards Forwarding. The switch has decided this port could become a Root or Designated Port. In this state, the port continues to process BPDUs and actively participates in the STP election, but it still does not forward user data or learn MAC addresses. This lasts for the duration of the Forward Delay timer (typically 15 seconds).
  • Learning: The second transitional state. The port is now confirmed to be a future forwarding port (Root or Designated). It still does not forward user data frames to prevent temporary loops. However, it begins to listen to incoming frames and learn the source MAC addresses to populate its MAC address table. This also lasts for the duration of the Forward Delay timer (another 15 seconds). Pre-populating the MAC table ensures that when forwarding begins, the switch already knows where to send traffic.
  • Forwarding: The port is fully operational. It sends and receives BPDUs, forwards user data frames, and continues to learn MAC addresses. This is the normal state for all active, non-redundant ports in the spanning tree.

The total time to transition a port from blocking to forwarding is typically 30 seconds (15 listening + 15 learning), though it can take up to 50 seconds if it has to wait for old topology information to time out first (20 seconds Max Age + 30 seconds). While very reliable, this slow convergence was a major drawback of the original STP and led to the development of faster versions like RSTP (Rapid Spanning Tree Protocol).

    Bridge Protocols and BPDUs | Teleinf Edu