Thursday 18 June 2015

BFD (Bidirectional Forwarding Detection)

In this post, we will look into a feature called BFD (bidirectional forwarding detection). In normal routing protocol operation, the link failure is detected by using the hello/holddown/dead timers. 

Depending on the routing protocol, you can lower the timers to achieve fast failure detection. e.g. in the case of OSPF the lowest dead time can be one second and one can set the hello interval as low as 50ms.

However lowering these timers can result in higher CPU utilization. Also it will unnecessarily waste the link bandwidth. 

There is a better way of achieving fast failure detection through BFD. BFD is a UDP-based protocol that provides fast (in milliseconds) routing protocol independent detection of layer-3 next hop failures.

Let's see how it works. As shown in the diagram below, routers R1 and R2 are connected via Switch 1 and Switch 2. Both the routers are running OSPF and we can see the OSPF neighbourship is up.




Now what if the link between SW1 and SW2 goes down? The connected interface of the routers are still up so the failure detection will rely upton the Hello & Dead timer of OSPF hence by default it will take around 40 seconds to detect the failure.

If we want OSPF to detect the link failure faster, then one of the options is to decrease the hello/dead interval. In OSPF we can minimize the dead timer to be as low as one second. The corresponding Hello interval can be minimum of 50ms. 

Let's try that on on both the routers




However lowering the timers in OSPF can increase the CPU utilization of router. 



We can see that the OSPF hello process is one of the top processes in the list so it's not a very practical solution.

The other way to achieve this by using BFD. 

A little bit of a background on BFD. 
  • BFD (Bidirectional Forwarding Detection) is defined in RFC 5880. 
  • BFD is a UDP based protocol that provides very fast (in milliseconds) detection of layer 3 next-hop failure independent of routing protocol.
  • BFD packets are smaller thank "hello" packets originated by routing protocols.
  • If you router is running more than one IGP, you will still need only one BFD session per interface.
  • There are two BFD modes i) Asynchronous ii) Demand (Demand mode is not supported by Cisco)
Ok, let's see how we can configure it. To configure BFD, we need to go under the interface and type

bfd interval milliseconds min_rx milliseconds multiplier interval-multiplier 

so for example,

bfd interval 60 min_rx 50 multiplier 3 where
60 is the send-timer which specifies the frequency of BFD packets originated by router

50 is the receive-timer which represent the minimum interval between packets accepted from BFD peers
3 is the multiplier which is the number of BFD packets can be lost before BFD peer id declared down

To see BFD in action, let's change the OSPF hello/dead interval to a higher value like 60 seconds Hello and 180 seconds dead interval.






Now let's see what happens if the link between ESW1 and ESW2 goes down.





It took few minutes for OSPF adjacency to go down after the link was shut. I will unshut the link now.

We will keep the OSPF timers as it is and implement BFD to improve the failure detection time.

Let's configure BFD on R1 and R2, I will use minimum timers which is 50ms send-timer, 50ms receive-timer and 3 as the multiplier.





Now we have to associate this BFD process with the routing protocol. 




If we check the OSPF interface status, 



We can see that BFD is enabled for OSPF.

One can also use "show bfd neighbours" command to verify the status of BFD.



Let's try and fail the link between the switches




The OSPF adjacency failed straight after the link between the switches went down. It even beat the log message that was generated on the switch!!

The same BFD session can be associated with multiple protocols on a single router. 

BFD can be used with static route, EIGRP, BGP, IS-IS and also HSRP! To implement BFD, CEF and IP routing must be enabled on router. More information on this can be found at http://www.cisco.com/c/en/us/td/docs/ios/12_0s/feature/guide/fs_bfd.html



No comments:

Post a Comment