1.1RIP的基本原理与实现:
1、RIP协议的处理是通过UDP520端口来操作的,所有的RIP消息都封装在UDP协议中,源和目的端口均设置为520.
2.、RIP定义了两种包类型:请求消息(request messages)和响应消息(response messages)。
3、RIP的度量值是跳数(hop count)的,16跳不可达。
4、启动rip路由协议时,rip将会从每个启用rip协议的端口广播出带有请求消息的数据包,之后rip进程进入一个循环状态(监听)
1.2 RIP的计时器和稳定性
1、rip数据的更新机制是 周期性的更新(30s更新一次)RIPV1更新的目的地址是255.255.255.255 RIPV2的更新地址为              
   224.0.0.9。
这个update包含了路由器中除了被splithorizon(水平分割)抑制的完整路由表,
update周期性的发送的时间间隔默认为(update timer)25.5s到30s之间(一个随机变量:RIP_JITTER是cisco-IOS中专有的一个随机变量,他缩短一般更新时间的15%(即4.5s),因此cisco的更新时间是25.5s到30s之间变化。   
2、invalidation timer (失效计时器)180s,当有一条路由被建立时,无效计时器机会被初始化为180s,如果一条路  由的更新在180s内还没有收到,这条路有就会被标记为16跳,标记为不可达,路由不会被删除。

 3、  holddown timer 180s(保持时间)
   一下为开启的holddown计时器的两种情况
1)180s,如果新收到的路由条目比原有的条目的metric值更大,那么原有的条目会进入一个长为180s的holddown状态
2)无效计时器到期后,开启holddown计时器,在抑制计时器的时间内给条目标记为possible down知道计时器超时,路由器才会接受有关路由的更新信息。
原理:
该计时器的原理是引用一个怀疑量,不管是真的还是假的路由消息,路由器先认为是假消息来避免路由环路。如果在抑制计时器超时后还接受到该消息,那么这时路由器就认为该消息时真的。RIP中认为假的消息总是真不了,不长久
4、Flush timer (刷新时间)
240s.在RFC1058中规定的是300s,如果超过240s,那么路由标记为不可达达,将会从路由表中删除。
1.3实验说明:
R1(S0/0)-------(s0/0)R2(S0/1)----(S0/0)R3
     LO1                                     LO1                     LO1
R1#sh ip protocols 
Routing Protocol is "rip"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Sending updates every 30 seconds, next due in 8 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Redistributing: rip
  Default version control: send version 1, receive any version
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/0             1     1 2                                  
    Loopback1             1     1 2                                  
  Automatic network summarization is in effect
  Maximum path: 4
  Routing for Networks:
    1.0.0.0
    192.168.12.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    192.168.12.2         120      00:11:11
  Distance: (default is 120)
通过开启debug观察路由表的变化情况:
R1#debug ip routing
R1#debug ip rip
在R1上做访问控制列表,不接受R2的rip数据包
R1(config)#access-list 111 deny udp any any eq rip 
R1(config)#access-list 111 permit ip any any 
R1(config-if)#ip access-group 111 in 
R1#sh ip route 
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - 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

C    192.168.12.0/24 is directly connected, Serial0/0
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback1
R    2.0.0.0/8 [120/1] via 192.168.12.2, 00:01:26, Serial0/0
R    3.0.0.0/8 [120/2] via 192.168.12.2, 00:01:26, Serial0/0
R    192.168.23.0/24 [120/1] via 192.168.12.2, 00:01:26, Serial0/0
180S后 来自R2的路由条目,被宣告无效,hop=16跳(即超时计时器走完)
*Mar  1 00:14:19.595: RT: delete route to 2.0.0.0 via 192.168.12.2, rip metric [120/1]
*Mar  1 00:14:19.595: RT: SET_LAST_RDB for 2.0.0.0/8
  OLD rdb: via 11.13.11.13

*Mar  1 00:14:19.595: RT: no routes to 2.0.0.0, entering holddown
*Mar  1 00:14:19.599: RT: NET-RED 2.0.0.0/8
*Mar  1 00:14:19.599: RT: delete route to 3.0.0.0 via 192.168.12.2, rip metric [120/2]
*Mar  1 00:14:19.603: RT: SET_LAST_RDB for 3.0.0.0/8
  OLD rdb: via 11.13.11.13

*Mar  1 00:14:19.603: RT: no routes to 3.0.0.0, entering holddown
*Mar  1 00:14:19.603: RT: NET-RED 3.0.0.0/8
*Mar  1 00:14:19.607: RT: delete route to 192.168.23.0 via 192.168.12.2, rip metric [120/1]
*Mar  1 00:14:19.607: RT: 
R1#sh ip route SET_LAST_RDB for 192.168.23.0/24
  OLD rdb: via 11.13.11.13

*Mar  1 00:14:19.607: RT: no routes to 192.168.23.0, entering holddown
*Mar  1 00:14:19.607: RT: NET-RED 192.168.23.0/24
R1#sh ip route 
*Mar  1 00:14:21.599: RIP: sending v1 flash update to 255.255.255.255 via Loopback1 (1.1.1.1)
*Mar  1 00:14:21.599: RIP: build flash update entries
*Mar  1 00:14:21.599:   network 2.0.0.0 metric 16
*Mar  1 00:14:21.599:   network 3.0.0.0 metric 16
*Mar  1 00:14:21.603:   network 192.168.23.0 metric 16
Holddown 计时器开始,进入possible down状态
R1#sh ip route 
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - 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

C    192.168.12.0/24 is directly connected, Serial0/0
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback1
R    192.168.23.0/24 is possibly down, routing via 192.168.12.2, Serial0/0
R1的Flush计时器到期后,删除不可到达的路由:
*Mar  1 01:20:22.431: RIP: sending v1 update to 255.255.255.255 via Serial0/0 (192.168.12.1)
*Mar  1 01:20:22.431: RIP: build update entries
*Mar  1 01:20:22.431:   network 1.0.0.0 metric 1
*Mar  1 01:20:22.431:   network 2.0.0.0 metric 16
*Mar  1 01:20:22.435:   network 3.0.0.0 metric 16
*Mar  1 01:20:22.435:   network 192.168.23.0 metric 16
R1#
*Mar  1 01:20:37.775: RT: delete network route to 2.0.0.0
*Mar  1 01:20:37.775: RT: NET-RED 2.0.0.0/8
*Mar  1 01:20:37.779: RT: delete network route to 3.0.0.0
*Mar  1 01:20:37.779: RT: NET-RED 3.0.0.0/8
*Mar  1 01:20:37.779: RT: delete network route to 192.168.23.0
*Mar  1 01:20:37.783: RT: NET-RED 192.168.23.0/24

R1#sh ip route 
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - 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

C    192.168.12.0/24 is directly connected, Serial0/0
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback1
备注:
1. 在 holddown timer 开始的时候就开始对外发路由毒化的路由,即hop=16,收到这个路由的设备毒性反转,再发送hop=16 回来(打破水平分割原则) ;holddown 的存在理由就是为了使得全网的毒化路由接收一致,防止路由环路.
计时器总结:
 
说明:Holddown 计时器在无效计时器运行180s后,开启,也只运行60s后;与刷新时间一起清零
1.4RIP的基础部分
Classful Routing 有类路由协议
IGRP /RIP V1
1.在发送路由更新信息时,不携带子网掩码,无法描述路由条目的路由长度
2.在主类的网络边界上,自动发生路由汇总
汇总到主类网络的默认的路由长度(自动汇总是无法关闭的)
(不支持VLSM,只能汇总为A/B/C类).
3.由于上述原因,有类路由协议会产生"不连续子网"的路由通达性问题.

2)Classless Routing/无类路由协议
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RIP V2 的automatic summary
1.不会对收到的明细路由进行汇总
2.对自己直连的路由进行汇总后,再通告出去.
3.把收到的明细路由放进路由表中,但会对明细路由进行汇总后再通告出去!



EIGRP的automatic summary
1.不会对收到的明细路由进行汇总,
2.对自己直连的路由进行汇总后,再通告出去
3.把收到的明细路由放进路由表中,并且把收到的明细路由通告出去!



RIPv2/EIGRP/OSPF/IS-IS/BGPv4
1.在发送路由更新信息时,已经携带子网掩码.
2.支持VLSM,路由的手工/自动汇总,(可以关闭自动汇总)
3.在部分先进的路由协议中,支持CIDR(超网)

备注:
ip classless(在IOS为12.0以后的版本中,默认启动无类路由。)