Sub topic 16
Topology Changes and Flushing the Table
This chapter assumes you know how a switch learns source addresses, floods unknown destinations, and ages out idle entries. It also assumes you know what a spanning tree protocol (STP) does at a high level: it blocks redundant links so that a switched network has no loops.
Why a topology change makes the table wrong
A MAC address table records which port leads to each address. In a network with several switches, that answer depends on which links are forwarding. If STP blocks one link and unblocks another, the best path to a host can move to a different port.
The table entries do not change on their own. With the default aging time of 300 seconds, a switch can keep sending frames to a port that no longer leads to the host. The host may not send a frame that would correct the entry, so traffic can be lost for up to five minutes.
The idea: shorten the memory
When a switch learns that the topology changed, it does not wait for the normal aging time. It makes entries expire quickly, or it removes them. Frames to those hosts are then flooded until the switch learns the new ports. Flooding wastes some bandwidth, but it delivers the frames.
Classic STP (802.1D) does this with a Topology Change Notification (TCN):
- A switch detects a change, for example a port moving into the forwarding state or a forwarding port going down.
- It sends a TCN BPDU (a spanning tree control message) toward the root bridge.
- The root sets the topology change flag in the configuration BPDUs it sends for a period of time.
- Every switch that receives the flag reduces its aging time to the forwarding delay, which is 15 seconds by default. Old entries expire quickly while the network relearns.
Rapid STP (802.1w) works differently. A switch that detects a change flushes the entries learned on its other ports immediately. It then floods the topology change message to its neighbors, and they flush too. Convergence is faster, and entries learned on the port that received the message are kept.
Example
Switch S1 reaches host H through port Gi0/1 and has an entry for H on that port. The link on Gi0/1 fails, and STP unblocks Gi0/2, which gives S1 a new path to H.
- Without a flush, S1 keeps sending frames for H out of Gi0/1, which is down or no longer leads to H. H is unreachable from S1 until the entry ages out or H sends a frame.
- With a flush, S1 removes or shortens the entry. The next frame for H is flooded, including out of Gi0/2. H answers, and S1 learns H on Gi0/2.
Seeing and causing a flush
On Cisco IOS-style switches, you can clear dynamic entries by hand. This is useful when you test a change, but it floods traffic on a busy network, so use it with care.
Switch# clear mac address-table dynamic
Switch# clear mac address-table dynamic interface Gi0/1
Switch# clear mac address-table dynamic vlan 10On a Linux bridge, you can watch entries disappear and reappear. The bridge fdb show command lists the forwarding database. Entries marked permanent are static and survive a flush.
bridge fdb show br br0Common errors
- Assuming a topology change is a failure. It is a normal recovery step.
- Expecting static entries to be removed. Flushes affect dynamic entries only.
- Ignoring a flapping access port. Repeated flushes show up as bursts of flooded traffic.
Exercise
A link fails and STP unblocks a backup path. Why does a switch shorten its aging time or flush entries, instead of waiting for the default 300 seconds?
Show answer
Entries learned before the change may point to ports that no longer lead to the host. Waiting could send frames to the wrong port for up to five minutes. Flushing or shortening the aging time makes the switch flood frames to the affected hosts and relearn the correct ports from the replies.
Exercise
Why is it a good idea to enable PortFast on ports that connect to workstations?
Show answer
A workstation port that goes up or down would otherwise trigger a topology change. That flushes entries on many switches and causes extra flooding. PortFast stops these ports from generating topology changes.