RIP v1 基于跳数的负载均衡
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://3layer.blog.51cto.com/57448/38634 |
![]() R1#
R1#show run ! hostname R1 no ip domain-lookup ! call rsvp-sync interface Loopback0 ip address 1.1.1.1 255.255.255.0 ! ! interface Serial1/1 description link to R2 ip address 192.168.1.1 255.255.255.0 serial restart-delay 0 clock rate 64000 ! interface Serial1/2 description link to R4 ip address 192.168.3.2 255.255.255.0 serial restart-delay 0 clock rate 64000 ! router rip //宣告rip version 1 //版本1 广播255.255.255.255 方式传播路由信息 network 1.0.0.0 //宣告 loopback network 192.168.1.0 //宣告 network 192.168.3.0 //宣告 ! ip classless no ip http server ! banner motd ^CThis is test network^C ! line con 0 exec-timeout 0 0 logging synchronous line aux 0 line vty 0 4 no login ! end R1#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP 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 [120/1] via 192.168.1.2, 00:00:20, Serial1/1 //学来的路由信息 R 4.0.0.0/8 [120/1] via 192.168.3.1, 00:00:11, Serial1/2 //学来的 C 192.168.1.0/24 is directly connected, Serial1/1 R 192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:20, Serial1/1 [120/1] via 192.168.3.1, 00:00:11, Serial1/2 //学来的 C 192.168.3.0/24 is directly connected, Serial1/2 R2#show run
service timestamps debug uptime service timestamps log uptime service password-encryption ! hostname R2 ! no ip domain-lookup ! call rsvp-sync interface Loopback0 ip address 2.2.2.2 255.255.255.255 ! interface Serial1/0 description link to R1 ip address 192.168.1.2 255.255.255.0 serial restart-delay 0 ! interface Serial1/1 no ip address shutdown serial restart-delay 0 ! interface Serial1/2 description link to R4 ip address 192.168.2.1 255.255.255.0 serial restart-delay 0 ! router rip version 1 network 2.0.0.0 network 192.168.1.0 network 192.168.2.0 ! ip classless no ip http server shutdown ! banner motd ^CThis is a test network^C ! line con 0 exec-timeout 0 0 logging synchronous line aux 0 line vty 0 4 no login ! end R2#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP 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
R 1.0.0.0/8 [120/1] via 192.168.1.1, 00:00:26, Serial1/0
2.0.0.0/32 is subnetted, 1 subnets C 2.2.2.2 is directly connected, Loopback0 R 4.0.0.0/8 [120/1] via 192.168.2.2, 00:00:06, Serial1/2 C 192.168.1.0/24 is directly connected, Serial1/0 C 192.168.2.0/24 is directly connected, Serial1/2 R 192.168.3.0/24 [120/1] via 192.168.1.1, 00:00:26, Serial1/0 [120/1] via 192.168.2.2, 00:00:06, Serial1/2 R4#show run
hostname R4 ! ! no ip domain-lookup ! interface Loopback0 ip address 4.4.4.4 255.255.255.255 ! interface Serial1/1 description link to R1 ip address 192.168.3.1 255.255.255.0 serial restart-delay 0 ! interface Serial1/2 description link to R2 ip address 192.168.2.2 255.255.255.0 serial restart-delay 0 ! router rip version 1 network 4.0.0.0 network 192.168.2.0 network 192.168.3.0 ! ip classless no ip http server banner motd ^CThis is test network^C ! line con 0 exec-timeout 0 0 logging synchronous line aux 0 line vty 0 4 no login ! end R4# show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP 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
R 1.0.0.0/8 [120/1] via 192.168.3.2, 00:00:15, Serial1/1
R 2.0.0.0/8 [120/1] via 192.168.2.1, 00:00:02, Serial1/2 4.0.0.0/32 is subnetted, 1 subnets C 4.4.4.4 is directly connected, Loopback0 R 192.168.1.0/24 [120/1] via 192.168.3.2, 00:00:15, Serial1/1 [120/1] via 192.168.2.1, 00:00:02, Serial1/2 C 192.168.2.0/24 is directly connected, Serial1/2 C 192.168.3.0/24 is directly connected, Serial1/1 R4#ping //扩展ping
Protocol [ip]: Target IP address: 192.168.1.2 Repeat count [5]: Datagram size [100]: Timeout in seconds [2]: Extended commands [n]: y Source address or interface: 4.4.4.4 Type of service [0]: Set DF bit in IP header? [no]: Validate reply data? [no]: Data pattern [0xABCD]: Loose, Strict, Record, Timestamp, Verbose[none]: r Number of hops [ 9 ]: Loose, Strict, Record, Timestamp, Verbose[RV]: Sweep range of sizes [n]: Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds: Packet sent with a source address of 4.4.4.4 Packet has IP options: Total option bytes= 39, padded length=40 Record route: <*> (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) Reply to request 0 (104 ms). Received packet has options
Total option bytes= 40, padded length=40 Record route: (192.168.2.2) // 走的 s 1/2 顺时针走一圈 (192.168.1.2) (192.168.2.1) (4.4.4.4) <*> (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) End of list Reply to request 1 (104 ms). Received packet has options
Total option bytes= 40, padded length=40 Record route: (192.168.3.1) // 走的s 1/1逆指针走了一圈 (192.168.1.1) (192.168.1.2) (192.168.2.1) (4.4.4.4) <*> (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) End of list Reply to request 2 (80 ms). Received packet has options
Total option bytes= 40, padded length=40 Record route: (192.168.2.2) // 顺 (192.168.1.2) (192.168.2.1) (4.4.4.4) <*> (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) End of list Reply to request 3 (152 ms). Received packet has options
Total option bytes= 40, padded length=40 Record route: (192.168.3.1) // 逆 (192.168.1.1) (192.168.1.2) (192.168.2.1) (4.4.4.4) <*> R4# R1#debug ip rip
00:03:20: RIP: received v1 update from 192.168.3.1 on Serial1/2 // 在串口上接收路由信息 00:03:20: 2.0.0.0 in 2 hops 00:03:20: 4.0.0.0 in 1 hops 00:03:20: 192.168.2.0 in 1 hops R1# 00:03:22: RIP: received v1 update from 192.168.1.2 on Serial1/1 //在串口上接收路由信息 00:03:22: 2.0.0.0 in 1 hops 00:03:22: 4.0.0.0 in 2 hops 00:03:22: 192.168.2.0 in 1 hops R1# 00:03:27: RIP: sending v1 update to 255.255.255.255 via Serial1/1 (192.168.1.1) // 255.255.255.255 广播发送路由更新 00:03:27: RIP: build update entries 00:03:27: network 1.0.0.0 metric 1 00:03:27: network 4.0.0.0 metric 2 00:03:27: network 192.168.3.0 metric 1 00:03:27: RIP: sending v1 update to 255.255.255.255 via Serial1/2 (192.168.3.2) 00:03:27: RIP: build update entries 00:03:27: network 1.0.0.0 metric 1 00:03:27: network 2.0.0.0 metric 2 00:03:27: network 192.168.1.0 metric 1 00:03:27: RIP: sending v1 update to 255.255.255.255 via Loopback0 (1.1.1.1) 00:03:27: RIP: build update entries 00:03:27: network 2.0.0.0 metric 2 00:03:27: network 4.0.0.0 metric 2 00:03:27: network 192.168.1.0 metric 1 00:03:27: network 192.168.2.0 metric 2 00:03:27: network 192.168.3.0 metric 1 R1#debug ip pack
IP packet debugging is on R1# 00:07:57: IP: s=192.168.3.1 (Serial1/2), d=255.255.255.255, len 92, rcvd 2 // 接收路由信息 R1# 00:08:03: IP: s=192.168.1.2 (Serial1/1), d=255.255.255.255, len 92, rcvd 2 //接收路由信息 R1# 00:08:09: IP: s=192.168.1.1 (local), d=255.255.255.255 (Serial1/1), len 92, sending broad/multicast 00:08:09: IP: s=192.168.3.2 (local), d=255.255.255.255 (Serial1/2), len 92, sending broad/multicast 00:08:09: IP: s=1.1.1.1 (local), d=255.255.255.255 (Loopback0), len 132, sending broad/multicast 00:08:09: IP: s=1.1.1.1 (Loopback0), d=255.255.255.255, len 132, unroutable R1#show ip protocols
Routing Protocol is "rip" Sending updates every 30 seconds, next due in 27 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 version 1 Interface Send Recv Triggered RIP Key-chain Serial1/1 1 1 Serial1/2 1 1 Loopback0 1 1 Automatic network summarization is in effect Maximum path: 4 Routing for Networks: 1.0.0.0 192.168.1.0 192.168.3.0 Routing Information Sources: Gateway Distance Last Update 192.168.3.1 120 00:00:06 192.168.1.2 120 00:00:17 Distance: (default is 120) R1#show ip rip database
1.0.0.0/8 auto-summary //有类路由协议 自动汇总 1.1.1.0/24 directly connected, Loopback0 2.0.0.0/8 auto-summary 2.0.0.0/8 [1] via 192.168.1.2, 00:00:27, Serial1/1 4.0.0.0/8 auto-summary 4.0.0.0/8 [1] via 192.168.3.1, 00:00:19, Serial1/2 192.168.1.0/24 auto-summary 192.168.1.0/24 directly connected, Serial1/1 192.168.2.0/24 auto-summary 192.168.2.0/24 [1] via 192.168.3.1, 00:00:19, Serial1/2 [1] via 192.168.1.2, 00:00:27, Serial1/1 192.168.3.0/24 auto-summary 192.168.3.0/24 directly connected, Serial1/2 以下为从互联网收集资料
RIP的度量是基于跳数(hops count)的,每经过一台路由器,路径的跳数加一。如此一来,跳数越多,路径就越长,RIP算法会优先选择跳数少的路径。RIP支持的最大跳数是15,跳数为16的网络被认为不可达。
RIP中路由的更新是通过定时广播实现的。缺省情况下,路由器每隔30秒向与它相连的网络广播自己的路由表,接到广播的路由器将收到的信息添加至自身的路由表中。每个路由器都如此广播,最终网络上所有的路由器都会得知全部的路由信息。正常情况下,每30秒路由器就可以收到一次路由信息确认,如果经过180秒,即6个更新周期,一个路由项都没有得到确认,路由器就认为它已失效了。如果经过240秒,即8个更新周期,路由项仍没有得到确认,它就被从路由表中删除。上面的30秒,180秒和240秒的延时都是由计时器控制的,它们分别是更新计时器(Update Timer)、无效计时器(Invalid Timer)和刷新计时器(Flush Timer)。
水平分割(split horizon)。水平分割保证路由器记住每一条路由信息的来源,并且不在收到这条信息的端口上再次发送它。这是保证不产生路由循环的最基本措施。 毒性逆转(poison reverse)。当一条路径信息变为无效之后,路由器并不立即将它从路由表中删除,而是用16,即不可达的度量值将它广播出去。这样虽然增加了路由表的大小,但对消除路由循环很有帮助,它可以立即清除相邻路由器之间的任何环路。 触发更新(trigger update)。当路由表发生变化时,更新报文立即广播给相邻的所有路由器,而不是等待30秒的更新周期。同样,当一个路由器刚启动RIP时,它广播请求报文。收到此广播的相邻路由器立即应答一个更新报文,而不必等到下一个更新周期。这样,网络拓扑的变化会最快地在网络上传播开,减少了路由循环产生的可能性。 抑制计时(holddown timer)。一条路由信息无效之后,一段时间内这条路由都处于抑制状态,即在一定时间内不再接收关于同一目的地址的路由更新。如果,路由器从一个网段上得知一条路径失效,然后,立即在另一个网段上得知这个路由有效。这个有效的信息往往是不正确的,抑制计时避免了这个问题,而且,当一条链路频繁起停时,抑制计时减少了路由的浮动,增加了网络的稳定性。 即便采用了上面的4种方法,路由循环的问题也不能完全解决,只是得到了最大程度的减少。一旦路由循环真的出现,路由项的度量值就会出现计数到无穷大(Count to Infinity)的情况。这是因为路由信息被循环传递,每传过一个路由器,度量值就加1,一直加到16,路径就成为不可达的了。RIP选择16作为不可达的度量值是很巧妙的,它既足够的大,保证了多数网络能够正常运行,又足够小,使得计数到无穷大所花费的时间最短。 邻居 有些网络是NBMA(Non-Broadcast MultiAccess,非广播多路访问)的,即网络上不允许广播传送数据。对于这种网络,RIP就不能依赖广播传递路由表了。解决方法有很多,最简单的是指定邻居(neighbor),即指定将路由表发送给某一台特定的路由器。 RIP的缺陷 RIP虽然简单易行,并且久经考验,但是也存在着一些很重要的缺陷,主要有以下几点: 过于简单,以跳数为依据计算度量值,经常得出非最优路由; 度量值以16为限,不适合大的网络; 安全性差,接受来自任何设备的路由更新; 不支持无类IP地址和VLSM(Variable Length Subnet Mask,变长子网掩码); 收敛缓慢,时间经常大于5分钟; 消耗带宽很大。 本文出自 “人类一思考,上帝都发笑” 博客,请务必保留此出处http://3layer.blog.51cto.com/57448/38634 本文出自 51CTO.COM技术博客 |




7layer
博客统计信息
热门文章
最新评论
友情链接