Monday, June 2, 2008

OSPF - auto-cost reference-bandwidth

The default reference bandwidth for OSPF is 10^8 bps or 100Mbit. Increasing the reference-bandwidth allows a more granular OSPF design. If changed it should be changed on all routers in the OSPF domain.

The reason you would change the reference-bandwidth is that you may have link faster than 100M in your network. If you have Gigabit networks but are using the default reference-bandwidth, then Gigabit links are equal in cost to fast Ethernet.

This example uses serial interfaces, but it will allow you to get an idea of what this command does.

Here is our basic topology, with R1 and R2 connected via 1544K serial links.

R1 ---area0--- R2

R1#show ip route | begin Gateway
Gateway of last resort is not set

1.0.0.0/32 is subnetted, 2 subnets
C 1.1.1.1 is directly connected, Loopback0
C 1.1.1.2 is directly connected, Loopback1
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 172.12.12.2, 00:08:50, Serial1/0
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/129] via 172.12.12.2, 00:08:50, Serial1/0
172.12.0.0/24 is subnetted, 2 subnets
C 172.12.12.0 is directly connected, Serial1/0
O IA 172.12.23.0 [110/128] via 172.12.12.2, 00:08:50, Serial1/0

R1#show ip ospf int s1/0 | inc Cost
Process ID 1, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 64

Chaging the reference-bandwidth under the ospf process as follows:

R1(config)#router ospf 1
R1(config-router)#auto-cost reference-bandwidth 1000
% OSPF: Reference bandwidth is changed.
Please ensure reference bandwidth is consistent across all routers.
R1(config-router)#^Z

The cost of the interface has changed from 64 to 647

R1#show ip ospf int s1/0 | inc Cost
Process ID 1, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 647

Here are the calculations:

100000000/1544000 = 64
1000000000/1544000 = 647

All routes have through this interface have a higher metric now:

R1#show ip route | begin Gateway
Gateway of last resort is not set

1.0.0.0/32 is subnetted, 2 subnets
C 1.1.1.1 is directly connected, Loopback0
C 1.1.1.2 is directly connected, Loopback1
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/648] via 172.12.12.2, 00:01:30, Serial1/0
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/712] via 172.12.12.2, 00:01:30, Serial1/0
172.12.0.0/24 is subnetted, 2 subnets
C 172.12.12.0 is directly connected, Serial1/0
O IA 172.12.23.0 [110/711] via 172.12.12.2, 00:01:30, Serial1/0

16 comments:

  1. Thanks, your explanation helped me.

    ReplyDelete
  2. Great explanation!

    ReplyDelete
  3. thanks it is very clearly

    ReplyDelete
  4. this is cool..thanx so muchh man

    ReplyDelete
  5. u explanation s great... thax alot

    ReplyDelete
  6. Good work, thanks from Russia!

    ReplyDelete
  7. Great Stuff. very very useful

    ReplyDelete
  8. I have a better understanding but, still not sure where the 1000 came from; or how to pick that number.

    ReplyDelete
  9. Simply superb explanation...

    ReplyDelete
  10. Wait a nimute,

    I think there is a little confusion here.

    You increased the bandwidth from 100 Mbps to 1000 Mbps and yet the OSPF cost increased from 64 to 640?

    I think it should be the other way. The cost now should be 6 (rounded down from 6.4)

    The more bandwidth you have the less cost you have. In other words if you upgrade interface cards from 100 Mbps to 1 Gbps
    on all routers that form a route, that route should now have smaller cost and more likely be chosen by OSPF to add to routing tables. In a word, bandwidth and cost are inversely related. Am I right?

    Your command is right and your calculation is right. But what is the point of doing it? If you do have higher links wouldn't it be better to change the bandwidth of those interfaces instead?

    ReplyDelete
    Replies
    1. hi,

      still i am not clear.
      in our routers, auto-cost ref bandwidth 100000 configured and we have gig and tengig interfaces, 100 and 10 cost respectively. can u please explain how 100 for gig and 10 for tengig calculated?

      thanks

      Delete
    2. He didn't increase the actual bandwidth, he increased the reference-bandwidth that OSPF uses to calculate the cost of a route.

      To get the cost: reference-bandwidth divided by actual bandwidth.

      first reference-bandwidth was: 100,000,000
      first actual bandwidth was: 1544000
      cost: 100000000 / 1544000 = 64

      second reference-bandwidth was: 1,000,000,000
      second actual bandwidth was: 1544000 (same as first)
      cost: 1000000000 / 1544000 = 647

      Delete
    3. I think now I understand it better.

      Lets say if you have a network of 4 routers. From LAN A to LAN B there are two possible routs, LAN A-R1-R3-LAN B or LAN A-R2-R4-LAN B. Lets also say that all the interfaces forming the two routes are 100 mbps interfaces.

      Now because the default reference-bandwidth is 100 mbps, each router has a cost of 1 (100 mbps/100 mbps), so the cost from either route is 2 (r1+r3=2, and and r2+r4=2). So either route is no of advantage over the other. They are equal.

      Now imagine we replace the interface cards on r1 and r3 with gigabit cards. Their interface cost would be 100 mbps / 1000 mbps = 0.1. Since OSPF cost is not allowed to have a value smaller than 1, 0.1 will actually be rounded to 1! In other words, even with 1000 mbps cards, r1-r3 route still has the same cost, at 2 !!

      If at this point we change reference-bandwidth on all 4 routers to 1,000,000,000 (10^9 or 1 Gbps), R1's cost will be 1 and R3's cost will be 1 (1 Gbps/1 Gbps); and R2's cost will be 10 and R4's cost will 10 (1 Gbps/100 Mbps). So R1-R3 cost will now be 2 and R2-R4 cost will now 20. This grantees R1-R3 will be always chosen by ospf as the best route for LAN A to reach LAN B or vice versa.

      Delete
  11. Thanks for the explanation.. Helpful...

    ReplyDelete

Note: Only a member of this blog may post a comment.