When an OSPF router receives an updated LSA, it doesn’t run SPF right away but schedules it. It does so in case there is a change in the topology. However, the local router is probably not the only one affected so it’s likely that you will receive more than one updated LSA. The router waits for a short while so that it only has to run SPF once for all updated LSAs.

If the topology change is caused by a flapping link then the router would run SPF over and over again, increasing its load. To ensure this doesn’t happen, the delay before SPF runs will keep increasing if you keep receiving updated LSAs.

This scheduling of SPF is controlled by SPF throttling. There are three values that it uses:

  • spf-start: the initial wait interval before SPF starts after receiving an updated LSA.
  • spf-hold: the wait interval between subsequent SPF runs. This value doubles for each time SPF runs.
  • spf-max-wait: the maximum time between two SPF runs, used to cap the spf-hold value. It also defines how long the network has to be stable before the wait interval is reset to the spf-start and spf-hold values.

Let me explain how this works. Let’s assume we use the following values:

  • spf-start: 5 seconds
  • spf-hold: 10 seconds
  • spf-max-wait: 60 seconds

Our router receives an LSA and schedules SPF according to the spf-start value, which is 5 seconds:

spf throttling initial lsa

During this time, the router receives another LSA. This LSA is stored in the LSDB but we have to wait until the wait interval (5 seconds) expires. Once these 5 seconds have expired, SPF will run:

ospf spf throttling second lsa

The router sets the wait interval to the spf-hold value which is 10 seconds:

ospf spf throttling spf-hold

During this time, we receive another LSA. Once the 10 seconds have expired, SPF will run:

ospf spf throttling hold value expires

The router now doubles the spf-hold value so now it’s 2x 10 = 20 seconds. During this time, we don’t receive any other LSAs. Once 20 seconds have elapsed, SPF runs again:

ospf spf throttling hold value doubles

Since we didn’t receive any LSAs during the last wait interval, the router resets the wait interval to spf-start. A few seconds later, we receive another LSA:

ospf spf throttling wait interval reseted

During this time, we receive yet another LSA. After 5 seconds, SPF runs:

ospf spf throttling wait interval reseted

The wait interval doubles the value of the previous spf-hold so now we have to wait 2x 20 = 40 seconds until SPF runs. During this time, however, we don’t receive any other LSAs:

ospf spf throttling hold value quad

Once SPF has run, the wait interval is reset to the spf-start value again. The spf-hold value remains at 40 seconds for now. No other LSAs arrive so after 60 seconds since we ran the last SPF, the max-hold-wait time interval expires:

ospf spf throttling spf max wait

Once the max-hold-wait timer expires, the spf-hold value is reset to its default value of 10 seconds again. Any topology changes that occur now will be dealt with like the start of this example.

Now you understand how SPF scheduling works by throttling, let’s see what it looks like on some routers.

Configuration

Here is the topology I will use:

ospf area 0 r1 r2 loopback

We only need two routers. R2 has a loopback interface that I will use to simulate a flapping interface.

  • Configurations
  • R1
  • R2

Want to take a look for yourself? Here you will find the startup configuration of each device.

Cisco IOS has a default spf-start of 5 seconds and the spf-hold and spf-max-wait are both 10 seconds. To see the spf-hold increase, we have to change the spf-max-wait value. Here’s how you can do this:

R1(config)#router ospf 1
R1(config-router)#timers throttle spf ?
  <1-600000>  Delay between receiving a change to SPF calculation in
              milliseconds

First, we specify the spf-start value. I will use the default value of 5 seconds. The next value is the spf-hold:

R1(config-router)#timers throttle spf 5000 ?     
  <1-600000>  Delay between first and second SPF calculation in milliseconds

Let’s use 10 seconds. Last but not least, the spf-max-wait value:

R1(config-router)#timers throttle spf 5000 10000 60000 

I will set this value to 60 seconds. This means that SPF will never be delayed by more than 60 seconds.

Verification

We can see the scheduling, throttling and running of SPF in action with a single OSPF debug command:

R1#debug ip ospf monitor 
OSPF SPF monitoring debugging is on

On R2, I do a couple of shutdowns and no shutdowns so that it creates LSAs. On R1, you will see this:

R1#
OSPF-1 MON  : Schedule Full SPF without microloop avoidance in area 0, change in LSA R/192.168.12.2/192.168.12.2 
OSPF-1 MON  : reset throttling to 5000ms next wait-interval 10000ms
OSPF-1 MON  : Schedule SPF in 5000ms: spf_time 06:07:22.759, wait_interval 5000ms 

Above you can see that SPF is scheduled in 5000ms (5 seconds). Once these 5 seconds have expired, SPF will run and the wait interval increases to 10000 ms (spf-hold):

R1#
OSPF-1 MON  : Begin SPF at 22107.274ms, process time 39163ms 
OSPF-1 MON  : Last spf_time 06:07:22.759, wait_interval 5000ms 
OSPF-1 MON  : Setting next wait-interval to 10000ms 
OSPF-1 MON  : End SPF at 22107.278ms, Total elapsed time 4ms 
OSPF-1 MON  :  Schedule time 06:08:27.278, Next wait_interval 10000ms

If the interface keeps flapping then we will see this value double over and over again. Next time it will be 20000 ms:

R1#
OSPF-1 MON  : Schedule Full SPF without microloop avoidance in area 0, change in LSA R/192.168.12.2/192.168.12.2 
OSPF-1 MON  : Schedule SPF in 5000ms: spf_time 06:09:23.697, wait_interval 10000ms 
OSPF-1 MON  : Begin SPF at 22176.179ms, process time 39333ms 
OSPF-1 MON  : Last spf_time 06:09:23.697, wait_interval 10000ms 
OSPF-1 MON  : Setting next wait-interval to 20000ms 
OSPF-1 MON  : End SPF at 22176.183ms, Total elapsed time 4ms 
OSPF-1 MON  :  Schedule time 06:09:36.183, Next wait_interval 20000ms 

And then it doubles again to 40000 ms:

R1#
OSPF-1 MON  : Schedule Full SPF without microloop avoidance in area 0, change in LSA R/192.168.12.2/192.168.12.2 
OSPF-1 MON  : Schedule SPF in 5000ms: spf_time 06:09:36.184, wait_interval 20000ms 
OSPF-1 MON  : Schedule Full SPF without microloop avoidance in area 0, change in LSA R/192.168.12.2/192.168.12.2 
OSPF-1 MON  : Begin SPF at 22197.309ms, process time 39384ms 
OSPF-1 MON  : Last spf_time 06:09:36.184, wait_interval 20000ms 
OSPF-1 MON  : Setting next wait-interval to 40000ms 
OSPF-1 MON  : End SPF at 22197.312ms, Total elapsed time 3ms 

The maximum wait interval will never be higher than the spf-max-wait value which is 60 seconds in my case. If you don’t generate any LSAs anymore, SPF will not run anymore and if you wait 60 seconds, the wait interval will reset to 5000 ms (spf-start) again. That’s all there is to it!

  • Configurations
  • R1
  • R2

Want to take a look for yourself? Here you will find the final configuration of each device.

Conclusion

OSPF doesn’t run SPF immediately every time it receives an LSA. Instead, SPF is scheduled. This allows OSPF to batch LSAs and run SPF for a few LSAs at the same time. When there are a lot of topology changes in the network, the SPF algorithm will keep running over and over. To prevent this from happening, you can tune the SPF scheduling with the SPF throttling feature.

SPF throttling has a spf-start value that defines a wait interval that tells OSPF how long to wait until it starts SPF. A second value, the spf-hold value tells OSPF how long to wait before it can run SPF again. The spf-hold value increases, preventing SPF from running over and over again in an unstable network. A third timer, called the spf-max-wait defines the maximum wait interval that we want to use and also defines when the topology is considered stable again, based on when SPF ran for the last time.

Unit 1: Introduction to OSPF

Unit 2: OSPF Neighbor Adjacency

Unit 3: OSPF Network Types

Unit 4: OSPF Stub Areas

Unit 5: Advanced OSPF Topics