If you want a primer on BPDUs and the STP Root Bridge election process, check out Spanning Tree BPDUs and Root Bridge Election. That serves to lay the groundwork for BPDU types and operation which we get deeper into here.
When network changes occur, it is important that Spanning Tree reconverge to reflect the new topology. If the Spanning Tree computation changes the forwarding path as part of that process, the MAC address table on all switches (also referred to as the CAM table) needs to be refreshed to age out older, inaccurate entries.
Topology Change Notifications
Before we get into the MAC address aging process, let’s first understand what Spanning Tree considers a network change. If either of the following events occur, a Topology Change Notification (TCN) will immediately be sent from the local switch to the Root Bridge:
- A port changes to Forwarding
- A port changes from Forwarding or Learning to Blocking
All switches need to be notified of the change, but they receive the information from the Root Bridge (via its superior Hello BPDUs). The following list outlines the topology change notification process for Spanning Tree.
TCN Propagation Steps
Step 1. A topology change event occurs on a switch. In this example an access port has been disconnected (changing the port from forwarding to blocking).
Step 2. The local switch sends a TCN BPDU out its Root Port, repeating the TCN every Hello timer value until an acknowledgement is received from the upstream switch.
Step 3. The upstream switch receives the TCN BPDU and responds with an acknowledgement by setting the Topology Change Acknowledgement (TCA) bit in the Flags field of its next Hello BPDU.
Step 4. The first three steps are repeated as the TCN/TCN Ack process continues towards the Root Bridge.
Step 5. The Root Bridge receives the TCN BPDU and responds to the sender with an acknowledgement.
Step 6. Now that the Root Bridge knows about the network change from the TCN BPDU it received, it will begin originating BPDUs with the special Topology Change (TC) bit set – instructing all switches to shorten their CAM table aging timer from the default of 300 seconds to the Forward Delay value (15 seconds by default). This allows all switches in the network to clear older entries which may be invalid while keeping entries for active connections.
MAC Address Aging
Spanning Tree Protocol is only interested in preventing switching loops, not in MAC address-learning. That means it leaves the address refresh process to the traditional MAC-learning processes like ARP and source-port learning. STP does kickstart the process by instructing all switches to age out old MAC entries from their CAM tables after a change has been identified (see Step 6 above).
By default, the aging time for the CAM table (aka MAC table) will stay at the Forward Delay Timer for 35 seconds. Specifically, that comes from the formula ForwardDelay+MaxAge.
Once the aging process is complete, MAC addresses can be quickly relearned via the traditional unknown unicast frame flooding process.
To summarize, after a change occurs, steps 2 and 3 are repeated until the Root Bridge receives the TCN BPDU. The root then sets the Topology Change flag on its Hellos (for the duration of the MaxAge+ForwardDelay seconds) which is flooded to all switches in the network. This lets the receiving switches know a network change has occurred and instructs them to time out old and potentially inaccurate MAC entries.
Spanning Tree Portfast and Topology Change Notifications
Portfast is a STP enhancement that was developed to allow specific ports to be excluded from generating Topology Change Notifications. Portfast is most often used on ports that connect to end hosts or workstations because when they are powered on (or off), a STP TCN storm isn’t helpful. This prevents unnecessary STP recomputation and address relearning.
Configuring Portfast intelligently can dramatically reduce the volume of Spanning Tree age-out cycles in a network where a large number of devices are frequently powered off and on. This is especially true in office environments. We’ll save the Portfast implementation details and options for another post, but understanding its role in preventing TCNs on configured ports is certainly worth a mention.