Day 11: OSPF Failures, Measuring Convergence, and BFD
Goal: Measure how long the network takes after a failure until traffic flows again. Experience the difference between a loud and a silent failure, and push the time down from over 30 seconds to a quarter of a second with shorter timers and with BFD · Duration: approx. 75 min · Prerequisite: Day 10 (the lab is still up)
Briefing
- Convergence is the time from a failure until the moment all routers have correct routes again. Packets get lost during this time.
- A loud failure is one the router notices
immediately: the interface goes
DOWNbecause the cable was pulled or the neighbor was shut down. A silent failure leaves the interfaceUP, but nothing gets through anymore: a switch in between hangs, a media converter is broken, a firewall suddenly drops. Then OSPF only has the dead time. - BFD (Bidirectional Forwarding Detection) is a tiny protocol that does just one thing: it asks the neighbor every few milliseconds whether it is still there and tells OSPF if not.
The measurement method for the whole day: h1 pings
h3 every 10 milliseconds. Every lost packet is 10
milliseconds of outage.
h1 ──── r1 ═══════ eth13/eth31 ═══════ r3 ──── h3
\ (disrupted) /
└───── r2 (backup path) ───┘
Drill 1: The Starting Point
The lab from Day 10 is still running. All adjacencies are up, and the
path leads directly via r1–r3:
# on netz
for r in r1 r2 r3; do echo "$r $(sudo vtysh -N $r -c 'show ip ospf neighbor' | grep -c Full)"; done
sudo vtysh -N r1 -c 'show ip route 10.3.3.0/24' | grep '\*'Expected:
r1 2
r2 2
r3 2
* 10.0.13.3, via eth13, weight 1
Caution: If the VM was restarted in the meantime, the namespaces are gone. Then run Drill 1 from Day 10 again and
sudo systemctl restart frr@r1 frr@r2 frr@r3.
Save your progress? Sign up for free
Drill 2: The Loud Failure
20 seconds of ping; after 5 seconds the direct link goes
DOWN:
# on netz
sudo ip netns exec h1 ping -i 0.01 -c 2000 -q 10.3.3.10 > /tmp/p.txt &
sleep 5; sudo ip -n r1 link set eth13 down
wait; tail -2 /tmp/p.txt
sudo vtysh -N r1 -c 'show ip route 10.3.3.0/24' | grep -E 'metric|\*'Expected:
2000 packets transmitted, 1999 received, +1 errors, 0.05% packet loss, time 22026ms
rtt min/avg/max/mdev = 0.035/0.135/0.552/0.039 ms
Known via "ospf", distance 110, metric 30, best
* 10.0.12.2, via eth12, weight 1
One packet lost, so about 10 milliseconds. zebra sees
the interface go down, ospfd declares the neighbor dead
immediately, recomputes, and floods its changed router LSA. The
+1 errors is a Destination Net Unreachable
from r1 from the moment in between. Link back up:
# on netz
sudo ip -n r1 link set eth13 up
sleep 15
sudo vtysh -N r1 -c 'show ip route 10.3.3.0/24' | grep '\*'Expected:
* 10.0.13.3, via eth13, weight 1
Save your progress? Sign up for free
Drill 3: The Silent Failure
Now the link stays UP, but both ends drop everything
they are supposed to send. tc netem from Day 9 does this
with loss 100%. 70 seconds of ping:
# on netz
sudo ip netns exec h1 ping -i 0.01 -c 7000 -q 10.3.3.10 > /tmp/p.txt &
sleep 5
sudo ip netns exec r1 tc qdisc add dev eth13 root netem loss 100%
sudo ip netns exec r3 tc qdisc add dev eth31 root netem loss 100%
sleep 10
sudo ip -n r1 link show eth13 | grep -o 'state [A-Z]*'
sudo vtysh -N r1 -c 'show ip ospf neighbor' | grep 10.255.0.3
wait; tail -2 /tmp/p.txt
sudo vtysh -N r1 -c 'show ip ospf neighbor'
sudo vtysh -N r1 -c 'show ip route 10.3.3.0/24' | grep '\*'Expected:
state UP
10.255.0.3 1 Full/- 33.991s 26.008s 10.0.13.3 eth13:10.0.13.1 0 0 0
7000 packets transmitted, 3712 received, +30 errors, 46.9714% packet loss, time 77204ms
rtt min/avg/max/mdev = 0.038/0.132/1.215/0.048 ms, pipe 278
Neighbor ID Pri State Up Time Dead Time Address Interface RXmtL RqstL DBsmL
10.255.0.2 1 Full/- 8m51s 38.450s 10.0.12.2 eth12:10.0.12.1 0 0 0
* 10.0.12.2, via eth12, weight 1
Ten seconds after the failure: interface UP, neighbor
Full, Dead Time counting down from 26 seconds.
For OSPF everything is fine, yet the traffic goes nowhere. Only when the
dead time expires does the neighbor drop out, and the path via
r2 takes over.
3288 lost packets, almost 33 seconds of outage. Not quite 40, because the last hello before the disturbance was already a few seconds old. On average, a silent failure with default timers costs 35 seconds. For a phone system, a database replication, or a load balancer with health checks, that is an eternity.
Remove the disturbance:
# on netz
sudo ip netns exec r1 tc qdisc del dev eth13 root
sudo ip netns exec r3 tc qdisc del dev eth31 rootSave your progress? Sign up for free
Drill 4: Faster Hellos
The obvious solution: ask more often. Hello every second, dead after 3 seconds. Both ends of a link need the same values, otherwise no adjacency forms:
# on netz
sudo vtysh -N r1 -c 'configure terminal' -c 'interface eth13' -c 'ip ospf hello-interval 1' -c 'ip ospf dead-interval 3' -c 'end' -c 'write memory' >/dev/null
sudo vtysh -N r3 -c 'configure terminal' -c 'interface eth31' -c 'ip ospf hello-interval 1' -c 'ip ospf dead-interval 3' -c 'end' -c 'write memory' >/dev/null
sleep 15
sudo vtysh -N r1 -c 'show ip ospf neighbor' | grep 10.255.0.3
sudo vtysh -N r1 -c 'show ip ospf interface eth13' | grep -E 'Hello 1s'Expected:
10.255.0.3 1 Full/- 14.153s 2.852s 10.0.13.3 eth13:10.0.13.1 0 0 0
Timer intervals configured, Hello 1s, Dead 3s, Wait 3s, Retransmit 5
Dead Time is now just under 3 seconds. The same silent
failure:
# on netz
sudo ip netns exec h1 ping -i 0.01 -c 1500 -q 10.3.3.10 > /tmp/p.txt &
sleep 3
sudo ip netns exec r1 tc qdisc add dev eth13 root netem loss 100%
sudo ip netns exec r3 tc qdisc add dev eth31 root netem loss 100%
wait; tail -2 /tmp/p.txt
sudo ip netns exec r1 tc qdisc del dev eth13 root
sudo ip netns exec r3 tc qdisc del dev eth31 rootExpected:
1500 packets transmitted, 1266 received, 15.6% packet loss, time 16527ms
rtt min/avg/max/mdev = 0.047/0.129/1.360/0.052 ms
234 packets, 2.3 seconds. Much better, but hellos are part of OSPF:
ospfd has to process them, and with many neighbors and a
busy router, a one-second delay can already trigger a false alarm. Going
below one second with hellos only works with tricks
(ip ospf dead-interval minimal hello-multiplier), and not
even the developers recommend that. Back to the default values:
# on netz
sudo vtysh -N r1 -c 'configure terminal' -c 'interface eth13' -c 'no ip ospf hello-interval' -c 'no ip ospf dead-interval' -c 'end' -c 'write memory' >/dev/null
sudo vtysh -N r3 -c 'configure terminal' -c 'interface eth31' -c 'no ip ospf hello-interval' -c 'no ip ospf dead-interval' -c 'end' -c 'write memory' >/dev/nullSave your progress? Sign up for free
Drill 5: Turning On BFD
BFD is a separate daemon in FRR, bfdd. Like
ospfd, it is enabled in the daemons file, and
that requires a restart of the instance:
# on netz
sudo sed -i 's/^bfdd=no/bfdd=yes/' /etc/frr/r1/daemons
sudo sed -i 's/^bfdd=no/bfdd=yes/' /etc/frr/r3/daemons
sudo systemctl restart frr@r1
sudo systemctl restart frr@r3
sleep 3
sudo vtysh -N r1 -c 'show daemons'Expected:
mgmtd zebra ospfd staticd bfdd watchfrr
A BFD profile with a 100-millisecond interval, three misses mean dead, and OSPF on the link should use BFD:
# on netz
sudo vtysh -N r1 -c 'configure terminal' -c 'bfd' -c 'profile schnell' -c 'detect-multiplier 3' -c 'receive-interval 100' -c 'transmit-interval 100' -c 'exit' -c 'exit' -c 'interface eth13' -c 'ip ospf bfd' -c 'ip ospf bfd profile schnell' -c 'end' -c 'write memory' >/dev/null
sudo vtysh -N r3 -c 'configure terminal' -c 'bfd' -c 'profile schnell' -c 'detect-multiplier 3' -c 'receive-interval 100' -c 'transmit-interval 100' -c 'exit' -c 'exit' -c 'interface eth31' -c 'ip ospf bfd' -c 'ip ospf bfd profile schnell' -c 'end' -c 'write memory' >/dev/null
sleep 50
sudo vtysh -N r1 -c 'show ip ospf neighbor'
sudo vtysh -N r1 -c 'show bfd peers brief'Expected:
Neighbor ID Pri State Up Time Dead Time Address Interface RXmtL RqstL DBsmL
10.255.0.2 1 Full/- 46.860s 33.142s 10.0.12.2 eth12:10.0.12.1 0 0 0
10.255.0.3 1 Full/- 43.571s 36.427s 10.0.13.3 eth13:10.0.13.1 0 0 0
Session count: 1
SessionId LocalAddress PeerAddress Status Profile
========= ============ =========== ====== =======
1684388473 10.0.13.1 10.0.13.3 up schnell
The restart of the instances rebuilt the adjacencies, hence the
50-second pause. The BFD session to r3 is up.
The details:
# on netz
sudo vtysh -N r1 -c 'show bfd peers' | grep -E 'Status|Peer Type|Detect-multiplier|Receive interval|Transmission interval|Detection timeout' | head -7Expected:
Status: up
Peer Type: dynamic
Detect-multiplier: 3
Receive interval: 100ms
Transmission interval: 100ms
Transmission interval (actual with jitter): 95ms
Detection timeout: 300ms
dynamic means: OSPF created the session when the
adjacency came up and removes it again when the neighbor disappears. The
packets deliberately vary by a few milliseconds (jitter) so
that not all of a router’s sessions send in the same rhythm.
Save your progress? Sign up for free
Drill 6: The Silent Failure with BFD
The same disturbance; ten seconds of ping are enough now:
# on netz
sudo ip netns exec h1 ping -i 0.01 -c 1000 -q 10.3.3.10 > /tmp/p.txt &
sleep 3
sudo ip netns exec r1 tc qdisc add dev eth13 root netem loss 100%
sudo ip netns exec r3 tc qdisc add dev eth31 root netem loss 100%
wait; tail -2 /tmp/p.txt
sudo vtysh -N r1 -c 'show ip route 10.3.3.0/24' | grep '\*'Expected:
1000 packets transmitted, 974 received, 2.6% packet loss, time 11005ms
rtt min/avg/max/mdev = 0.039/0.122/0.419/0.032 ms
* 10.0.12.2, via eth12, weight 1
26 packets, a quarter of a second. 300 milliseconds of detection, minus the time since the last BFD packet, plus the recomputation in OSPF. And back:
# on netz
sudo ip netns exec r1 tc qdisc del dev eth13 root
sudo ip netns exec r3 tc qdisc del dev eth31 root
sleep 15
sudo vtysh -N r1 -c 'show bfd peers brief' | tail -1
sudo vtysh -N r1 -c 'show ip route 10.3.3.0/24' | grep '\*'Expected:
2043166479 10.0.13.1 10.0.13.3 up schnell
* 10.0.13.3, via eth13, weight 1
A new session ID: the old session disappeared with the neighbor, and the new one was created with the new adjacency.
The day’s numbers at a glance:
| Failure | Detection | Measured |
|---|---|---|
loud (interface DOWN) |
immediate | 1 packet, approx. 10 ms |
| silent, default timers (10/40 s) | dead time | 3288 packets, approx. 33 s |
| silent, hello 1 s / dead 3 s | dead time | 234 packets, approx. 2.3 s |
| silent, BFD 100 ms × 3 | BFD | 26 packets, approx. 0.26 s |
Save your progress? Sign up for free
Exercise: Speed drills
- After what time does the BFD session of
r1declare the neighbor dead? Target time: 20 s - Which hello and dead time apply on
eth12ofr1? Target time: 20 s - How many BFD sessions on
r3areup? Just the number. Target time: 20 s
Solution
# on netz
sudo vtysh -N r1 -c 'show bfd peers' | grep 'Detection timeout'
sudo vtysh -N r1 -c 'show ip ospf interface eth12' | grep -o 'Hello [0-9]*s, Dead [0-9]*s'
sudo vtysh -N r3 -c 'show bfd peers brief' | grep -c ' up 'Expected (after the Challenge; before it, question 3
gives 1):
Detection timeout: 300ms
Hello 10s, Dead 40s
2
Save your progress? Sign up for free
Challenge
A colleague has also set up BFD for the link
r2–r3 and says: “Done, a silent failure there
now also costs only a quarter of a second.” This is how he did it:
# on netz
sudo sed -i 's/^bfdd=no/bfdd=yes/' /etc/frr/r2/daemons
sudo systemctl restart frr@r2
sleep 3
sudo vtysh -N r2 -c 'configure terminal' -c 'bfd' -c 'profile schnell' -c 'detect-multiplier 3' -c 'receive-interval 100' -c 'transmit-interval 100' -c 'exit' -c 'exit' -c 'interface eth23' -c 'ip ospf bfd' -c 'ip ospf bfd profile schnell' -c 'end' -c 'write memory' >/dev/null
sleep 45
sudo vtysh -N r2 -c 'show ip ospf neighbor' | grep 10.255.0.3Expected:
10.255.0.3 1 Full/- 40.194s 39.805s 10.0.23.3 eth23:10.0.23.2 0 0 0
The adjacency is up. Is his claim true? Check it without causing a failure, and fix it.
Hint: A BFD session needs two participants.
Solution
# on netz
sudo vtysh -N r2 -c 'show bfd peers brief'
sudo vtysh -N r2 -c 'show bfd peers' | grep -E 'peer|Status|Remote ID'
sudo vtysh -N r3 -c 'show ip ospf interface eth32' | grep -ci bfdExpected:
Session count: 1
SessionId LocalAddress PeerAddress Status Profile
========= ============ =========== ====== =======
4273044143 10.0.23.2 10.0.23.3 down schnell
peer 10.0.23.3 local-address 10.0.23.2 vrf default interface eth23
Remote ID: 0
Status: down
0
The session on r2 is down,
Remote ID: 0: no BFD packet ever came from the other side.
On r3, BFD is not enabled for eth32 at all.
The good news: a session that was never up does not tear
down the OSPF adjacency, which is why it is Full. The bad
news: it does not protect anything either. A silent failure still costs
33 seconds. r3 has had bfdd since Drill 5;
only the interface is missing:
# on netz
sudo vtysh -N r3 -c 'configure terminal' -c 'interface eth32' -c 'ip ospf bfd' -c 'ip ospf bfd profile schnell' -c 'end' -c 'write memory' >/dev/null
sleep 5
sudo vtysh -N r2 -c 'show bfd peers brief' | tail -1Expected:
4273044143 10.0.23.2 10.0.23.3 up schnell
Save your progress? Sign up for free
Checkpoint
# on netz
for r in r1 r2 r3; do echo "$r $(sudo vtysh -N $r -c 'show bfd peers brief' | grep -c ' up ')"; doneExpected:
r1 1
r2 1
r3 2
# on netz
sudo ip netns exec r1 tc qdisc show dev eth13
sudo ip netns exec r3 tc qdisc show dev eth31Expected:
qdisc noqueue 0: root refcnt 2
qdisc noqueue 0: root refcnt 2
Clean-up
The OSPF lab has served its purpose; Day 12 builds two sites with
BGP. The drop-in for frr@ stays, since all further FRR days
need it:
# on netz
sudo systemctl stop frr@r1 frr@r2 frr@r3
sudo rm -rf /etc/frr/r1 /etc/frr/r2 /etc/frr/r3
sudo ip netns del r1
sudo ip netns del r2
sudo ip netns del r3
sudo ip netns del h1
sudo ip netns del h3
rm -f /tmp/p.txt
ip netns list | wc -l
pgrep -c -x zebra
cat /etc/systemd/system/[email protected]/netns.confExpected:
0
0
[Service]
NetworkNamespacePath=/run/netns/%i
Practice note
- Test the silent failure, not just the loud one. A
pulled cable is the rarer case in the data center. More often something
in between hangs, and then the dead time counts. With
tc netem loss 100%you can reproduce it in any test environment. - BFD instead of short hellos. BFD is lightweight, implemented in hardware on many platforms, and built for milliseconds. OSPF hellos stay at 10/40 seconds, and BFD takes over fast detection.
- BFD on both sides, and verify.
show bfd peersbelongs in every acceptance test. A session in thedownstate does not protect anything and otherwise goes unnoticed. - Not too aggressive. 3 × 100 ms is common on direct links. Over paths with fluctuating round-trip times (VPN, provider networks), times that are too short lead to flapping: the session drops with every small delay, and routing jumps back and forth. There, 300 ms × 3 is the more sensible choice.