This is more a topic for exams, like Cisco CCIE, but also it can appear in real-world environments.
SW1 is the spanning-tree root bridge for all VLANs. Imagine that you have a request which ask you that when a port becomes active, no matter of VLAN, it should wait 10 seconds until it transition to forwarding state.
You look into configuration mode and spot the “spanning-tree .. forward-time..” command. OK, simple enough, you go there and type:
spanning-tree vlan 1-4094 forward-time 10
Task completed. This is what I also thought. Looks pretty straight forward, but it’s a mistake which I learned from and I hope you will read this before doing it.
Lucky for me it was just a test lab not the real CCIE lab, but if I don’t teach this kind of things or spend the entire day fine-tuning STP, I tend to forget.
Back to this example, let’s see on the SW2 what’s happening after I did configure the above command on SW1. By the way, you need to configure this command only on the STP root bridge because the downstream devices will inherit the values.
On the SW2 I shutdown the root interface to force the alternate interface (which is in blocking state) to transition to forward state and check the output of “debug spanning-tree events” :
00:55:15: STP: VLAN0001 new root port Fa0/2, cost 19 00:55:15: STP: VLAN0001 Fa0/2 -> listening ... 00:55:25: STP: VLAN0001 Fa0/2 -> learning ... 00:55:35: STP: VLAN0001 sent Topology Change Notice on Fa0/2 00:55:35: STP: VLAN0001 Fa0/2 -> forwarding
From :15 seconds when the port entered Listening state until :35 seconds when it went into Forwarding state there are 20 seconds. We were required to have 10 seconds not 20. That’s not good.
Going back and checking the parameters of a STP for a particular VLAN did not give me too much information to clarify the issue:
show spanning-tree vlan 1 | i Forward Hello Time 3 sec Max Age 10 sec Forward Delay 10 sec
OK, after reading again carefully the documentation I came to the understanding that value added to this command is applied to each state towards the forwarding state.
The STP Port States are: Blocking, Listening, Learning, Forwarding and Disabled.
When I did shutdown the root port, the alternate port when immediately to Listening state then waited for 10 seconds until it transition to Learning state and again 10 Seconds to achieve Forwarding state.
The correct solution was obvious now to decrease the forward-time to 5 seconds.
spanning-tree vlan 1-4094 forward-time 5
Let’s check again:
01:11:55: STP: VLAN0001 new root port Fa0/2, cost 19 01:11:55: STP: VLAN0001 Fa0/2 -> listening ... 01:12:00: STP: VLAN0001 Fa0/2 -> learning ... 01:12:05: STP: VLAN0001 sent Topology Change Notice on Fa0/2 01:12:05: STP: VLAN0001 Fa0/2 -> forwarding
Now the total time is 10 second.
I hope this will help others to avoid my mistakes.