Chinaunix首页 | 论坛 | 博客
  • 博客访问: 923658
  • 博文数量: 276
  • 博客积分: 4182
  • 博客等级: 上校
  • 技术积分: 4486
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-17 21:14
文章分类

全部博文(276)

文章存档

2014年(9)

2013年(132)

2012年(135)

分类:

2012-12-12 17:01:42

OSPF中COST选路研究!!!!

关于OSPF的COST 扩展研究(参考实验手册3.4):
本实验拓扑图如下:



实验目的:
正确配置,完成OSPF基本选路:
R3到达12.1.1.0/24 这一网络 ,S1/0和S2/0实现负载均衡


更改R2的S2/0 端口的COST值:110;
R1的S1/0端口的COST值:100;
影响R3到达12.1.1.0/24 的选路,说明OSPF更改COST可以影响到别人


当R1的S2/0端口DOWN掉,R3自动切换到R2到达12.1.1.0/24,查看OSPF数据库,
R2给R3的LSA-1里,包含了R2的各端口的 地址/对端接口/地址/链路开销……


扩展: 在R1上加一台路由器R4, R3到达4.4.4.0/24网络必须经过R2,R1,R4.
那这里R3要到达4.4.4.0/24的网络,是用R2的S2/0端口开销记算呢? 还是R1的S1/0 ?
反之,R4要到3.3.3.0/24 网络,又用哪个COST计算的呢?


总结OSPF 计算COST的值的步骤, 理解OSPF选路

目的一, R3实现负载均衡:
Gateway of last resort is not set

1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/65] via 13.1.1.1, 00:00:36, Serial1/0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 23.1.1.2, 00:00:36, Serial2/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, Serial2/0
12.0.0.0/24 is subnetted, 1 subnets
O 12.1.1.0 [110/128] via 23.1.1.2, 00:00:36, Serial2/0
[110/128] via 13.1.1.1, 00:00:36, Serial1/0
13.0.0.0/24 is subnetted, 1 subnets
C 13.1.1.0 is directly connected, Serial1/0
配置完成,正确选路.开销为64+64=128

目的二, 分别更改R1和R2 在12.1.1.0/24 网络的COST值, 影响R3选路:
R2(config)#int s2/0
R2(config-if)#ip ospf cost 110

R1(config)#int s1/0
R1(config-if)#ip ospf cost 100
毫无疑问,这里R3到达12.1.1.0/24 网络要通过COST小的,也就是R1.
R3# 12.0.0.0/24 is subnetted, 1 subnets
O 12.1.1.0 [110/164] via 13.1.1.1, 00:24:14, Serial1/0
这证明:
OSPP里所有路由器的动作,是计算自己所有OSPF接口/链路的COST值,并通过
LSA-1通告出去! 同时把受到的到达各个网络的COST值 (包括自己链路) 相加,
选择最优的装进路由表.




目的三, 我们先来看一下OSPF的数据库, 了解LSA-1里面的一些内容:
R3#show ip ospf database router

OSPF Router with ID (3.3.3.3) (Process ID 10)

Router Link States (Area 0)

LS age: 556
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 1.1.1.1
Advertising Router: 1.1.1.1
LS Seq Number: 80000007
Checksum: 0x5BEE
Length: 84
Number of Links: 5

Link connected to: a Stub Network
(Link ID) Network/subnet number: 12.1.1.0
(Link Data) Network Mask: 255.255.255.0
Number of TOS metrics: 0
TOS 0 Metrics: 100

LS age: 1168
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 2.2.2.2
Advertising Router: 2.2.2.2
LS Seq Number: 80000005
Checksum: 0xCB4E
Length: 84
Number of Links: 5

Link connected to: a Stub Network
(Link ID) Network/subnet number: 12.1.1.0
(Link Data) Network Mask: 255.255.255.0
Number of TOS metrics: 0
TOS 0 Metrics: 110

R3 只是提取到同一网络最小 Metrics值,再和自己计算的链路COST, 做累加
100+64=164,装进路由表!



目的四, R1上加一台路由R4, 相当于:R4=>R1=>R2=>R3 串连, 拓扑如下:


R4正确配置, DOWN掉R1的S2/0端口,现在我们来看一下, R4到达3.3.3.0/24网络,
采用的是R1的100? 还是R2的110 ? 反之, R3到4.4.4.0/24 呢 ?

R4通过E0/0 连接R1, 并宣告进OSPF区域0:
R4#
router ospf 10
router-id 4.4.4.4
network 4.4.4.0 0.0.0.255 area 0
network 14.1.1.0 0.0.0.255 area 0

R4#show ip route
Gateway of last resort is not set

1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/11] via 14.1.1.1, 00:05:49, Ethernet0/0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/111] via 14.1.1.1, 00:05:49, Ethernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/175] via 14.1.1.1, 00:05:49, Ethernet0/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/174] via 14.1.1.1, 00:05:49, Ethernet0/0
12.0.0.0/24 is subnetted, 1 subnets
O 12.1.1.0 [110/110] via 14.1.1.1, 00:05:49, Ethernet0/0
14.0.0.0/24 is subnetted, 1 subnets
C 14.1.1.0 is directly connected, Ethernet0/0

R3#show ip route
Gateway of last resort is not set

1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/175] via 23.1.1.2, 00:07:02, Serial2/0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 23.1.1.2, 00:07:02, Serial2/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/185] via 23.1.1.2, 00:07:02, Serial2/0
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, Serial2/0
12.0.0.0/24 is subnetted, 1 subnets
O 12.1.1.0 [110/174] via 23.1.1.2, 00:07:02, Serial2/0
14.0.0.0/24 is subnetted, 1 subnets
O 14.1.1.0 [110/184] via 23.1.1.2, 00:07:03, Serial2/0

结论:
R4=>R1=>R2=>R3
COST=10+100+64+1
R3=>R2=>R1=>R4
COST=64+110+10+1



五,实验总结:

任何OSPF路由器,都是以自己为根, 通过链路状态, 计算出一棵树!
实验证明了COST值的累加,这里又有点距离矢量加跳数的意思. 错!
这个累加和(175)只是R4自己的动作! 所累加的每个COST值是每台路由器通告的最原始的!

对于R4而言, 自己为根, 最近的枝就是R1,通过R1的S1/0端口到达12.1.1.0/24,
以及后面的网络, 就算R2的LSA里的Metrics再小也不会采用!
R3则相反,反之亦然!

总结一句, 更改COST值时, 以目的网络为参考点, 所做的COST/参数改动,只对
其上游路由器 (包括本路由) 选路起作用!!!

 

 

阅读(914) | 评论(0) | 转发(1) |
0

上一篇:OSPF 选路案例

下一篇:OSPF 使用 经验

给主人留下些什么吧!~~