Cisco OSPF 实验 DR/BDR的选取

实验级别:Professional
情况一:
我们都知道OSPF选取DR的过程是首先比较优先级,在优先级相同的情况下选择RID较高的为DR,但是我多次实验后发现在很多时候DR并非RID最高的路由器,这是什么原因呢?

在翻阅了卷一有关OSPF DR选取的介绍时,发现了这么一句话:“在一个多址网络上,最先初始化启动的两台具有DR选取资格的路由器将成为DR和BDR路由器。”这是我总结了非最高RID而成为DR的实验,发现这些路由器都是我在进行OSPF配置的时候首先启动ospf的路由器,那会不会是因为这些路由器首先启动了OSPF,然后把自己设置为DR导致其他路由器启动OSPF后就不再进行DR的选取了呢?于是我做了下面的这个实验。

实验的topo很简单,我就不画了,就是两台路由器通过fa0/0口相连接。
R1:
conf t
ho R1
int lo0
ip add 1.1.1.1 255.255.255.0
int fa0/0
ip add 172.1.1.1 255.255.255.0
no sh
router ospf 10
net 172.1.1.1 0.0.0.0 a 0

R2:
conf t
ho R2
int lo0
ip add 2.2.2.2 255.255.255.0
int fa0/0
ip add 172.1.1.2 255.255.255.0
no sh

R1启动ospf进程后,我们在R2上暂时先不开启ospf,在R1上发现了以下信息:

R1#sho ip ospf int
FastEthernet0/0 is up, line protocol is up
   Internet Address 172.1.1.1/24, Area 0
   Process ID 10, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1
   Transmit Delay is 1 sec, State DR, Priority 1
   Designated Router (ID) 1.1.1.1, Interface address 172.1.1.1
   No backup designated router on this network
   Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:01
   Index 1/1, flood queue length 0
   Next 0x0(0)/0x0(0)
   Last flood scan length is 0, maximum is 0
   Last flood scan time is 0 msec, maximum is 0 msec
   Neighbor Count is 0, Adjacent neighbor count is 0
   Suppress hello for 0 neighbor(s)
rhce 教材
我们看到R1已经把自己设定为DR了,按照OSPF的规则,新加入的路由器即使RID比DR高,也不会替换DR。这就说明了为什么在有些时候DR并非RID最高的路由器。

当然这个实验也顺便验证了ospf中DR选取结束后,除非DR路由器出现故障,否则就是有更高优先级或者RID的路由器进入OSPF进程,也是无法改变DR的。既DR是不可以抢夺的!

情况二(本实验参照了ITAA实验室Netfish的实验):
ospf中有一个Wait Timer计时器,在这个计时器所限定的时间内起来的OSPF可以视为同时起机。

TCP/IP卷1第292页对于这个时间间隔是这样定义的:
Wait Timer:在开始选举DR和BDR之间,路由器等待邻居路由器的Hello数据包通告DR和BDR的时长。长度就是RouterDeadInterval的时间。

本实验拓扑与情况一相同,不同的地方在于当我们在R1上启动OSPF后,迅速(一定要迅速,非常迅速!40s之内)在R2上也启动ospf,通过debug信息可以看到以下情况:
R1#debug ip ospf adj
OSPF adjacency events debugging is on
R1#debug ip ospf ev
OSPF events debugging is on
*Aug 14 00:56:19.047: OSPF: Interface FastEthernet0/0 going Up
*Aug 14 00:56:19.051: OSPF: Send hello to 224.0.0.5 area 0 on FastEthernet0/0 from 172.1.1.1
*Aug 14 00:56:19.551: OSPF: Build router LSA for area 0, router ID 1.1.1.1, seq 0x80000001
*Aug 14 00:56:19.555: OSPF: Rcv hello from 2.2.2.2 area 0 from FastEthernet0/0 172.1.1.2
*Aug 14 00:56:19.555: OSPF: End of hello processing
R1(config-router)#
*Aug 14 00:56:29.051: OSPF: Send hello to 224.0.0.5 area 0 on FastEthernet0/0 from 172.1.1.1
*Aug 14 00:56:29.451: OSPF: Rcv hello from 2.2.2.2 area 0 from FastEthernet0/0 172.1.1.2
*Aug 14 00:56:29.455: OSPF: 2 Way Communication to 2.2.2.2 on FastEthernet0/0, state 2WAY
*Aug 14 00:56:29.455: OSPF: End of hello processing
R1(config-router)#
*Aug 14 00:56:39.051: OSPF: Send hello to 224.0.0.5 area 0 on FastEthernet0/0 from 172.1.1.1
*Aug 14 00:56:39.427: OSPF: Rcv hello from 2.2.2.2 area 0 from FastEthernet0/0 172.1.1.2
*Aug 14 00:56:39.427: OSPF: End of hello processing
R1(config-router)#
*Aug 14 00:56:49.051: OSPF: Send hello to 224.0.0.5 area 0 on FastEthernet0/0 from 172.1.1.1
*Aug 14 00:56:49.447: OSPF: Rcv hello from 2.2.2.2 area 0 from FastEthernet0/0 172.1.1.2
*Aug 14 00:56:49.447: OSPF: End of hello processing
R1(config-router)#
*Aug 14 00:56:59.051: OSPF: end of Wait on interface FastEthernet0/0
*Aug 14 00:56:59.051: OSPF: DR/BDR election on FastEthernet0/0
*Aug 14 00:56:59.051: OSPF: Elect BDR 2.2.2.2
*Aug 14 00:56:59.055: OSPF: Elect DR 2.2.2.2
*Aug 14 00:56:59.055:        DR: 2.2.2.2 (Id) BDR: 2.2.2.2 (Id)
*Aug 14 00:56:59.055: OSPF: Send DBD to 2.2.2.2 on FastEthernet0/0 seq 0x826 opt 0x52 flag 0x7 len 32
*Aug 14 00:56:59.059: OSPF: Send hello to 224.0.0.5 area 0 on FastEthernet0/0 from 172.1.1.1
*Aug 14 00:56:59.459: OSPF: Rcv hello from 2.2.2.2 area 0 from FastEthernet0/0 172.1.1.2
*Aug 14 00:56:59.463: OSPF: Neighbor change Event on interface FastEthernet0/0
*Aug 14 00:56:59.463: OSPF: DR/BDR election on FastEthernet0/0
*Aug 14 00:56:59.463: OSPF: Elect BDR 1.1.1.1
*Aug 14 00:56:59.467: OSPF: Elect DR 2.2.2.2
*Aug 14 00:56:59.467: OSPF: Elect BDR 1.1.1.1
*Aug 14 00:56:59.467: OSPF: Elect DR 2.2.2.2
*Aug 14 00:56:59.471:        DR: 2.2.2.2 (Id) BDR: 1.1.1.1 (Id)

这个时候我们发现两个路由器进行了DR/BDR的选取,并且结论和书上介绍的完全一致。

从Debug信息的时间上来看,从启动OSPF进程到开始选举DR和DBR的时间间隔是40秒,在这个时间段内,无论R1还是R2并没有选举DR和DBR。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/25703.html