Topology Changes in Spanning Tree Protocol (STP)
Spanning Tree Protocol (STP) is used to prevent loops in the network due to redundant connections between switches in the network. It determines an efficient path from non-root switches to root switches with the help of Bridge Protocol Data Unit (BPDUs). BPDU carries information regarding topology changes within the network to notify all the switches about the change.
There are two types of BPDUs that are involved in the topology change mechanism in STP:
- Configuration BPDU: Root switch sends configuration BPDUs with set TC (topology change) and TCA (topology change acknowledgment) bit in flags field to notify all the switches about the topology change.
- Topology Change Notification (TCN) BPDUs: Non-root switch that encounters topology change in the network transmits TCN BPDU to notify root switch about topology change along with regulating the currently used topology by the network.
Reasons for Topology Change:
Spanning Tree Protocol activated network can encounter topology change due to the following reasons:
- Link failure
- Switch failure
- Port transitioning to the forwarding state
Topology Change Mechanism:
Switch encounters a topology change whenever it detects link status change on one of its interfaces due to a link or another switch failure. After detecting topology change within the network it generates a Topology Change Notification BPDU with all the information about the topology that is currently being used and sends it towards the root switch through its root port. Upstream switch connected with a switch that sent the TCN BPDU through its root port will receive the BPDU and responds back sender with Topology Change Acknowledgment (TCA) BPDU. Now, the upstream switch that received the TCN BPDU generates its own TCN BPDU and transmits it towards the root switch through its root port. This process is continued until the root bridge receives TCN BPDU.
Once, root bridge is notified about topology change, it generates a configuration BPDU with set topology change bit and topology change acknowledgment bit and broadcast this BPDU to the entire network so that all the switches are notified about topology change within the network.
TC bit in configuration BPDU sent by root instructs the non-root switches to delete MAC address entries which increase network convergence speed and the TCA bit informs them that the root switch is informed about topology change and hence instructs them to stop sending TCN BPDUs. Switches ensure no traffic is sent to host that is no longer reachable via port by updating MAC address entries by lowering the aging time to the same as the forward delay time and devices which communicate within this time period are retained in the MAC address table while others are flushed out.
What happens if a large number of Topology Changes occur in the Network?
Topology Change Notification BPDUs are used to notify about topology changes in the network. So, if the topology of the network is changed frequently then it will generate a large amount of TCN BPDUs in the network which will lead to frequent deletion of ARP entries and MAC entries by the devices. It will lead to high CPU usage and will cause instability in network traffic. Also, frequent change in port status during topology change cause network flapping which interrupts user traffic and reduce network convergence.
Example: Following figure shows an STP-activated LAN network that encounters a topology change at one of its interfaces at switch 4.
Switch 4 generates a TCN BPDU with information about topology change and sends it upstream towards switch 1 (root switch) via switch 2. Switch 2 on receiving TCN BPDU sent by switch 4 responds with TCA BPDU and generates its own TCN BPDU and sends it to switch 1. Switch 1 is informed about topology change as soon as it receives TCN BPDU.
Once, switch 1 is notified about topology change it generates a configuration BPDU with set TC and TCA bits and floods it to all the switches to inform them about topology change.
Problems associated with topology change:
- If a device receives too many TCN BPDUs then its CPU usage becomes high and the network becomes unstable due to repeated deletion of MAC address entries.
- Frequent port status changes may lead to network flapping.