TL;DR

BFD (Bi-Directional Forwarding Detection) is a highly efficient keepalive mechanism for routing protocols, that can detect link failures in milliseconds.

Background

As stated at http://brbccie.blogspot.com/,

All routing protocols have some way of detecting failure, usually timer-related. Tuning the timers can theoretically get you sub-second failure detection in some protocols, but this produces unnecessary high overhead as the average IGP wasn't designed with that in mind.

BFD was specifically built for fast/low CPU detection, and in the case of single-hop, can offload a great deal of the checks to CEF (by using echo mode - more later), even on a typical router. [1]

Packets

BFD consists of 2 types of packets - Control and Echo:

  • Control packets are mandatory and processed by the CPU. They set up the initial BFD session, where parameters are negotiated, such as timers.
  • Echo packets use UDP to send an echo to a peer and are not received by the CPU. The is because they contain the source and destination IP/MAC of the sender. Therefore, when the peer gets the echo packet, the CEF/FIB tables (which do not touch the CPU) simplify forward the packet straight back to the sending peer. These are optional (but is on by default) if disabled only the control packets are used to determine that the peer is alive.

image1-1
Figure 1 - BFD Control and ECHO packets.[2]

Parameters

Let us look at the key parameters:

  • Transmit Interval - The amount of time between each ECHO being sent i.e ECHO packets are sent every x msecs.
  • Receive Interval - The maximum receive interval for the device when receiving ECHO packets i.e I can only accept ECHO packets sent to me every y msecs.
  • Multiplier - The number of ECHO packets, with no response before marking peer as down. i.e I have not seen any response from peer after sending z ECHO packets, so I'm marking the peer as down.

With regards to the intervals, each peer will negotiate these within their control packets. If a peer receives a control packet where the receive interval is less then its own transmit interval then the transmit interval will be adjusted to match that of the peer.

For Example :

Lets consider,

  • Peer 1 sends min_rx = 200ms
  • Peer 2 sends (tx) interval = 300ms.

This would result in peer 2 setting its (tx) interval and sending ECHO packets every 200ms.

Configuration

BFD can be configured and assiocated with many routing protocols. Within our example below, we will show you how to configure BFD with OSPF.

First we configure BFD on the interface.

interface GigabitEthernet0/0
 ...
 bfd interval 100 min_rx 200 multiplier 3

Next, we enable BFD within OSPF, like so,

router ospf 1
 ...
 bfd all-interfaces

You will then see a message similar to the below,

*Jun  8 05:33:25.563: %BFD-6-BFD_SESS_CREATED: BFD-SYSLOG: bfd_session_created, neigh 10.0.0.10 proc:OSPF, idb:GigabitEthernet0/2 handle:2 act
*Jun  8 05:33:25.569: %BFDFSM-6-BFD_SESS_UP: BFD-SYSLOG: BFD session ld:2 handle:2 is going UP

Finally, we can use the following commands to validate and obtain details about BFD, the state of the BFD neighbours and also the BFD paramters.

iosv-1# show bfd neighbors 

IPv4 Sessions
NeighAddr                              LD/RD         RH/RS     State     Int
10.0.0.6                                1/2          Up        Up        Gi0/1
10.0.0.10                               2/2          Up        Up        Gi0/2
iosv-1# show bfd neighbors details 

IPv4 Sessions
NeighAddr                              LD/RD         RH/RS     State     Int
10.0.0.6                                1/2          Up        Up        Gi0/1
Session state is UP and using echo function with 200 ms interval.
Session Host: Software
OurAddr: 10.0.0.5       
Handle: 1
Local Diag: 0, Demand mode: 0, Poll bit: 0
MinTxInt: 1000000, MinRxInt: 1000000, Multiplier: 3
Received MinRxInt: 1000000, Received Multiplier: 3
Holddown (hits): 0(0), Hello (hits): 1000(61)
Rx Count: 63, Rx Interval (ms) min/max/avg: 2/1000/862 last: 280 ms ago
Tx Count: 63, Tx Interval (ms) min/max/avg: 2/1001/856 last: 645 ms ago
Elapsed time watermarks: 0 0 (last: 0)
Registered protocols: OSPF CEF 
Uptime: 00:00:53
Last packet: Version: 1                  - Diagnostic: 0
             State bit: Up               - Demand bit: 0
             Poll bit: 0                 - Final bit: 0
             C bit: 0                                   
             Multiplier: 3               - Length: 24
             My Discr.: 2                - Your Discr.: 1
             Min tx interval: 1000000    - Min rx interval: 1000000
             Min Echo interval: 200000  

...

References


  1. "Jeff Kronlage's CCIE Study Blog: Everything BFD." 14 Jun. 2014, http://brbccie.blogspot.com/2014/06/everything-bfd.html. Accessed 8 Jun. 2018. ↩︎

  2. "BFD for MPLS LSPs - Knowledge Base - Google Sites." https://sites.google.com/site/amitsciscozone/home/important-tips/mpls-wiki/bfd-for-mpls-lsps. Accessed 8 Jun. 2018. ↩︎

Ready to Master Network Automation? Start Your Journey Today!
Our membership provides:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Live monthly tech sessions
  • Access to tech session library

Join Now ➜