Step 5. Topology Change with STP: Switch Failure and Recovery¶
Goals¶
This step demonstrates how STP handles a topology change caused by a switch failure. We will observe how the spanning tree rebuilds after a switch goes down, and how long STP takes to restore connectivity.
The Network¶
The simulation uses the LargeNet network: 11 switches and 6 hosts with a
heavily meshed topology, providing many redundant paths. This gives the spanning
tree more work to do when a failure occurs.
Configuration¶
[Config Step5]
description = "Topology change with STP - switch failure and recovery"
network = StpLargeNet
sim-time-limit = 1000s
**.hasStp = true
**.spanningTreeProtocol = "Stp"
**.hasStatus = true
**.script = xmldoc("failure.xml")
**.switch1.**.address = "AAAAAA000001"
**.switch2.**.address = "AAAAAA000002"
**.switch3.**.address = "AAAAAA000003"
**.switch4.**.address = "AAAAAA000004"
**.switch5.**.address = "AAAAAA000005"
**.switch6.**.address = "AAAAAA000006"
**.switch7.**.address = "AAAAAA000007"
**.switch8.**.address = "AAAAAA000008"
**.switch9.**.address = "AAAAAA000009"
**.switch10.**.address = "AAAAAA00000A"
**.switch11.**.address = "AAAAAA00000B"
**.host2.cli.destAddress = "host1"
**.host3.cli.destAddress = "host1"
**.host4.cli.destAddress = "host6"
**.host5.cli.destAddress = "host3"
**.host6.cli.destAddress = "host3"
**.host*.cli.startTime = 10ms
Switch failures are driven by failure.xml:
<script>
<at t="60s"><shutdown module="switch4"/></at>
<at t="180s"><startup module="switch4"/></at>
</script>
switch4 shuts down at t=60 s and restarts at t=180 s. The hasStatus = true
parameter enables lifecycle operations (shutdown/startup) on all nodes.
Traffic between all host pairs starts at t=10 ms and runs continuously, so any disruption to connectivity is immediately visible.
How STP Handles Topology Changes¶
When a switch detects a topology change — such as a port going down or a new port transitioning to Forwarding — STP uses a two-phase notification process:
The detecting switch sends a Topology Change Notification (TCN) BPDU upstream toward the root bridge via its root port. Each intermediate switch relays the TCN further upstream and acknowledges it downstream.
When the root bridge receives the TCN, it sets the Topology Change (TC) flag in its periodic Configuration BPDUs for a period of
maxAge + forwardDelayseconds (default 20 + 15 = 35 s).All switches that receive a TC-flagged BPDU reduce their MAC address aging time from the normal
agingTime(default 300 s) toforwardDelay(15 s). This causes stale entries to expire quickly, forcing the switches to re-learn the correct port mappings through flooding.
This mechanism is slow because it depends on the root bridge as a relay point, and the MAC tables are only gradually flushed through accelerated aging rather than immediately cleared.
The total reconvergence time after a failure can be broken down as:
maxAge (20 s): neighboring switches wait for the failed switch’s stored BPDU information to expire before they accept that the topology has changed.
Listening (15 s): ports with new roles go through the Listening state.
Learning (15 s): then through the Learning state.
Total: ~50 s before data flows again on the reconfigured tree.
Results¶
See Step 2 for a summary of the visual cues available in the simulation (packet names, port labels, root path cost, link colors, etc.).
Before failure (t=0-60 s): STP converges in ~35 s. All hosts communicate
through the active spanning tree. switch1 is root (lowest MAC address).
At t=60 s — switch4 shuts down. The switches that had ports connected
to switch4 stop receiving BPDUs on those ports. After maxAge (20 s)
expires, they discard the stored BPDU information and re-evaluate their port
roles. The affected ports then transition through Listening → Learning →
Forwarding (another 30 s). During this ~50 s period, hosts that depended on
paths through switch4 lose connectivity.
When the tree re-stabilizes, they can communicate again via alternate paths (the topology has enough redundancy).
At t=180 s — switch4 restarts. STP again goes through the full
convergence cycle before the switch rejoins the active tree.
The slow convergence after failure is the main limitation of STP. The next step introduces RSTP, which converges much faster both at startup and after topology changes.
Sources:
omnetpp.ini,
StpTutorial.ned,
failure.xml
Discussion¶
Use this page in the GitHub issue tracker for commenting on this tutorial.