标签:because 出接口 tty 相互 图片 状态机 ati extend rtu
BFD出现的技术背景
RTA和RTD建立了OSPF邻接关系,Hello包发送周期为10秒;当交换机SWB与SWC链路物理中断,路由器RTA和RTD无法感知,需要等待OSPF协议邻居失效计时器超时后才会中断邻接关系
SWA和SWB启用了VRRP协议,实现了主备网关的作用,SWB为主用网关。
当出口路由器RTB与外网Router的链路中断,SWB虽然可以通过动态路由协议感知,但是无法联动连接下游的网关接口,且继续为主网关。
用户的数据流还是发送到SWB,SWB再通过三层路由转发给SWA,最后由RTA出口。虽然结果不至于造成业务中断,但是会产生次优路径。
一种全网统一、检测迅速、监控网络中链路或者IP路由的双向转发连通状况,并为上层应用提供服务的技
BFD会话建立后会周期性地快速发送BFD报文,如果在检测时间内没有收到对端BFD报文则认为该双向转发路径发生了故障,通知被服务的相关层应用进行相应的处理。
本身并没有邻居发现机制,而是靠被服务的上层应用通知其邻居信息以建立会话。
不管是物理接口状态、二层链路状态、网络层地址可达性、还是传输层连接状态、应用层协议运行状态,都可以被BFD感知到
BFD建立会话存在标识符的概念,类似于OSPF建立邻居需要一个路由器的Router ID。
标识符分为本地标识符和远端标识符,本地标识符用于表示本端设备,远端标识符用于表示对端设备。
静态建立BFD会话是指通过命令行手工配置BFD会话参数,包括配置本地标识符和远端标识符等,然后手工下发BFD会话建立请求。
动态建立BFD会话是指由应用程序触发创建BFD会话,当应用程序动态触发创建BFD会话时,系统分配属于动态会话标识符区域的值作为BFD会话的本地标识符。然后向对端发送Remote Discriminator的值为0的BFD控制报文,进行会话协商。当BFD会话的一端收到Remote Discriminator的值为0的BFD控制报文时,判断该报文是否与本地BFD会话匹配,如果匹配,则学习接收到的BFD报文中Local Discriminator的值,获取远端标识符。
BFD的检测机制是两个系统建立BFD会话,并沿它们之间的路径周期性发送BFD控制报文,如果一方在既定的时间内没有收到BFD控制报文,则认为路径上发生了故障,BFD控制报文是UDP报文,端口号3784。
BFD提供异步检测模式。在这种模式下,系统之间相互周期性地发送BFD控制报文,如果某个系统连续3个报文都没有接收到,就认为此BFD会话的状态是Down
RTA和RTB各自启动BFD状态机,初始状态为Down,发送状态为Down的BFD报文。对于静态配置BFD会话,报文中的Remote Discriminator的值是用户指定的;对于动态创建BFD会话,Remote Discriminator的值是0。
RTB收到状态为Down的BFD报文后,状态切换至Init,并发送状态为Init的BFD报文。
RTB本地BFD状态为Init后,不再处理接收到的状态为Down的报文。
RTB收到状态为Init的BFD报文后,本地状态切换至Up。
RTA的BFD状态变化同RTB。
邻居会话建立成功后,RTA和RTB周期性的向对方发送状态为Up的控制报文。
某公司通过两台二层交换机作为中继将两个相距较远的部门连接。RTA、RTD上运行OSPF,建立OSPF邻居关系,保证网络层相互可达。
已知RTA、RTB都支持BFD功能,要求使用OSPF与BFD联动技术,采用BFD控制报文方式实现当RTA或RTB与二层交换机之间以及二层交换机之间的链路出现故障(如链路down)时,BFD能够快速感知并通告OSPF协议。
#
sysname RA
#
bfd
#
interface GigabitEthernet0/0/1
ip address 10.0.12.1 255.255.255.0
#
ospf 1
bfd all-interfaces enable
area 0.0.0.0
network 10.0.12.0 0.0.0.255
#
#
sysname RD
#
interface GigabitEthernet0/0/1
ip address 10.0.12.2 255.255.255.0
#
Bfd
#
ospf 1
bfd all-interfaces enable
area 0.0.0.0
network 10.0.12.0 0.0.0.255
#
[RA]display ospf peer brief
OSPF Process 1 with Router ID 10.0.12.1
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/1 10.0.12.2 Full
----------------------------------------------------------------------------
[RA]display bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
8192 8192 10.0.12.2 Up D_IP_IF GigabitEthernet0/0/1
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 1/0
[RA]
[SW1-GigabitEthernet0/0/2]shutdown
弹出的一些日志信息
Sep 28 2019 17:04:18-08:00 RA %%01BFD/4/STACHG_TODWN(l)[8]:BFD session changed t
o Down. (SlotNumber=0, Discriminator=2097152, Diagnostic=DetectDown, Application
s=OSPF, ProcessPST=False, BindInterfaceName=GigabitEthernet0/0/1, InterfacePhysi
calState=Up, InterfaceProtocolState=Up)
Sep 28 2019 17:04:18-08:00 RA %%01OSPF/3/NBR_CHG_DOWN(l)[9]:Neighbor event:neigh
bor state changed to Down. (ProcessId=256, NeighborAddress=2.12.0.10, NeighborEv
ent=KillNbr, NeighborPreviousState=Full, NeighborCurrentState=Down)
Sep 28 2019 17:04:18-08:00 RA %%01OSPF/3/NBR_DOWN_REASON(l)[10]:Neighbor state l
eaves full or changed to Down. (ProcessId=256, NeighborRouterId=2.12.0.10, Neigh
borAreaId=0, NeighborInterface=GigabitEthernet0/0/1,NeighborDownImmediate reason
=Neighbor Down Due to Kill Neighbor, NeighborDownPrimeReason=BFD Session Down, N
eighborChangeTime=2019-09-28 17:04:18-08:00)
[RA]display bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
8192 0 10.0.12.2 Down D_IP_IF GigabitEthernet0/0/1
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 0/1
查看OSPF的邻居状态信息
[RA]display ospf peer brief
OSPF Process 1 with Router ID 10.0.12.1
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
----------------------------------------------------------------------------
中间的链路故障,BFD通过监测模块进行检测,然后交给track模块,由追踪模块交给应用模块,也就是OSPF进程进行处理
VRRP的配置参考上面
#
Bfd //全局启动BFD协议
#
bfd 1 bind peer-ip 10.0.24.2 source-ip 10.0.45.5 auto //因为当中没有任何动态路由协议 所以需要手动指定邻居的IP地址和自己的IP地址 后面的auto就是让其动态产生本地标识符
commit //有一些交换机里面需要commit一下bfd的配置
进行查看BFD的会话
<RA>display bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
8195 8194 10.0.12.2 Up D_IP_IF GigabitEthernet0/0/1
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 1/0
<RA>
#
sysname RA
#
interface GigabitEthernet0/0/0
ip address 13.1.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 10.0.0.1 255.255.255.0
vrrp vrid 1 virtual-ip 10.0.0.10
vrrp vrid 1 priority 120
vrrp vrid 1 preempt-mode timer delay 20
vrrp vrid 1 track interface GigabitEthernet0/0/0 reduced 30
vrrp vrid 1 track bfd-session session-name 1 reduced 30
#
bfd 1 bind peer-ip 13.1.1.3 source-ip 13.1.1.1 auto
commit
#
ip route-static 3.3.3.3 255.255.255.255 13.1.1.3
#
#
sysname RB
#
interface GigabitEthernet0/0/0
ip address 23.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 10.0.0.2 255.255.255.0
vrrp vrid 1 virtual-ip 10.0.0.10
#
ip route-static 3.3.3.3 255.255.255.255 23.1.1.3
#
#
sysname RC
#
interface GigabitEthernet0/0/0
ip address 13.1.1.3 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 23.1.1.3 255.255.255.0
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
bfd 1 bind peer-ip 13.1.1.1 source-ip 13.1.1.3 auto
commit
#
ip route-static 10.0.0.0 255.255.255.0 13.1.1.1
ip route-static 10.0.0.0 255.255.255.0 23.1.1.2
#
[RA]display bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
8192 8192 13.1.1.3 Up S_AUTO_PEER -
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 1/0
[RA]display vrrp
GigabitEthernet0/0/1 | Virtual Router 1
State : Master
Virtual IP : 10.0.0.10
Master IP : 10.0.0.1
PriorityRun : 120
PriorityConfig : 120
MasterPriority : 120
Preempt : YES Delay Time : 20 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0101
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Track IF : GigabitEthernet0/0/0 Priority reduced : 30
IF state : UP
Track BFD : 1 Priority reduced : 30
BFD-session state : UP
Create time : 2019-09-28 17:15:24 UTC-08:00
Last change time : 2019-09-28 17:26:50 UTC-08:00
PC>tracert 3.3.3.3
traceroute to 3.3.3.3, 8 hops max
(ICMP), press Ctrl+C to stop
1 10.0.0.1 63 ms 46 ms 47 ms
2 3.3.3.3 63 ms 62 ms 47 ms
[SW3-GigabitEthernet0/0/1]shutdown
[RA]
Sep 28 2019 17:34:22-08:00 RA %%01BFD/4/STACHG_TODWN(l)[16]:BFD session changed
to Down. (SlotNumber=0, Discriminator=2097152, Diagnostic=DetectDown, Applicatio
ns=VRRP | AUTO, ProcessPST=False, BindInterfaceName=None, InterfacePhysicalState
=None, InterfaceProtocolState=None)
[RA]
Sep 28 2019 17:34:22-08:00 RA VRRP/2/VRRPMASTERDOWN:OID 16777216.50331648.100663
296.16777216.67108864.16777216.3674669056.83886080.419430400.2130706432.33554432
.503316480.16777216 The state of VRRP changed from master to other state. (VrrpI
fIndex=67108864, VrId=16777216, IfIndex=67108864, IPAddress=1.1.1.13, NodeName=R
A, IfName=GigabitEthernet0/0/1, CurrentState=Backup, ChangeReason=priority calcu
lation)
[RA]
Sep 28 2019 17:34:22-08:00 RA %%01VRRP/4/STATEWARNINGEXTEND(l)[17]:Virtual Route
r state MASTER changed to BACKUP, because of priority calculation. (Interface=Gi
gabitEthernet0/0/1, VrId=16777216, InetType=IPv4)
[RA]
[RA]display bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------
8192 0 13.1.1.3 Down S_AUTO_PEER -
--------------------------------------------------------------------------------
Total UP/DOWN Session Number : 0/1
[RA]display vrrp
GigabitEthernet0/0/1 | Virtual Router 1
State : Backup
Virtual IP : 10.0.0.10
Master IP : 10.0.0.2
PriorityRun : 90
PriorityConfig : 120
MasterPriority : 100
Preempt : YES Delay Time : 20 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0101
Check TTL : YES
Config type : normal-vrrp
Backup-forward : disabled
Track IF : GigabitEthernet0/0/0 Priority reduced : 30
IF state : UP
Track BFD : 1 Priority reduced : 30
BFD-session state : DOWN
Create time : 2019-09-28 17:15:24 UTC-08:00
Last change time : 2019-09-28 17:34:22 UTC-08:00
PC>tracert 3.3.3.3
traceroute to 3.3.3.3, 8 hops max
(ICMP), press Ctrl+C to stop
1 10.0.0.2 47 ms 47 ms 47 ms
2 3.3.3.3 46 ms 47 ms 47 ms
PC>
单臂回声功能:
是指通过BFD报文的环回操作检测转发链路的连通性。
两台直接相连的设备中RTA和RTB,其中一台设备RTA支持BFD功能,另一台设备RTB不支持BFD功能,只支持基本的网络层转发。为了能够快速的检测这两台设备之间的故障,可以在支持BFD功能的设备RTA上创建单臂回声功能的BFD会话。RTA主动发起回声请求功能,不支持BFD功能的设备RTB接收到该报文后直接将其环回,从而实现转发链路的连通性检测功能。
实现的技术原理就是支持BFD功能的路由器RTA在出接口发送目的地址和源地址都是自己的BFD探测报文,不支持BFD功能的路由器RTB收到探测报文就直接回发给路由器RTA。
<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan 13
[SwitchA-vlan13] quit
[SwitchA] interface gigabitethernet 0/0/1
[SwitchA-GigabitEthernet0/0/1] port link-type hybrid
[SwitchA-GigabitEthernet0/0/1] port hybrid pvid vlan 13
[SwitchA-GigabitEthernet0/0/1] port hybrid untagged vlan 13
[SwitchA-GigabitEthernet0/0/1] quit
[SwitchA] interface vlanif13
[SwitchA-Vlanif13] ip address 10.1.1.5 24
[SwitchA-Vlanif13] quit
[SwitchA] bfd
[SwitchA-bfd] quit
[SwitchA] bfd atob bind peer-ip 10.1.1.6 interface vlanif13 source-ip 10.1.1.5 one-arm-echo
[SwitchA-bfd-session-atob] discriminator local 1
[SwitchA-bfd-session-atob] min-echo-rx-interval 100
[SwitchA-bfd-session-atob] commit
[SwitchA-bfd-session-atob] quit
<HUAWEI> system-view
[HUAWEI] sysname SwitchB
[SwitchB] vlan 13
[SwitchB-vlan13] quit
[SwitchB] interface gigabitethernet 0/0/1
[SwitchB-GigabitEthernet0/0/1] port link-type hybrid
[SwitchB-GigabitEthernet0/0/1] port hybrid pvid vlan 13
[SwitchB-GigabitEthernet0/0/1] port hybrid untagged vlan 13
[SwitchB-GigabitEthernet0/0/1] quit
[SwitchB] interface vlanif13
[SwitchB-Vlanif13] ip address 10.1.1.6 24
[SwitchB-Vlanif13] quit
[SwitchA] display bfd session all verbose
--------------------------------------------------------------------------------
Session MIndex : 256 (One Hop) State : Up Name : atob
--------------------------------------------------------------------------------
Local Discriminator : 1 Remote Discriminator : -
Session Detect Mode : Asynchronous One-arm-echo Mode
BFD Bind Type : Interface(Vlanif13)
Bind Session Type : Static
Bind Peer IP Address : 10.1.1.6
NextHop Ip Address : 10.1.1.6
Bind Interface : Vlanif13
Bind Source IP Address : 10.1.1.5
FSM Board Id : 0 TOS-EXP : 7
Echo Rx Interval (ms) : 100
Actual Tx Interval (ms): 100 Actual Rx Interval (ms): 100
Local Detect Multi : 3 Detect Interval (ms) : 300
Echo Passive : Disable Acl Number : -
Destination Port : 3784 TTL : 255
Proc Interface Status : Disable Process PST : Disable
WTR Interval (ms) : -
Active Multi : 3 DSCP : -
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
标签:because 出接口 tty 相互 图片 状态机 ati extend rtu
原文地址:https://blog.51cto.com/13817711/2457249