Reference: Routing TCP/IP volume 1 page 345
Cost calculation for OSPF:
10^8/bandwidth
This works well with 100mpbs link whereby the cost is 1.
however if it exceeds the 100mbps boundary the cost calculation will still be 1, because decimal/fraction of 1 is unacceptable in ospf cost metric.
hence any fraction of 1 will be rounded back to 1.
this will cause the faster link (1gbps) to be the same cost with other 100mbps link making the routing decision to be hop-based instead of cost base.
to resolve this issue, cisco routers have this feature: auto-cost reference-bandwidth
Let’s look at this request:
A company will be upgrading its network links to gigabit, assuming the highest link is a 1gbps, you must configure the routers to accurately calculate the cost metric so that the gigabit is taken into account.
The command must be consistent throughout the ospf speaking routers.
WARNING: setting a reference bandwidth too high will cause some lower bandwidth links to lost ospf adjacency, ospf does have a cap to the cost calculation if the cost calculation exceeded the highest cap ospf will deem that route dead.
R5(config-router)#auto-cost reference-bandwidth ?
<1-4294967> The reference bandwidth in terms of Mbits per second
(DO NOT SET THIS TOO HIGH)
R5(config-router)#auto-cost reference-bandwidth 1000
% OSPF: Reference bandwidth is changed.
Please ensure reference bandwidth is consistent across all routers.
R5(config-router)#
R2(config)#router ospf 1
R2(config-router)#auto-cost reference-bandwidth 1000
R3(config)#router ospf 1
R3(config-router)#auto-cost reference-bandwidth 1000
R4(config)#router ospf 1
R4(config-router)#auto-cost reference-bandwidth 1000
R1(config)#router ospf 1
R1(config-router)#auto-cost reference-bandwidth 1000
Testing the effect:
R1#sh ip route ospf
172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
O 172.16.0.0/22 is a summary, 00:21:40, Null0
172.30.0.0/24 is subnetted, 3 subnets
O IA 172.30.20.0 [110/2010] via 172.30.0.3, 00:00:20, FastEthernet0/0
O IA 172.30.10.0 [110/2010] via 172.30.0.2, 00:00:20, FastEthernet0/0
10.0.0.0/22 is subnetted, 2 subnets
O IA 10.10.0.0 [110/2011] via 172.30.0.2, 00:00:20, FastEthernet0/0
O IA 10.20.0.0 [110/2011] via 172.30.0.3, 00:00:20, FastEthernet0/0
The cost metric actually increased 10 folds. The reference is 1gbps instead of 100mbps. Hence caution is needed to never set the reference bandwidth values into insane values.