BFD on a FortiGate overlay: Measuring What Your Timers Actually Survive

Most BFD advice comes down to a number: 300 ms, 3 times. Some of it comes from a vendor default, some from a datacentre design, and little of it comes with a measurement from a link that looks like yours. I wanted to know what a timer set actually survives, so I put three of them through the same impairments on a FortiGate overlay and counted the flaps.

This post is the result: the configuration, the three things I got wrong on the first install, the outage each timer set rides out, what loss, jitter and load do, and why the timer I chose has more to do with margin than with speed. For the protocol background and the design reasoning, see SD-WAN Resilience Part 4. Here I am looking at what happens in practice.

The lab

Two FortiGate-VMs on FortiOS 7.6.8. The hub is a BGP route reflector at 10.0.1.2 and the spoke is at 10.0.1.11. They run iBGP in AS 65000 between loopbacks (lo-bgp, VRF 100), carried over an IPsec tunnel. I covered the BGP side, including the authentication, in BGP TCP-AO on FortiGate.

The underlay is a Proxmox bridge, so it is clean and fast. That matters for how far the results travel, and I come back to it at the end. All impairments were applied with tc netem on the host, on the tap interface of the spoke VM, and only in the hub-to-spoke direction. One-way loss is a deliberately harsh test, because the spoke keeps sending BFD packets that the hub receives, yet the hub’s own packets never arrive.

The configuration

BGP peers loopback to loopback across the tunnel, so BFD has to use the same pair of addresses. That is a multihop BFD template, not the usual interface BFD:

config system settings
    set bfd enable
end
config router bfd
    config multihop-template
        edit 1
            set src 10.0.1.2 255.255.255.255
            set dst 10.0.1.11 255.255.255.255
            set bfd-desired-min-tx 500
            set bfd-required-min-rx 500
            set bfd-detect-mult 3
        next
    end
end
config router bgp
    config neighbor
        edit "10.0.1.11"
            set bfd enable
        next
    end
end

The spoke has the mirror image: one template with the source and destination swapped. The detect time is the interval multiplied by the multiplier, so 500 ms with a multiplier of 3 gives 1500 ms.

The documented multihop example is for eBGP. Whether it works for iBGP across a tunnel was an open question, so I made it test 0. It does: BFD came up on both ends and BGP stayed Established.

Three things the first install got wrong

None of these is hidden in the documentation, but I only found them by watching what failed.

1. BFD does nothing until it is enabled globally. I installed the template and bound bfd enable to the neighbor, and nothing happened: no bfdd process, no BFD neighbor, no BFD line anywhere. The missing piece was set bfd enable under config system settings. The 7.6.8 Administration Guide example sets it, and I had read past it.

2. The firewall policy has to allow UDP 4784. After the global enable, the neighbor appeared but stayed Down. A sniffer on the tunnel showed BFD packets arriving in both directions, which looks reassuring, but the sniffer sees packets before the firewall does. The policy that lets the overlay reach the loopback (mine is policy 901) had no service for multihop BFD, which uses UDP port 4784. I added a custom service and put it in the policy:

config firewall service custom
    edit "GT-BFD-MULTIHOP"
        set udp-portrange 4784
    next
end

3. The BGP neighbor output will not tell you. get router info bgp neighbors has no BFD line on this build, so I spent a while looking for state in the wrong place. The command is:

get router info bfd neighbor
OurAddress   NeighAddress   State  Interface  LDesc/RDesc
10.0.1.2     10.0.1.11      UP     N/A        1/1/M

The M marks a multihop session. The two numbers are the local and remote discriminators, and they turn out to be the most useful thing in the output.

Counting flaps

A BFD session that goes down and comes back is created again with a new local discriminator. So the discriminator is a flap counter: 1 means the session has never failed since it was installed, 2 means it has failed once, and so on. Reading it before and after a test shows exactly how many times BFD tore the session down, even when I was not watching at the time.

I paired that with BGP’s own uptime on both ends (get router info bgp summary vrf 100). If the discriminator is unchanged and the uptime ran on unbroken, nothing flapped. If the discriminator moved, the uptime shows when BGP was reset by it.

The timer sets

I tested three sets. Each has an interval, a multiplier, and the detect time that follows from them:

SetIntervalMultiplierDetect time
5100 ms3300 ms
3300 ms3900 ms
2500 ms31500 ms

I confirmed each set was live by sniffing UDP 4784 on the hub. The packets are not sent at exactly the configured interval, because RFC 5880 applies jitter that reduces the transmit interval by up to 25%. With 300 ms configured, the hub transmitted every 232 to 293 ms. With 500 ms, every 392 to 483 ms. That is correct behaviour, and it matters when you read a sniffer trace.

Test 1: jitter, which rules out the aggressive set

I added 200 ms of delay with 150 ms of jitter for ten minutes, which is a rough stand-in for a congested LTE or cable link.

Set 5 (300 ms detect) failed badly. It flapped 26 times, ten of them in the first 69 seconds, and I stopped it by hand after about three minutes. Every flap reset BGP. It recovered by itself when I removed the impairment.

Sets 3 and 2 both ran the full ten minutes with no flap and no BGP reset.

A 300 ms detect time is tighter than the jitter on a poor link, so BFD reads ordinary delay variation as a failure. I rejected set 5 for any path where the jitter is of that order, which includes most paths with a wireless or congested last mile.

Test 2: how short an outage can each set ride out?

This is the test I care about most. I dropped all hub-to-spoke traffic for a fixed time with netem loss 100%, then removed it, and repeated that ten times 20 seconds apart. I measured the span from timestamps around the tc commands, so each span includes a few milliseconds of command overhead.

My expectation going in was that any outage shorter than the detect time would pass. I was wrong. A 0.87 s outage flapped set 3, which has a 900 ms detect time.

The results, with ten outages per point unless noted:

SetDetectZero flaps up toHalf flap atAlways flaps from
3 (300 ms x 3)900 ms0.47 s (0/10; 0.37 s was 0/11)0.57 s (5/10)0.87 s (1 of 1)
2 (500 ms x 3)1500 ms0.97 s (0/10)1.17 s (5/10)not measured

In both sets the half-flap point sits about a third of a second below the detect time, and zero flaps held up to roughly half a second below it. I have only two points, so I would not push that into a formula. A plausible reason is that the detect timer runs from the last packet received, and the first packet after an outage can arrive up to one transmit interval late, so the gap the peer sees is longer than the outage. That is reasoning, not something I measured, and it fits set 3 better than set 2.

The practical reading: the detect time is not the outage you survive. Subtract about half a second from it, and then look at what outages your underlay produces. Set 2 tolerates outages about twice as long as set 3.

Test 3: loss

5% loss for ten minutes did not flap sets 2 or 3. That is weaker evidence than it looks. With a multiplier of 3, three consecutive losses at 5% is rare, and my estimate was about 0.15 flaps per ten minutes on set 2 and 0.25 on set 3, so a clean run was the likely outcome either way.

20% loss on set 3 is where it shows. Over five minutes it flapped eight times, about every 37 seconds, and each flap reset BGP. After a reset the prefix stays gone until the session is back and BGP has advertised again, so the route was absent for most of the test. When I removed the loss, the session re-established with no manual action.

Without BFD I would expect the BGP session to have survived 20% loss, since the default hold time is 180 seconds. I did not run that comparison, so it is an inference. If it holds, BFD turned a degraded but working link into a flapping one. Degraded links are a job for SD-WAN SLA steering, which can move traffic off a lossy path without tearing the routing session down. BFD is for dead paths.

Test 4: load

I used the built-in iperf3 on the FortiGate, which I covered in iperf3 on FortiOS 7.6.8, to put traffic through the tunnel.

Bulk TCP did not flap set 3. An unshaped run at 537 Mbit/s for 60 seconds saturated the tunnel and BFD held. I then shaped the tap to 20 Mbit/s with queue depths that give about 0.6 s and 1.2 s of queueing delay. That held too.

That last result went against my prediction. I expected a queueing delay above the detect time to trip BFD, and it did not. The detect timer restarts on every BFD packet received, so a constant delay of 1.2 s still delivers a BFD packet every few hundred milliseconds. What trips BFD is a gap of three consecutive missed packets, from loss or from a sudden jump in delay. TCP also backs off before a queue stays full, so the tail-drop bursts are short.

A UDP flood does take BFD down. I sent 100 Mbit/s of UDP into the 20 Mbit/s shaper. About 81% of the datagrams were lost, BFD went down within a couple of seconds, and BGP reset. It only recovered when the flood ended. Nothing prioritises BFD on that link, so the BFD packets are tail-dropped along with everything else. A flood of unresponsive traffic that fills a queue will do this to any timer set, so it says nothing about which one to pick. It does say that a real WAN edge needs the BFD packets in a priority queue.

A practical note: the bfdd debug at level -1 gave no state-transition text on this build, only netlink events. To see the timeline, sniff BFD itself on the receiving end:

diagnose sniffer packet any 'udp and port 4784' 4 0 l

The moment the hub’s packets stop arriving is the moment BFD starts counting.

Test 5: a real failure, and what BFD does not speed up

A 3 second outage is longer than any detect time here, so it must flap. On set 3, BFD was created again, BGP reset, and the session re-established within a second or two of the path returning. But the prefix was missing at the first check and back by the next one, about two minutes later. Between those two reads I do not have a timestamp.

For a cleaner measurement I ran a 60 second outage on set 2. The result:

  • BFD detected the failure and the BGP session was torn down within about 2 to 9 seconds of the start. That is far inside the 180 second hold time. I could only bound it that tightly from the uptime counters, so I will not claim a better figure.
  • At 16 seconds in, the BFD table was empty, BGP was in Connect and the prefix was gone.
  • After the path returned, BGP re-established in 32 seconds. The next connect attempt had been due in 47 seconds.

Two things follow. First, a BFD session on this design only exists while the BGP session is up. After a teardown, BFD comes back when BGP reconnects, on BGP’s retry timer, and not on BFD’s schedule. Second, route recovery after a real failure is bounded by the BGP reconnect and the 30 second minimum interval between advertisement runs. The 0.6 second difference between a 900 ms and a 1500 ms detect time barely shows up in the time to a working route.

That is the point I would keep from all of this. Faster detection buys very little recovery time, and it costs margin against jitter and short outages. The margin is the part worth paying for.

What I chose

Set 2: 500 ms, multiplier 3, a 1500 ms detect time. It survived the jitter test, tolerated outages about twice as long as set 3, and recovered the same way after a real failure. I did not test the other timer sets in my plan, 1000 ms x 3 and 250 ms x 5, so I am not claiming set 2 is the best possible. It is the fastest of the three I measured that I would trust.

What I did not test

  • A real WAN. The underlay is a virtual bridge. The impairments are synthetic, so the numbers show how the timers behave, not what your ISP does. Repeat it on real links before copying a value.
  • A 24 hour soak with no impairment, to confirm zero flaps over a day.
  • BFD authentication. The template supports MD5 with a key per peer, and I have not enabled it.
  • The interaction with IPsec dead peer detection and with graceful restart. BFD should be the faster signal, and I have not confirmed that on this build.
  • Hub CPU at scale. I had one spoke, so the per-spoke cost of BFD on a hub with many sessions is unmeasured.
  • The interaction with SD-WAN SLAs. That is a separate post.

Summary

  1. Multihop BFD works for iBGP over a tunnel on 7.6.8, but only with BFD enabled globally and UDP 4784 allowed in the policy that guards the loopback.
  2. Read get router info bfd neighbor, and use the local discriminator as a flap counter.
  3. A 100 ms x 3 set flapped 26 times under 200 ms delay with 150 ms jitter. A 300 ms detect time is not safe on a path with real jitter.
  4. The detect time overstates the outage you survive. In my tests zero flaps held up to roughly half a second below it.
  5. A constant delay above the detect time does not trip BFD. Loss bursts do, and so does a flood that fills a queue and drops the BFD packets.
  6. After a real failure, recovery is set by the BGP reconnect and advertisement timers. Choosing a timer for margin, not speed, costs almost nothing.
  7. BFD is for dead paths. For degraded ones, use SLA steering.