CISCO uses the formula 108/Bandwidth (of an interface) to calculate the interface cost. This produces the following costs for the interfaces :
This formula is usable for interface speeds up to 100Mb, but with the introduction of high speed SONET and ATM interfaces in the network, this approach is not adequate. The following example will illustrate the problem.
Using a OC-3 interface, the bandwidth for this interface is 155,000,000. Using the formula 108/155,000,000 = 0.645. OSPF will round all decimals to 1, making it equal to the cost of a fast Ethernet interface. The same would hold true for OC-12, OC-48, and Gigabit Ethernet interfaces. Obviously, this would cause routing problems within the network. having interfaces with different bandwidths having the same cost.
CISCO provides a solution within certain router IOS software to be able to control how OSPF calculates the default metrics for an interface. This feature is enabled under the router ospf process using the ospf auto-cost reference-bandwidth ref-bw. Where ref-bw is the rate in megabits per second (bandwidth). The range is 1 to 4294967; the default is 100. The formula is now changed to be Reference-bandwidth/interface bandwidth. This feature allows us to globally change how the costs are determined by interface speed. This command was introduced in CISCO IOS release 11.2.
Conclusion:- If you are using OC-3 and higher links, you should enable ospf auto-cost reference-bandwidth under your router ospf process. Depending on your organizations routing policies you can implement different methods. The best practice here is specifying ip ospf cost manually for every interface. This is a best method to avoid confusion in route selection.