BFD(Bidirectional Forwarding Detection,双向转发检测)
具体文档下载见:http://bbs.csc-china.com.cn/forum.php?mod=viewthread&tid=969503&extra=
路由协议的HELLO周期一般为10~30秒,三个周期的无响应才能确定链路的中断,所以依靠路由协议检测链路故障时延迟非常大。而在现在的高速网络中,网络延迟和设备延迟已经大大降低,完全可以采用更短的探测周期。提供毫秒级的链路连通性检测功能
基本理论
参考信息
介绍BFD的相关RFC清单。
本特性的参考资料清单如下:
文档
|
描述
|
备注
|
RFC 5880
|
Bidirectional Forwarding Detection
(BFD)
|
-
|
RFC 5881
|
Bidirectional Forwarding
Detection (BFD) for IPv4 and IPv6 (Single Hop)
|
-
|
RFC 5882
|
Generic Application of
Bidirectional Forwarding Detection (BFD)
|
-
|
RFC 5883
|
Bidirectional Forwarding
Detection (BFD) for Multihop Paths
|
-
|
RFC 5884
|
Bidirectional Forwarding
Detection (BFD) for MPLS Label Switched Paths (LSPs)
|
-
|
RFC 7130
|
Bidirectional Forwarding
Detection (BFD) on Link Aggregation Group (LAG) Interfaces
|
|
BFD本身并没有发现机制,而是靠被服务的上层协议通知其该与谁建立会话,会话建立后如果在检测时间内没有收到对端的BFD控制报文则认为发生故障,通知被服务的上层协议,上层协议进行相应的处理。
BFD能够在系统之间的任何类型通道上进行故障检测,这些通道包括直接的物理链路、虚电路、隧道、MPLS LSP、多跳路由通道,以及非直接的通道。
---------------------------------------------------------------------------------------------------------------------------------------
BFD会话建立流程图

上图所示是一个简单的网络组网,两台设备上同时配置了OSPF与BFD,BFD会话建立过程如下所示:
1. OSPF通过自己的Hello机制发现邻居并建立连接。
2. OSPF在建立了新的邻居关系后,将邻居信息(包括目的地址和源地址等)通告给BFD。
3. BFD根据收到的邻居信息建立会话。
4. 会话建立以后,BFD开始检测链路故障,并做出快速反应。
BFD故障发现处理流程图

如上图所示:
1. 被检测链路出现故障。
2. BFD快速检测到链路故障,BFD会话状态变为Down。
3. BFD通知本地OSPF进程BFD邻居不可达。
4. 本地OSPF进程中断OSPF邻居关系。
状态机迁移如下:

以BFD会话连接建立过程为例,简要介绍状态机迁移过程:

BFD抓包



BFD报文分为控制报文(control
packets)和回复报文(echo packets)。
BFD会话通过下面两种报文来实现:
· echo报文:封装在UDP报文中传送,其UDP目的端口号为3785。
· 控制报文:封装在UDP报文中传送,对于单跳检测其UDP目的端口号为3784,对于多跳检测其UDP目的端口号为4784。
BFD控制报文封装在UDP报文中传送,对于单跳检测其UDP目的端口号为3784,对于多跳检测其UDP目的端口号为4784(也可配置为3784,具体参见配置任务)。BFD echo报文与BFD控制报文格式类似(区别在于字段Desired Min TX Interval和Required Min RX
Interval为空),其UDP目的端口号为3785。
BFD会话的检测时间大于链路的延迟时间
本地BFD报文实际发送时间间隔=MAX { 本地配置的发送时间间隔,对端配置的接收时间间隔 };
本地实际接收时间间隔=MAX { 对端配置的发送时间间隔,本地配置的接收时间间隔};
本地实际检测时间=本地实际接收时间间隔×对端配置的BFD检测倍数。
例如,
·
本地配置的发送时间间隔为200ms,本地配置的接收时间间隔为300ms,本地检测倍数为4
·
对端配置的发送时间间隔为100ms,对端配置的接收时间间隔为600ms,对端检测倍数为5
则:
·
本地实际的发送时间间隔为MAX { 200ms,600ms }=600ms,
本地实际接收时间间隔为MAX { 100ms,300ms }=300ms,本地实际检测时间间隔为300ms×5=1500ms
·
对端实际的发送时间间隔为MAX { 100ms,300ms }=300ms,对端实际接收时间间隔为MAX { 200ms,600ms }=600ms,
对端实际检测时间间隔为600ms×4=2400ms
各个厂商
BFD配置情况
锐捷:缺省BFD运行版本1,同时兼容版本0。
H3C:缺省BFD运行版本1,同时兼容版本0。
HUAWEI:缺省BFD运行版本1,同时兼容版本0。
HuaWei交换机:
|
H3C交换机:
|
Ruijie交换机:
|
缺省配置
参数
|
缺省值
|
全局BFD功能
|
未使能
|
发送间隔
|
1000毫秒
|
接收间隔
|
1000毫秒
|
本地检测倍数
|
3
|
等待恢复时间
|
0分钟
|
会话延迟Up时间
|
0秒钟
|
BFD报文优先级
|
7
|
|
缺省配置
参数
|
缺省值
|
全局BFD功能
|
未使能
|
发送间隔
|
400毫秒
|
接收间隔
|
400毫秒
|
本地检测倍数
|
5
|
等待恢复时间
|
?分钟
|
会话延迟Up时间
|
?秒钟
|
|
???
|
Ruijie BFD配置命令
通过show bfd neighber 确认BFD邻居状态。
配置直连BFD联动(静态路由)
RSR-A(config)#ip
route 0.0.0.0 0.0.0.0 gigabitEthernet
0/0 1.1.1.1
//要和BFD联动,静态路由必须是配置出接口和下一跳;下一跳和对端BFD指定的源地址必须一致
RSR-A(config)#interface gigabitEthernet 0/0
RSR-A(config-GigabitEthernet 0/0)#bfd
interval 500 min_rx 500 multiplier 3
//配置BFD时间参数,该命令同时启用了接口的BFD功能,因此必须配置;
RSR-A(config-GigabitEthernet 0/0)#no bfd
echo
//推荐配置为该模式(ctrl模式),默认是bfd echo模式;
RSR-A(config)#ip route static bfd
GigabitEthernet 0/0 1.1.1.1 source 1.1.1.2
//BFD和静态路由联动,接口和下一跳相互对应
RSR-A(config)#arp 1.1.1.2 0022.2222.2222
arpa
//必须对这个跨跳的下一跳地址进行ARP绑定。配置跨跳BFD联动(静态路由)
配置OSPF与BFD联动
SWA(config)#interface gigabitEthernet 2/1
SWA(config-GigabitEthernet 2/1)#bfd
interval 500 min_rx 500 multiplier 3
SWA(config-GigabitEthernet 2/1)#no bfd echo
SWA(config-GigabitEthernet 2/1)#ip ospf
bfd //在对应的接口开启OSPF与BFD联动功能
SWA(config-router)# router ospf 123
SWA(config-router)# bfd all-interfaces ///////同样可以在OSPF全进程下启动BFD
---------------------------------------------------------------------------------------
配置BGP与BFD联动
RSR-B(config)#interface gigabitEthernet 2/1
RSR-B(config-GigabitEthernet 2/1)#bfd
interval 500 min_rx 500 multiplier 3
RSR-B(config-GigabitEthernet 0/0)#no bfd
echo
RSR-B(config-router)# router bgp 40000
RSR-B(config-router)# neighbor 172.16.11.1
fall-over bfd
HUAWEI BFD配置命令
通过display bfd session all verbose命令查看状态
配置直连BFD联动(静态路由)
[~SwitchA] bfd
[*SwitchA-bfd] quit
[*SwitchA] bfd atoc bind peer-ip 10.2.1.2
[*SwitchA-bfd-session-atoc] discriminator
local 10
////配置BFD会话的本地标识符(对端标识符需要配置颠倒)
[*SwitchA-bfd-session-atoc] discriminator
remote 20
////配置BFD会话的远端标识符(对端标识符需要配置颠倒)
[*SwitchA-bfd-session-atoc] commit
[~SwitchA-bfd-session-atoc] quit
ip route-static 0.0.0.0 0 x.x.x.x track
bfd-session aa
////配置到外部网络的静态缺省路由,并绑定BFD会话aa
---------------------------------------------------------------------------------------
配置OSPF与BFD联动
[~SwitchB] bfd
[*SwitchB-bfd] quit
[*SwitchB] ospf
[*SwitchB-ospf-1] bfd all-interfaces
enable
////在OSPF进程下使能BFD,邻居状态为Full的邻居都将创建BFD会话
[*SwitchB-ospf-1] quit
[*SwitchB] commit
[*SwitchB] interface vlanif 20
[*SwitchB-Vlanif20] ospf bfd enable
////接口配置的BFD特性优先级高于进程配置的BFD特性优先级。
如果打开了接口的BFD开关,则按照接口上BFD参数建立BFD会话。
[*SwitchB-Vlanif20] ospf bfd
min-tx-interval 100 min-rx-interval 100 detect-multiplier 4
[*SwitchB-Vlanif20] quit
[*SwitchB] commit
ospf bfd block ////接口配置模式下,阻止接口动态创建BFD会话。
使用display ospf bfd session all 命令查看BFD会话信息
---------------------------------------------------------------------------------------
配置BGP与BFD联动
[~SwitchA] bfd
[*SwitchA-bfd] quit
[*SwitchA] bgp 100
[*SwitchA-bgp] peer 192.168.1.2 bfd enable
[*SwitchA-bgp] peer 192.168.1.2 bfd
min-tx-interval 100 min-rx-interval 100 detect-multiplier 4
[*SwitchA-bgp] commit
命令peer { group-name | ipv4-address } bfd { min-tx-interval min-tx-interval | min-rx-interval min-rx-interval | detect-multiplier multiplier | wtr wtr-value }
使用display
bgp bfd session all 命令查看BFD会话信息
H3C BFD配置命令
显示BFD会话信息 display bfd
session [ discriminator value | verbose ]
清除BFD会话统计信息 reset bfd session statistics
配置直连BFD联动(静态路由)
<SwitchA> system-view
[SwitchA] interface vlan-interface 10
[SwitchA-vlan-interface10] bfd
min-transmit-interval 500
[SwitchA-vlan-interface10] bfd
min-receive-interval 500
[SwitchA-vlan-interface10] bfd
detect-multiplier 9
[SwitchA-vlan-interface10] quit
[SwitchA] ip route-static 120.1.1.0 24
vlan-interface 10 12.1.1.2 bfd control-packet
[SwitchA] ip route-static 120.1.1.0 24
vlan-interface 11 10.1.1.100 preference 65
[SwitchA] quit
---------------------------------------------------------------------------------------
配置OSPF与BFD联动
[SwitchA] bfd session init-mode active
[SwitchA] interface vlan-interface 10
[SwitchA-Vlan-interface10] ospf bfd enable
[SwitchA-Vlan-interface10] bfd min-transmit-interval
500
[SwitchA-Vlan-interface10] bfd
min-receive-interval 500
[SwitchA-Vlan-interface10] bfd
detect-multiplier 7
[SwitchA-Vlan-interface10] quit
[SwitchA] quit
<SwitchA> system-view
[SwitchA] interface vlan-interface 10
[SwitchA-vlan-interface10] bfd
min-transmit-interval 500
[SwitchA-vlan-interface10] bfd
min-receive-interval 500
[SwitchA-vlan-interface10] bfd
detect-multiplier 9
[SwitchA-vlan-interface10] quit
---------------------------------------------------------------------------------------
配置BGP与BFD联动
[SwitchA] bgp 200
[SwitchA-bgp] peer 3.0.2.2 bfd
[SwitchA-bgp] quit
<SwitchA> system-view
[SwitchA] interface vlan-interface 10
[SwitchA-vlan-interface10] bfd
min-transmit-interval 500
[SwitchA-vlan-interface10] bfd
min-receive-interval 500
[SwitchA-vlan-interface10] bfd
detect-multiplier 9
[SwitchA-vlan-interface10] quit
CISCO BFD配置命令
Configuring BFD
Session Parameters on the Interface
Router(config)# interface FastEthernet
6/0
Router(config-if)# bfd interval 50 min_rx
50 multiplier 5
Configuring BFD
Support for BGP
1. enable
2. configure terminal
3. router bgp as-tag
4. neighbor ip-address fall-over bfd
5. end
6. show bfd neighbors [details]
7. show ip bgp neighbor
Configuring BFD
Support for OSPF
1. enable
2. configure terminal
3. router ospf process-id
4. bfd all-interfaces
5. exit
6. interface name number
7. ip ospf bfd [disable]
8. end 9. show bfd neighbors [details]
10. show ip ospf
BFD 配错思路
BFD会话无法Up(HUAWEI)
常见原因
本故障的常见原因主要包括:
·
BFD会话检测的链路存在故障,导致BFD报文无法进行交互。
·
BFD会话频繁震荡。
操作步骤
1.
执行display
current-configuration configuration bfd命令
查看BFD会话两端的本地标识符和远端标识符是否匹配。
·
如果会话两端的discriminator local字段和discriminator remote字段匹配,则转到步骤2。
·
如果会话两端的discriminator local字段和discriminator remote字段不匹配,
则使用discriminator命令配置BFD会话的本地标识符和远端标识符,
然后使用display bfd session all命令查看BFD会话是否Up。
·
如果State字段的值为Up,则表明BFD会话已经建立。
·
如果State字段的值为非Up,则请转到步骤2。
2.
使用display
current-configuration configuration bfd命令,
查看BFD会话的min-tx-interval和min-rx-interval信息,
检查BFD会话的检测时间是否大于链路的延迟时间。
检测时间 = 接收到的远端Detect Multi × max(本地的RMRI,接收到的DMTI),
其中,Detect Mult(Detect
time multiplier)是检测倍数,通过detect-multiplier命令配置;
RMRI(Required Min Rx Interval)是本端能够支持的最短BFD报文接收间隔,
通过min-rx-interval命令配置;
DMTI(Desired Min Tx Interval)是本端想要采用的最短BFD报文的发送间隔,
通过min-tx-interval命令配置。
链路的延迟时间是指链路的时延,可通过ping或者tracert的方式获取链路的时延。
如果BFD会话的检测时间小于链路的延迟时间,则在BFD会话视图下执行detect-multiplier命令、min-rx-interval命令和min-tx-interval命令调整BFD会话的检测时间,使之大于链路的延迟时间。
BFD会话的检测时间大于链路的延迟时间
本地BFD报文实际发送时间间隔=MAX { 本地配置的发送时间间隔,对端配置的接收时间间隔 };
本地实际接收时间间隔=MAX { 对端配置的发送时间间隔,本地配置的接收时间间隔};
本地实际检测时间=本地实际接收时间间隔×对端配置的BFD检测倍数。
例如,
·
本地配置的发送时间间隔为200ms,本地配置的接收时间间隔为300ms,本地检测倍数为4
·
对端配置的发送时间间隔为100ms,对端配置的接收时间间隔为600ms,对端检测倍数为5
则:
·
本地实际的发送时间间隔为MAX { 200ms,600ms }=600ms,
本地实际接收时间间隔为MAX { 100ms,300ms
}=300ms,本地实际检测时间间隔为300ms×5=1500ms
·
对端实际的发送时间间隔为MAX { 100ms,300ms }=300ms,对端实际接收时间间隔为MAX { 200ms,600ms }=600ms,
对端实际检测时间间隔为600ms×4=2400ms
排错案例:
http://support.huawei.com/enterprise/KnowledgebaseReadAction.action?contentId=KB1000081754&idAbsPath=>
http://www.wenkuxiazai.com/doc/56ee07dbd1f34693daef3e74.html
http://www.h3c.com.cn/Service/TechnicalInfo/PorductMaintanInfo/Tech_Column/Hundred/Hundred/The_Two/Home/Catalog/201405/922012_30005_0.htm ////神仙眷侣走江湖——OSPF与BFD联动后BFD
Session DOWN问题排查技巧