BFD会话标识符
- 本地标识符 local discriminator
- 远端标识符 remote discriminator
BFD会话建立方式
- 静态建立BFD会话 通过命令手工配置BFD会话参数,包括本地标识符和远端标识符等,然后手工下发BFD会话建立请求。
- 动态建立BFD会话 系统对本地标识符和远端标识符的处理方式如下:
- 动态分配本地标识符
当应用程序(ospf等)触发动态创建BFD会话时,系统会分配属于动态标识符区域的值作为BFD会话的本地标识符。然后向对端发送remote discriminator的值为0的BFD控制报文,进行会话协商。
- 自学习远端标识符
当BFD会话一端收到remote discriminate的值为0的BFD控制报文时,判断该报文是否与本地BFD会话匹配 如果匹配,则学习接收到的BFD报文中的local discriminator的值,获取远端标识符。[将报文对端本地标识符作为本端的远端标识符]
- 动态分配本地标识符
BFD检测机制
- 两端建立BFD会话系统后,周期性发送BFD控制报文,如果一方在既定时间没有收到BFD控制报文,则认为路径上发生了故障
- 提供异步检测模式,在这种模式下,系统之间相互周期发送BFD控制报文,如果某个系统连续几个报文都没有收到,就认为此BFD为down状态 bfd demand enbale
BFD状态
- down init up adm
- 两端系统建立BDF与拆除BDF会话都采取三次握手机制,确保两端系统都能知道状态变化
BFD报文类型与结构
- 默认组播地址 224.0.0.184 [二层链路没有ip情况 用组播]
- 控制报文单跳检测(直连)端口号 udp:3784
- 控制报文多跳检测(跨网段)端口号 udp:3784、4784
- Echo报文 单臂回声(对端不支持BFD)端口号 udp:3785
BFD联动功能
- 监测模块 负责对链路状态、网络性能等进行监测,并将探测结果通知给track模块。
- track模块 收到监测模块的探测结果后,修改track项的状态,并通知应用模块。
- 应用模块 根据track项的状态,进行相应的处理,从而实现联动。
BFD思路
- 单跳绑定接口
- 三层接口 可以配置对端地址
- 二层接口 可以不配置对端地址 使用组播地址
- 多跳绑定ip [可以跨越多个网段]
- 单臂回声功能 [只适用于单跳BFD会话]
- 对于一端不支持BFD的环境,通过BFD报文的环回操作检测转发链路的连通性
- 接口状态联动
- 提高接口感应链路故障的灵敏度,减少非直连链路故障导致的问题
BFD默认配置参数
- 发送间隔TX 1000毫秒 [两端BFD协商之前发送与接受间隔时间为随机值 协商成功后为默认值]
min-tx-interval 100
2. 接收间隔RX 1000毫秒
min-rx-interval 100
3. 本地检测倍数 3
detect-multiplier 3
4. 等待恢复时间 0分钟
-
会话延迟up时间 0秒钟
-
BFD报文优先级 7(最高级)
收发间隔不一致问题计算
A:
最小发送间隔 300
最小接收间隔 800
实际发送间隔 600 [远端最小接受间隔]
实际接收间隔 800 [本端最小接收间隔]
检测倍数 3
实际检测间隔 3000 [对端检测倍数 * 实际发送间隔]
B:
最小发送间隔 500
最小接收间隔 600
实际发送间隔 800 [远端最小接收间隔]
实际接收间隔 600 [本端最小接收间隔]
检测倍数 5
实际检测间隔 2400 [对端检测倍数 * max(对端发送间隔,本端接收间隔)]
// 发的快,收的慢,取收的值;发的快降低发送频率。
BFD-二层组播形式配置
[LSW1]bfd // 使能BFD
[LSW1]bfd 1 bind peer-ip default-ip interface GigabitEthernet 0/0/1 // bfd使用组播地址形式且绑定e0/0/0
[LSW1-bfd-session-1]discriminator local 123 // 配置本地标识符
[LSW1-bfd-session-1]discriminator remote 321 // 配置远端标识符
[LSW1-bfd-session-1]commit // 提交配置
[LSW1]display bfd session all // 查看bfd信息
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
123 321 224.0.0.184 Down S_IP_IF GigabitEthernet0/0/1
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 0/1
[LSW1]
********************************************************************************
[LSW2]bfd // 使能BFD
[LSW2]bfd 1 bind peer-ip default-ip interface GigabitEthernet 0/0/1 // bfd使用组播地址形式且绑定e0/0/0
[LSW2-bfd-session-1]discriminator local 321 // 配置本地标识符 [组播地址本地与远端不能一致]
[LSW2-bfd-session-1]discriminator remote 123 // 配置远端标识符
[LSW2-bfd-session-1]commit // 提交配置
[LSW2]display bfd session all // 查看bfd信息
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
321 123 224.0.0.184 Up S_IP_IF GigabitEthernet0/0/1
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 1/0
[LSW2]
[LSW2]display bfd session peer-ip default-ip verbose
--------------------------------------------------------------------------------
Session MIndex : 256 (One Hop [单跳] ) State : Up Name : 1
--------------------------------------------------------------------------------
Local Discriminator : 321 Remote Discriminator : 123
Session Detect Mode : Asynchronous Mode Without Echo Function
BFD Bind Type : Interface(GigabitEthernet0/0/1)
Bind Session Type : Static [会话类别静态]
Bind Peer IP Address : 224.0.0.184 [对端组播ip]
NextHop Ip Address : 224.0.0.184
Bind Interface : GigabitEthernet0/0/1
FSM Board Id : 0 TOS-EXP : 7
Min Tx Interval (ms) : 1000 [最小发送间隔] Min Rx Interval (ms) : 1000
Actual Tx Interval (ms): 1000 [实际发送间隔] Actual Rx Interval (ms): 1000
Local Detect Multi : 3 [本地检测倍数] Detect Interval (ms) : 3000 [实际检测间隔]
Echo Passive : Disable Acl Number : -
Destination Port : 3784 TTL : 255
Proc Interface Status : Disable [状态关联]
WTR Interval (ms) : -
Active Multi : 3
Last Local Diagnostic : No Diagnostic
Bind Application : No Application Bind [绑定应用 ]
Session TX TmrID : 1035 Session Detect TmrID : 1036
Session Init TmrID : - Session WTR TmrID : -
Session Echo Tx TmrID : -
PDT Index : FSM-0 | RCV-0 | IF-0 | TOKEN-0
Session Description : -
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 1/0
[LSW2]
报文分析
BFD-三层单播形式配置
[AR1]interface GigabitEthernet 0/0/0
[AR1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
[AR1-GigabitEthernet0/0/0]quit
[AR1]bfd
[AR1-bfd]quit
[AR1]bfd 1 bind peer-ip 12.1.1.2 interface GigabitEthernet 0/0/0 // 远端地址为12.1.1.2 绑定0/0/0
[AR1-bfd-session-1]discriminator local 10
[AR1-bfd-session-1]discriminator remote 10
[AR1-bfd-session-1]commit
[AR1-bfd-session-1]quit
[AR1]display bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
10 10 12.1.1.2 Down S_IP_IF GigabitEthernet0/0/0
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 0/1
[AR1]
********************************************************************************
[AR2]interface GigabitEthernet 0/0/0
[AR2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
[AR2-GigabitEthernet0/0/0]quit
[AR2]bfd
[AR2-bfd]quit
[AR2]bfd 1 bind peer-ip 12.1.1.1 interface GigabitEthernet 0/0/0
[AR2-bfd-session-1]discriminator local 10
[AR2-bfd-session-1]discriminator remote 10
[AR2-bfd-session-1]commit
[AR2-bfd-session-1]quit
[AR2]
[AR2]display bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
10 10 12.1.1.1 Up S_IP_IF GigabitEthernet0/0/0
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 1/0
[AR2]
********************************************************************************
[AR1]display bfd session peer-ip 12.1.1.2 verbose
--------------------------------------------------------------------------------
Session MIndex : 64 (One Hop [单跳] ) State : Up Name : 1
--------------------------------------------------------------------------------
Local Discriminator : 10 Remote Discriminator : 10
Session Detect Mode : Asynchronous Mode Without Echo Function
BFD Bind Type : Interface(GigabitEthernet0/0/0)
Bind Session Type : Static
Bind Peer IP Address : 12.1.1.2 [单播地址]
NextHop Ip Address : 12.1.1.2
Bind Interface : GigabitEthernet0/0/0
FSM Board Id : 0 TOS-EXP : 7
Min Tx Interval (ms) : 1000 Min Rx Interval (ms) : 1000
Actual Tx Interval (ms): 1000 Actual Rx Interval (ms): 1000
Local Detect Multi : 3 Detect Interval (ms) : 3000
Echo Passive : Disable Acl Number : -
Destination Port : 3784 TTL : 255
Proc Interface Status : Disable Process PST : Disable
WTR Interval (ms) : -
Active Multi : 3
Last Local Diagnostic : No Diagnostic
Bind Application : No Application Bind
Session TX TmrID : - Session Detect TmrID : -
Session Init TmrID : - Session WTR TmrID : -
Session Echo Tx TmrID : -
PDT Index : FSM-0 | RCV-0 | IF-0 | TOKEN-0
Session Description : -
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 1/0
[AR1]
单臂回声配置
[AR2]interface GigabitEthernet 0/0/1
[AR2-GigabitEthernet0/0/1]ip address 23.1.1.2 24
[AR2-GigabitEthernet0/0/1]quit
[AR2]bfd 2 bind peer-ip 23.1.1.3 interface GigabitEthernet 0/0/1 one-arm-echo // 单臂回声只能单跳
[AR2-bfd-session-2]discriminator local 20 // 单臂回声只能配置本地标识符
[AR2-bfd-session-2]commit
[AR3]interface GigabitEthernet 0/0/0
[AR3-GigabitEthernet0/0/0]ip address 23.1.1.3 24
[AR3-GigabitEthernet0/0/0]quit
[AR3]
********************************************************************************
[AR2]display bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
10 10 12.1.1.1 Up S_IP_IF GigabitEthernet0/0/0
20 - 23.1.1.3 Up S_IP_IF GigabitEthernet0/0/1
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 2/0
[AR2]
三层多跳检测
[AR1]ip route-static 0.0.0.0 0 12.1.1.2 // 多跳检测时 请保证目标地址可达
[AR1]bfd 2 bind peer-ip 23.1.1.3 // bfd进程号本地有效
[AR1-bfd-session-2]discriminator local 123
[AR1-bfd-session-2]discriminator remote 321
[AR1-bfd-session-2]commit
[AR1-bfd-session-2]quit
[AR3]ip route-static 0.0.0.0 0 23.1.1.2
[AR3]bfd
[AR3-bfd]quit
[AR3]bfd 1 bind peer-ip 12.1.1.1
[AR3-bfd-session-1]discriminator local 321
[AR3-bfd-session-1]discriminator remote 123
[AR3-bfd-session-1]commit
[AR3-bfd-session-1]quit
********************************************************************************
[AR1]display bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
10 10 12.1.1.2 Up S_IP_IF GigabitEthernet0/0/0
123 321 23.1.1.3 Up S_IP_PEER -
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 2/0
[AR1]
[AR1]display bfd session peer-ip 23.1.1.3 verbose
--------------------------------------------------------------------------------
Session MIndex : 65 (Multi Hop [多跳] ) State : Up Name : 2
--------------------------------------------------------------------------------
Local Discriminator : 123 Remote Discriminator : 321
Session Detect Mode : Asynchronous Mode Without Echo Function
BFD Bind Type : Peer IP Address
Bind Session Type : Static
Bind Peer IP Address : 23.1.1.3
Bind Interface : -
Track Interface : -
FSM Board Id : 0 TOS-EXP : 7
Min Tx Interval (ms) : 1000 Min Rx Interval (ms) : 1000
Actual Tx Interval (ms): 1000 Actual Rx Interval (ms): 1000
Local Detect Multi : 3 Detect Interval (ms) : 3000
Echo Passive : Disable Acl Number : -
Destination Port : 3784 TTL : 254
Proc Interface Status : Disable Process PST : Disable
WTR Interval (ms) : -
Active Multi : 3
Last Local Diagnostic : No Diagnostic
Bind Application : No Application Bind
Session TX TmrID : - Session Detect TmrID : -
Session Init TmrID : - Session WTR TmrID : -
Session Echo Tx TmrID : -
PDT Index : FSM-1 | RCV-0 | IF-0 | TOKEN-0
Session Description : -
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 1/0
[AR1]
报文分析
BFD联动技术
配置与接口状态联动
注意 单跳组播地址可用 指定地址不可用
[Huawei]bfd 1
[Huawei-bfd-session-1]process-interface-status // 与接口状态联动
[Huawei-bfd-session-1]quit
[Huawei]dis int g0/0/2
GigabitEthernet0/0/2 current state : UP
Line protocol current state : UP(BFD status down) // 链路层状态为down
Description:
Switch Port, PVID : 1, TPID : 8100(Hex), The Maximum Frame Length is 9216
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-ccd2-556c
Last physical up time : 2024-09-03 00:02:18 UTC-08:00
Last physical down time : 2024-09-03 00:02:17 UTC-08:00
Current system time: 2024-09-03 00:19:32-08:00
Hardware address is 4c1f-ccd2-556c
Last 300 seconds input rate 0 bytes/sec, 0 packets/sec
Last 300 seconds output rate 0 bytes/sec, 0 packets/sec
Input: 114266 bytes, 1399 packets
Output: 70232 bytes, 1053 packets
Input:
Unicast: 974 packets, Multicast: 423 packets
Broadcast: 2 packets
Output:
Unicast: 1020 packets, Multicast: 33 packets
Broadcast: 0 packets
Input bandwidth utilization : 0%
Output bandwidth utilization : 0%
配置与静态路由联动
```
[AR1]ip route-static 0.0.0.0 0 GigabitEthernet 0/0/1 preference 70 // 配置浮动路由
[AR1]dis ip routing-table protocol static // 查看路由激活状态
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : Static
Destinations : 1 Routes : 2 Configured Routes : 2
Static routing table status : <Active 激活 >
Destinations : 1 Routes : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 60 0 RD 12.1.1.2 GigabitEthernet
0/0/0
Static routing table status : <Inactive 未激活 >
Destinations : 1 Routes : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 70 0 16.1.1.1 GigabitEthernet
0/0/1
[AR1]
[AR1]ip route-static 0.0.0.0 0 12.1.1.2 track bfd-session 2 // 将默认路由绑定bfd
**********************************************************************************
[AR2-GigabitEthernet0/0/1]shutdown
**********************************************************************************
[AR1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 70 0 D 16.1.1.1 GigabitEthernet
0/0/1
12.1.1.0/24 Direct 0 0 D 12.1.1.1 GigabitEthernet
0/0/0
12.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
12.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
16.1.1.0/24 Direct 0 0 D 16.1.1.1 GigabitEthernet
0/0/1
16.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
16.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[AR1]
```
配置与OSPF联动
[R1]bfd
[R1]display ospf peer brief
OSPF Process 1 with Router ID 1.1.1.1
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 2.2.2.2 Full
0.0.0.0 GigabitEthernet0/0/1 3.3.3.3 Full
----------------------------------------------------------------------------
[R1]ospf 1
[R1-ospf-1]bfd all-interfaces enable // 所有接口开启bfd检测
[R1-ospf-1]quit
[R1]
[R1]dis bfd session dynamic
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
8192 8192 13.1.1.3 Up D_IP_IF GigabitEthernet0/0/1
8193 8193 12.1.1.2 Up D_IP_IF GigabitEthernet0/0/0
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 2/0
[R1]
[R1]display bfd session peer-ip 12.1.1.2
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
8193 8193 12.1.1.2 Up D_IP_IF GigabitEthernet0/0/0
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 1/0
[R1]dis bfd session peer-ip 12.1.1.2 v
[R1]dis bfd session peer-ip 12.1.1.2 verbose
--------------------------------------------------------------------------------
Session MIndex : 514 (One Hop) State : Up Name : dyn_8193
--------------------------------------------------------------------------------
Local Discriminator : 8193 Remote Discriminator : 8193
Session Detect Mode : Asynchronous Mode Without Echo Function
BFD Bind Type : Interface(GigabitEthernet0/0/0)
Bind Session Type : Dynamic // 动态
Bind Peer IP Address : 12.1.1.2
NextHop Ip Address : 12.1.1.2
Bind Interface : GigabitEthernet0/0/0
FSM Board Id : 0 TOS-EXP : 7
Min Tx Interval (ms) : 1000 Min Rx Interval (ms) : 1000
Actual Tx Interval (ms): 1000 Actual Rx Interval (ms): 1000
Local Detect Multi : 3 Detect Interval (ms) : 3000
Echo Passive : Disable Acl Number : -
Destination Port : 3784 TTL : 255
Proc Interface Status : Disable Process PST : Disable
WTR Interval (ms) : -
Active Multi : 3
Last Local Diagnostic : No Diagnostic
Bind Application : OSPF // 配置与ospf联动
Session TX TmrID : - Session Detect TmrID : -
Session Init TmrID : - Session WTR TmrID : -
Session Echo Tx TmrID : -
PDT Index : FSM-1 | RCV-0 | IF-0 | TOKEN-0
Session Description : -
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 1/0
[R1]
其他联动方式
1. 与BGP联动
peer x.x.x.x bfd enable
2. 与vrrp联动
vrrp vrid 1 track bfd-session 10