OSPF Cost


What is Cost?
OSPF metric is known as cost and OSPF Cost is the overhead required to send packets across a certain interface. IN OSPF different interface have different cost related to bandwidth, a interface have high bandwidth have lower cost and OSPF consider the best path/link among the different link by lower cost.
OSPF use the following formula for calculating cost for a link.

OSPF Cost=100 / (bandwidth in MB)

OSPF Cost for different interfaces(Cisco):
Link/interface
OSPF cost
56k
1785
64k
1562
T1
65
E1
48
FE/GE/10 GE
1



Cost Management/Configuration:
By default, the cost of an interface is calculated based on the bandwidth and also FE=G=GE=E=10G have cost of ‘1’. Since all E/FE/GE interfaces have equal cost therefore in some networks design there you are using all E/FE/GE interfaces router can give the preference to E interface over GE to avoid such situation it is recommended that you set the cost of different interface manually. For this you can force the cost of an interface with the ip ospf cost <value>interface sub configuration mode command.

Router(config-if)#ip ospf cost <1 to 22>
Also following are some method for cost management in OSPF.
Metric Tuning

Engineers have a couple of commands available that allow them to tune the values of the OSPF interface cost, thereby influencing the choice of best OSPF route. There are three methods:
         i.            Changing the reference bandwidth
       ii.            Setting the interface bandwidth
      iii.            Setting the OSPF cost directly.

Changing the Reference Bandwidth:
Using reference bandwidth command you can change the default cost of any interface\link and you can accommodate good default for higher-speed link. Auto-cost reference bandwidth 100 is the default where 100 MB link= 1 (cost).
I fyou have GE interface in your network you can change your reference bandwidth by "auto-cost reference bandwidth 1000", in this case cost of gig interface is selected as 1.
Setting Bandwidth
You can change the OSPF cost by configuring the bandwidth of an interface. In such cases, the cost formula (Cost=100 / (bandwidth in MB) is used, just with the configured bandwidth value.
On Ethernet interfaces, if not configured with the bandwidth command, the interface bandwidth matches the actual speed. For example, on an interface that supports auto negotiation
for 10/100, the bandwidth is either 100,000 (kbps, or 100 Mbps) or 10,000 (Kbps, or 10 Mbps) depending on whether the link currently runs at 100 or 10 Mbps, respectively.
Configuring Cost Directly
The handiest method to configure OSPF costs is to set the cost manually by command:
Router#ip ospf cost <number>
When you configuration the manual cost of each interface then OSPF ignore every this use the manually configured cost.
Ip ospf cost set the cost by you according to interface speed. For example if there are FE, GE and 10 GE interface you can set 20 for FE,10 for GE and 1 for 10 GE. In this way you can easy manage cost of OSPF link and take full advantage of you GE interfaces.
Verifying OSPF Cost Settings
You can verify OSPF cost settings of various interfaces by following commands.
Router#show run
Router#show ip ospf interface brief
Router#show ip ospf interface fa 0/0

4 comments:

  1. easy to understand "ospf cost" from your aricle, thanks alot.

    ReplyDelete
  2. nice article , i have one question though.
    like i have two links, one FE and one GE as per ospf both has same cost , so inorder to route the traffic on GE i will increase the cost on FE.other than this are there any other ways to route the traffic over the high bw link?
    please reply thanks.

    ReplyDelete
    Replies
    1. There are three methods:
      i.Changing the reference bandwidth
      ii.Setting the interface bandwidth
      iii.Setting the OSPF cost directly.

      Delete
  3. Dear all after saving and re-open the topology, all configuration file are crashed. pls help me

    ReplyDelete

UA-23728446-1