24 June, 2015

Bidirectional Forwarding Detection


[R1]
{INTERFACE}
interface Ethernet0/0
 ip address 10.99.1.1 255.255.255.0
 ip ospf bfd
 bfd interval 100 min_rx 100 multiplier 3

{OSPF}
router ospf 1
 router-id 1.1.1.1
 passive-interface default
 no passive-interface Ethernet0/0
 no passive-interface Ethernet0/1
 network 10.1.1.1 0.0.0.0 area 0
 network 10.1.2.1 0.0.0.0 area 0
 network 10.1.3.1 0.0.0.0 area 0
 network 10.99.1.1 0.0.0.0 area 0
 network 10.99.2.1 0.0.0.0 area 0
 bfd all-interfaces

[R2]
{INTERFACE}
interface Ethernet0/0
 ip address 10.99.1.2 255.255.255.0
 ip ospf bfd
 bfd interval 100 min_rx 100 multiplier 3

{OSPF}
router ospf 1
 router-id 2.2.2.2
 passive-interface default
 no passive-interface Ethernet0/0
 network 10.2.1.2 0.0.0.0 area 2
 network 10.2.2.2 0.0.0.0 area 2
 network 10.2.3.2 0.0.0.0 area 2
 network 10.99.1.2 0.0.0.0 area 0
 bfd all-interfaces

{SHOW COMMANDS AND DEBUG}
R1#show bfd ?
  drops      Display packets dropped 
  map        BFD map entry DB
  neighbors  BFD neighbors
  summary    BFD summary

R1#show bfd neighbors ?
  client         View neighbors of a specific client
  details        Display all BFD parameters
  hardware       Display hardware offloaded sessions
  inactive       Display inactive adjs
  ipv4           Neighbor IPv4 single-hop address
  ipv6           Neighbor IPv6 single-hop address
  mpls-pw        MPLS Pseudo-wire
  mpls-tp        MPLS TP
  multihop-ipv4  Multi-hop IPv4
  multihop-ipv6  Multi-hop IPv6
  vrf            Show entries for a VPN Routing/Forwarding instance
  |              Output modifiers
  <cr>

R1#show bfd summary 
                    Session          Up          Down
Total                     1           1             0

R1#show bfd neighbors 
IPv4 Sessions
NeighAddr                              LD/RD         RH/RS     State     Int
10.99.1.2                               1/1          Up        Up        Et0/0

R1#show bfd neighbors details 
IPv4 Sessions
NeighAddr                              LD/RD         RH/RS     State     Int
10.99.1.2                               1/1          Up        Up        Et0/0
Session state is UP and using echo function with 100 ms interval.
Session Host: Software
OurAddr: 10.99.1.1      
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(503)
Rx Count: 502, Rx Interval (ms) min/max/avg: 1/1077/882 last: 896 ms ago
Tx Count: 505, Tx Interval (ms) min/max/avg: 1/1042/878 last: 173 ms ago
Elapsed time watermarks: 0 0 (last: 0)
Registered protocols: OSPF
Uptime: 00:07:22
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.: 1                - Your Discr.: 1
             Min tx interval: 1000000    - Min rx interval: 1000000
             Min Echo interval: 100000 

R1#show bfd drops 
BFD Drop Statistics
                        IPV4    IPV6    IPV4-M  IPV6-M  MPLS_PW MPLS_TP_LSP
Invalid TTL             0        0       0       0       0       0
BFD Not Configured      0        0       0       0       0       0
No BFD Adjacency        0        0       0       0       0       0
Invalid Header Bits     0        0       0       0       0       0
Invalid Discriminator   0        0       0       0       0       0
Session AdminDown       0        0       0       0       0       0
Authen invalid BFD ver  0        0       0       0       0       0
Authen invalid len      0        0       0       0       0       0
Authen invalid seq      0        0       0       0       0       0
Authen failed           0        0       0       0       0       0

{Debug BFD}

R2(config)#in ethernet 0/0
R2(config-if)#shutdown 
R2(config-if)#no shutdown

R1#debug bfd event 
*Jun 24 06:37:47.063: BFD-DEBUG Event: V1 FSM ld:1 handle:1 event:ECHO FAILURE state:UP (0)
*Jun 24 06:37:47.064: BFD-DEBUG EVENT: bfd_session_destroyed, proc:OSPF, handle:1 act

*Jun 24 06:37:47.064: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Ethernet0/0 from FULL to DOWN, Neighbor Down: BFD node down

*Jun 24 06:37:47.065: BFD-DEBUG Event: notify client(OSPF) IP:10.99.1.2, ld:1, handle:1, event:1, cp independent failure (0)
*Jun 24 06:37:47.065: BFD-DEBUG Event: V1 FSM ld:1 handle:1 event:Session delete state:DOWN (0)

*Jun 24 06:37:50.067: BFD-DEBUG Event: V1 FSM ld:1 handle:1 event:DETECT TIMER EXPIRED state:ADMIN DOWN (0)
*Jun 24 06:37:50.067: BFD-DEBUG Event: decreasing credits by 12 [to 0] (0)

*Jun 24 06:37:52.789: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Ethernet0/0 from LOADING to FULL, Loading Done

*Jun 24 06:37:52.808: BFD-DEBUG EVENT: bfd_session_created, proc:OSPF, idb:Ethernet0/0 handle:1 act
*Jun 24 06:37:53.627: BFD-DEBUG Event: V1 FSM ld:1 handle:1 event:RX DOWN state:DOWN (0)
*Jun 24 06:37:53.628: BFD-DEBUG Event: V1 FSM ld:1 handle:1 event:RX UP state:INIT (0)
*Jun 24 06:37:53.628: BFD-DEBUG Event: notify client(OSPF) IP:10.99.1.2, ld:1, handle:1, event:0,  (0)

R2(config)#router ospf 1
R2(config-router)#no network 10.99.1.2 0.0.0.0 area 0

*Jun 24 06:42:08.307: BFD-DEBUG Event: V1 FSM ld:1 handle:1 event:RX ADMINDOWN state:UP (0)
*Jun 24 06:42:08.308: BFD-DEBUG Event: notify client(OSPF) IP:10.99.1.2, ld:1, handle:1, event:1 adminDown,  (0)
*Jun 24 06:42:09.137: BFD-DEBUG Event: V1 FSM ld:1 handle:1 event:RX ADMINDOWN state:DOWN (0)
*Jun 24 06:42:10.107: BFD-DEBUG Event: V1 FSM ld:1 handle:1 event:RX ADMINDOWN state:DOWN (0)
*Jun 24 06:42:10.968: BFD-DEBUG Event: V1 FSM ld:1 handle:1 event:RX ADMINDOWN state:DOWN (0)

*Jun 24 06:42:45.805: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Ethernet0/0 from FULL to DOWN, Neighbor Down: Dead timer expired

*Jun 24 06:42:45.805: BFD-DEBUG EVENT: bfd_session_destroyed, proc:OSPF, handle:1 act
*Jun 24 06:42:45.806: BFD-DEBUG Event: decreasing credits by 12 [to 0] (0)

R2(config-router)#network 10.99.1.2 0.0.0.0 area 0

*Jun 24 06:44:20.170: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Ethernet0/0 from LOADING to FULL, Loading Done
*Jun 24 06:44:20.183: BFD-DEBUG EVENT: bfd_session_created, proc:OSPF, idb:Ethernet0/0 handle:1 act
*Jun 24 06:44:21.077: BFD-DEBUG Event: V1 FSM ld:1 handle:1 event:RX DOWN state:DOWN (0)
*Jun 24 06:44:21.077: BFD-DEBUG Event: V1 FSM ld:1 handle:1 event:RX UP state:INIT (0)
*Jun 24 06:44:21.077: BFD-DEBUG Event: notify client(OSPF) IP:10.99.1.2, ld:1, handle:1, event:0,  (0)

R2(config)#interface ethernet 0/0
R2(config-if)#shutdown 
R2(config-if)#no shutdown 

R1#debug bfd packet 
*Jun 24 13:10:15.049: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Ethernet0/0 from FULL to DOWN, Neighbor Down: BFD node down
*Jun 24 13:10:15.050: BFD-DEBUG Packet: Tx IP:10.99.1.2 ld/rd:1/0 diag:2(Echo Function Failed) Down   cnt:1787 (0)
*Jun 24 13:10:15.054: BFD-DEBUG Packet: Tx IP:10.99.1.2 ld/rd:1/0 diag:7(Administratively Down) AdminDown   cnt:1788 (0)

*Jun 24 13:10:56.535: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Ethernet0/0 from LOADING to FULL, Loading Done
*Jun 24 13:10:57.381: BFD-DEBUG Packet: Rx IP:10.99.1.2 ld/rd:1/1 diag:0(No Diagnostic) Init  cnt:1 ttl:254 (0)
*Jun 24 13:10:57.381: BFD-DEBUG Packet: Tx IP:10.99.1.2 ld/rd:1/1 diag:0(No Diagnostic) Up   cnt:2 (0)
*Jun 24 13:10:57.381: BFD-DEBUG Packet: Rx IP:10.99.1.2 ld/rd:1/1 diag:0(No Diagnostic) Up  cnt:2 ttl:254 (0)

R1#show bfd drops 
BFD Drop Statistics
                        IPV4    IPV6    IPV4-M  IPV6-M  MPLS_PW MPLS_TP_LSP
Invalid TTL             0        0       0       0       0       0
BFD Not Configured      0        0       0       0       0       0
No BFD Adjacency        0        0       0       0       0       0
Invalid Header Bits     0        0       0       0       0       0
Invalid Discriminator   0        0       0       0       0       0
Session AdminDown       2        0       0       0       0       0
Authen invalid BFD ver  0        0       0       0       0       0
Authen invalid len      0        0       0       0       0       0
Authen invalid seq      0        0       0       0       0       0
Authen failed           0        0       0       0       0       0

R1#show clock 
*10:55:17.078 UTC Wed Jun 24 2015
R1#show interfaces ethernet 0/0 stats 
Ethernet0/0
          Switching path    Pkts In   Chars In   Pkts Out  Chars Out
               Processor        528     248328        787     264600
             Route cache      52560    2869584      52570    2870208
                   Total      53088    3117912      53357    3134808

R1#show clock                         
*10:55:44.779 UTC Wed Jun 24 2015
R1#show interfaces ethernet 0/0 stats 
Ethernet0/0
          Switching path    Pkts In   Chars In   Pkts Out  Chars Out
               Processor        532     248962        794     265414
             Route cache      53178    2903340      53187    2903898
                   Total      53710    3152302      53981    3169312

R1#show processes cpu sorted | in BFD
 221        5448      286802         18  1.91%  1.94%  1.93%   0 BFD IOU Process  
 130           8        1346          5  0.00%  0.00%  0.00%   0 BFD              
 187           0           3          0  0.00%  0.00%  0.00%   0 BFD events       
 208           0           5          0  0.00%  0.00%  0.00%   0 BFD debugs       
 254           8         408         19  0.00%  0.00%  0.00%   0 BFD packet stats 


- BFD is always unicast.

- BFD control packets are always UDP, sourced from 49152 and sent to 3784. BFD echo packets are also UDP, and are sourced from 3785 and sent to 3785 (why this is will become obvious later).

BFD Single-Hop Authentication here
If you wish to take a look at the Cisco BFD Configuration Guide, it can be found here