3.2RIP 定时器情况 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

实验连接图

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />

提要描述

RIP 定时器

更新定时器: 30 秒(用于设置定期路由更新的时间间隔)

无效定时器: 180 秒(路由器在认定一个路由成为无效路由之前所需要等待的时间)

保持定时器: 180 秒(用于设置路由信息被抑制的时间)

刷新定时器: 240 秒(用于设置某个路由成为无效路由并将它从路由表中删除的时间)

实验目标:通过实验调试 RIP ,观察定时器的情况,理解定时器的原理。

基本配置

R1 的配置

R2 的配置

!

hostname R1

!

interface Loopback0

 ip address 1.1.1.1 255.255.255.0

!

interface Serial1/1

 no shut

 ip address 12.1.1.1 255.255.255.0

clock rate 64000

!

router rip

 network 0.0.0.0

!

!

hostname R2

!

interface Loopback0

 ip address 2.2.2.2 255.255.255.0

!

interface Serial1/0

no shut

 ip address 12.1.1.2 255.255.255.0

!

interface Serial1/1

 no shut

 ip address 23.1.1.2 255.255.255.0

!

router rip

 network 0.0.0.0

!

R3 的配置

 
!

hostname R3

!

interface Loopback0

 ip address 3.3.3.3 255.255.255.0

!

interface Serial1/0

 no shut

 ip address 23.1.1.3 255.255.255.0

clock rate 64000

!

router rip

network 0.0.0.0

!

 
↓调试配置及监测步骤↓

查看各路由器路由表的情况:

R1#show ip route

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
R    2.0.0.0/8 [120/1] via 12.1.1.2, 00:00:00, Serial1/1

R    3.0.0.0/8 [120/2] via 12.1.1.2, 00:00:00, Serial1/1

R    23.0.0.0/8 [120/1] via 12.1.1.2, 00:00:00, Serial1/1

     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/1
R2#show ip route

R    1.0.0.0/8 [120/1] via 12.1.1.1, 00:00:26, Serial1/0

     2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
R    3.0.0.0/8 [120/1] via 23.1.1.3, 00:00:10, Serial1/1

     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial1/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/0
R3#show ip route

R    1.0.0.0/8 [120/2] via 23.1.1.2, 00:00:20, Serial1/0

R    2.0.0.0/8 [120/1] via 23.1.1.2, 00:00:20, Serial1/0

     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial1/0
R    12.0.0.0/8 [120/1] via 23.1.1.2, 00:00:20, Serial1/0

通过路由表已经看到各个路由器都学到了路由信息,只要通过重复show ip route 就可以查看到路由器条目阴影部分的时间在30s内变化

 

看看在R1show ip protocols输出的信息,留意定时器部分:

R1#show ip protocols

Routing Protocol is "rip"
  Sending updates every 30 seconds, next due in 24 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240

  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Redistributing: rip
  Default version control: send version 1, receive any version
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial1/1             1     1 2                                 
    Loopback0             1     1 2                                  
  Automatic network summarization is in effect
  Maximum path: 4
  Routing for Networks:
    0.0.0.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    12.1.1.2             120      00:00:26
  Distance: (default is 120)

 

下面通过debug观察路由表的变化情况:

1R1#debug ip routing

R1#debug ip rip

2:在R1上,做个访问列表,不接收来自R2rip数据包
R1(config)#access-list 110 deny udp any any eq rip

R1(config)#access-list 110 permit ip any any

R1(config-if)#ip access-group 110 in

3:再看看R1这是的debug信息:
R1#
*Mar  4 16:21:46.123: RT: delete route to 2.0.0.0 via 12.1.1.2, rip metric [120/1]
*Mar  4 16:21:46.123: RT: no routes to 2.0.0.0, entering holddown
*Mar  4 16:21:46.127: RT: delete route to 3.0.0.0 via 12.1.1.2, rip metric [120/2]
*Mar  4 16:21:46.131: RT: no routes to 3.0.0.0, entering holddown
*Mar  4 16:21:46.131: RT: delete route to 23.0.0.0 via 12.1.1.2, rip metric [120/1]
*Mar  4 16:21:46.135: RT: no routes to 23.0.0.0, entering holddown
R1#
*Mar  4 16:21:48.127: RIP: sending v1 flash update to 255.255.255.255 via Loopback0 (1.1.1.1)
*Mar  4 16:21:48.127: RIP: build flash update entries
*Mar  4 16:21:48.131:   network 2.0.0.0 metric 16
*Mar  4 16:21:48.131:   network 3.0.0.0 metric 16
*Mar  4 16:21:48.131:   network 23.0.0.0 metric 16
会在180之后,来自R2路由条目,被宣告无效(即invail计时器走完)。

 

R1#show ip route

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

 

Gateway of last resort is not set

 

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
R    2.0.0.0/8 is possibly down, routing via 12.1.1.2, Serial1/1

R    3.0.0.0/8 is possibly down, routing via 12.1.1.2, Serial1/1

R    23.0.0.0/8 is possibly down, routing via 12.1.1.2, Serial1/1

     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/1
查看R1路由表已经出现了possibly down,在保持时间计时器段。

 

R1#
*Mar  4 16:22:46.135: RT: delete network route to 2.0.0.0

*Mar  4 16:22:46.135: RT: NET-RED 2.0.0.0/8
*Mar  4 16:22:46.139: RT: delete network route to 3.0.0.0

*Mar  4 16:22:46.139: RT: NET-RED 3.0.0.0/8
*Mar  4 16:22:46.143: RT: delete network route to 23.0.0.0
*Mar  4 16:22:46.143: RT: NET-RED 23.0.0.0/8
通过上面时间的对比,在宣布无效之后的大概60s,学自R2的路由条目在路由表里面被删除,即刷新计时器如图所示为180+60=240s这个计时器是刚开始就启动的,一直到保持计时器进行到60s(刷新计时器和无效计时器同时触发),它将路由表刷新.在将它(无效路由)从表中删除前,路由器会通告它的邻居这个路由即将消亡。

 

上面的是使用默认的时间,调试过程时间较长,我们可以通过修改timer来使调试的结果更加明显。

 
R1(config)#int s1/1

R1(config-if)#no ip access-group 110 in

R1(config-router)#timer basic ?

  <0-4294967295>  Interval between updates

R1(config-router)#timer basic 5 ?

  <1-4294967295>  Invalid

R1(config-router)#timer basic 5 10 ?

  <0-4294967295>  Holddown

R1(config-router)#timer basic 5 10 15 ?

  <1-4294967295>  Flush

R1(config-router)#timer basic 5 10 15 20

 

R2(config)#router rip

R2(config-router)#timer basic 5 10 15 20

 

R3(config)#router rip

R3(config-router)#timer basic 5 10 15 20

 

观察留意show ip protocols 各个时间值已经改变了

 

R1#show ip protocols

Routing Protocol is "rip"

  Sending updates every 5 seconds, next due in 2 seconds

  Invalid after 10 seconds, hold down 15, flushed after 20

  Outgoing update filter list for all interfaces is not set

  Incoming update filter list for all interfaces is not set

  Redistributing: rip

  Default version control: send version 1, receive any version

    Interface             Send  Recv  Triggered RIP  Key-chain

    Serial1/1             1     1 2                                 

    Loopback0             1     1 2                                  

  Automatic network summarization is in effect

  Maximum path: 4

  Routing for Networks:

    0.0.0.0

  Routing Information Sources:

    Gateway         Distance      Last Update

    12.1.1.2             120      00:00:01

  Distance: (default is 120)

现在再次恢复访问列表,使R1不接收来自R2RIP路由,且在R1上打开debug 观察:

 

R1(config)#int s1/1

R1(config-if)#ip access-group 110 in

 

R1#debug ip rip

RIP protocol debugging is on

 

R1#

*Mar  4 17:02:26.795: RIP: sending v1 update to 255.255.255.255 via Serial1/1 (12.1.1.1)

*Mar  4 17:02:26.795: RIP: build update entries

*Mar  4 17:02:26.799:   network 1.0.0.0 metric 1

*Mar  4 17:02:26.799:   network 2.0.0.0 metric 16

*Mar  4 17:02:26.799:   network 3.0.0.0 metric 16

*Mar  4 17:02:26.803:   network 23.0.0.0 metric 16

*Mar  4 17:02:28.151: RIP: sending v1 flash update to 255.255.255.255 via Serial1/1 (12.1.1.1)

-------------------------------省略部分信息-------------------------------------

R1#

*Mar  4 17:02:33.067: RIP: sending v1 update to 255.255.255.255 via Loopback0 (1.1.1.1)

*Mar  4 17:02:33.067: RIP: build update entries

*Mar  4 17:02:33.071:   network 2.0.0.0 metric 16

*Mar  4 17:02:33.071:   network 3.0.0.0 metric 16

*Mar  4 17:02:33.071:   network 12.0.0.0 metric 1

*Mar  4 17:02:33.071:   network 23.0.0.0 metric 16

R1#

*Mar  4 17:02:36.687: RIP: sending v1 update to 255.255.255.255 via Serial1/1 (12.1.1.1)

*Mar  4 17:02:36.687: RIP: build update entries

*Mar  4 17:02:36.691:   network 1.0.0.0 metric 1

从以上debug结果观察到,第一次通告不可达(metric 16)的时间为0226 到来自R2的路由消失时间为0236 的间隔为10s(即是Invalid计时器和Flush计时器差为10s,与我们设置的时间一致。

 

 

总结: 在距离矢量路由协议里面,路由器会将它学习的整张路由表信息更新发出去,Rip使用4种计时器来管理它的性能:

1:周期更新计时器 周期更新计时器用于设置定期路由更新的时间间隔(一般为30s),在这个间隔里路由器发送一个自己路由表的完整拷贝到所有相邻的路由器。

2:无效计时器 用于决定一个时间长度,即路由器在认定一个路由成为无效路由之前所需要等待的时间(180s,实际情况往往略大于180s).如果路由器在更新计时器期间没有得到关于某个指定路由的任何更新消息,它将认为这个路由失效,这时就会进入到无效计时器阶段.当这一情况发生时,这个路由器将会给它所有的邻居发送一个更新消息以通知它们这个路由已经无效。

 

3:保持计时器 用于设置路由信息被抑制的时间数量.当上述无效计时器计时完毕后,就会进入到保持计数器阶段.也可理解为,当指示某个路由为不可达的更新数据包被接受到时,路由器将会进入保持失效状态.这个状态将会一直持续到一个带有更好度量的更新数据包被接受到或者这个保持计时器到期.默认时,它的取值是180s.在进入到这个阶段的前60s,会显示一个如下的路由信息possibly down,这时路由器并没有直接删除这条路由信息,但记住,若此时该路由恢复正常通讯,路由表信息也不会更新,在接下来的120s会起到一个保持网络稳定的作用。

 

4:刷新计时器 用于设置某个路由成为无效路由并将它从路由表中删除的时间间隔(240s).这个计时器是刚开始就启动的,一直到保持计时器进行到60s时,它将路由表刷新.在将它(无效路由)从表中删除前,路由器会通告它的邻居这个路由即将消亡。

5:我们也可以用time basic 来改变计时器的时间间隔。

timers basic update invalid holddown flush