Hope everyone remember the basic concept of OSPF metric calculation. Its cost. Each interfaces have a cost attached to it by default. Below is the list of default cost per interface.

So, notice these calculations were just assumed till the 100 Mbps which has the cost of 1. Now, we have 1G, 10G, 40G & 100G (In progress). Still the cost remains 1 ????

Well, if we were to live with Cost of 1, then we end up sub-utilizing high bandwidth links. If we were to pickup, 1G link over an 100Mbps it wouldn’t have been possible because, OSPF metric calculation of Cost shows 1G & 100Mbps link both to have a cost of 1 which means Load balance across both links.

So, there came a concept of auto-cost reference bandwidth. Below is the OSPF cost calculation equation

By default Ref-Bandwidth is 10^8 bps (i.e 100 Mbps). So, calculating the exponential gives you 1,000,000,00 bps (Bits per second). Now, lets assume our we have 100 Mbps Link, lets calculate the cost of it

So, Cost is 1.

Now, lets talk about 10 Mbps (This will give you the clear idea).

So, Cost is 10.

Do homework to calculate the cost of a serial link with 1.544 Mbps speed

So, we have successfully calculated the Cost. But, as the command auto-cost reference-bandwidth asks you to put the reference bandwidth value in Mbps. How do we calculate the reference bandwidth?

Just relook at the below formula

We do the below:

Now lets forget the default cost’s & calculate the reference BW for 100 Mbps so that the cost is 5.

Just you need to do is, put that value in the command as below in router ospf process

Verifying if the cost of fastethernet interface is reflecting with the cost of 5. Do the below

<-- Output Omitted -->

Let’s do one more calculation for 1 Gig link. We give this link a cost of 3.

So, our main goal of shredding of the default values accomplished. We manually decide which interface should be considered least cost. If you had a 1G uplink & you plan to put a cost of 3 for it, then set the reference bandwidth as 300 Mbps. If you had a 10G uplink & plan to put a cost of 2, then set the reference bandwidth as 200 Mbps.

I have seen in certain CCIE workbooks where a task requires you to have all the fastethernet interfaces with the cost of 5 & ethernet interface with a cost of 50. So, just inject the calculation into your mind :)

Thanks :)

**Interface Type Interface Bandwidth OSPF Cost**

**Loopback 8,000,000,000 1**

**Serial 56,000 1785**

**T1 1,544,000 64**

**Ethernet 10,000,000 10**

**Fast Ethernet 100,000,000 1**

**Gigabit Ethernet 1,000,000,000 1**

**OC48 2,500,000,000 1**So, notice these calculations were just assumed till the 100 Mbps which has the cost of 1. Now, we have 1G, 10G, 40G & 100G (In progress). Still the cost remains 1 ????

Well, if we were to live with Cost of 1, then we end up sub-utilizing high bandwidth links. If we were to pickup, 1G link over an 100Mbps it wouldn’t have been possible because, OSPF metric calculation of Cost shows 1G & 100Mbps link both to have a cost of 1 which means Load balance across both links.

So, there came a concept of auto-cost reference bandwidth. Below is the OSPF cost calculation equation

**OSPF Cost = Ref-Bandwidth in Bits per second/Link-Bandwidth in Bits per second.**By default Ref-Bandwidth is 10^8 bps (i.e 100 Mbps). So, calculating the exponential gives you 1,000,000,00 bps (Bits per second). Now, lets assume our we have 100 Mbps Link, lets calculate the cost of it

**OSPF Cost = 1,000,000,00/1,000,000,00 = 1**So, Cost is 1.

Now, lets talk about 10 Mbps (This will give you the clear idea).

**OSPF Cost = 1,000,000,00/10,00,00,00 = 10**So, Cost is 10.

Do homework to calculate the cost of a serial link with 1.544 Mbps speed

So, we have successfully calculated the Cost. But, as the command auto-cost reference-bandwidth asks you to put the reference bandwidth value in Mbps. How do we calculate the reference bandwidth?

Just relook at the below formula

**OSPF Cost = Reference BW/Link BW (All in Bits per second)**We do the below:

**OSPF Cost X Link BW = Reference BW**Now lets forget the default cost’s & calculate the reference BW for 100 Mbps so that the cost is 5.

**5 x 10^8 = Reference BW****500000000**= Reference BW in Bits per second. Convert this into Mbps (i.e**500 Mbps**).Just you need to do is, put that value in the command as below in router ospf process

**Auto-cost reference bandwidth 500**Verifying if the cost of fastethernet interface is reflecting with the cost of 5. Do the below

*R1#sh ip ospf interface fas 0/0*

*FastEthernet0/0 is up, line protocol is up**Internet Address 81.81.81.1/24, Area 81**Process ID 1, Router ID 255.255.255.1, Network Type POINT_TO_MULTIPOINT,***Cost: 5***Enabled by interface config, including secondary ip addresses**Transmit Delay is 1 sec, State POINT_TO_MULTIPOINT,**Timer intervals configured, Hello 5, Dead 20, Wait 20, Retransmit 5*<-- Output Omitted -->

Let’s do one more calculation for 1 Gig link. We give this link a cost of 3.

**3 x 10^8 = 300000000 bps (I.e 300 Mbps)**So, our main goal of shredding of the default values accomplished. We manually decide which interface should be considered least cost. If you had a 1G uplink & you plan to put a cost of 3 for it, then set the reference bandwidth as 300 Mbps. If you had a 10G uplink & plan to put a cost of 2, then set the reference bandwidth as 200 Mbps.

I have seen in certain CCIE workbooks where a task requires you to have all the fastethernet interfaces with the cost of 5 & ethernet interface with a cost of 50. So, just inject the calculation into your mind :)

Thanks :)

hello vivek your blog is too good

ReplyDeleteits really interesting for guys who loves networking.

nd dis is krishna working on java...

i need some suggessions regarding my career plans

i love to be in networking..but i got into software...

i am a 2010 passout from VIT...

hope a rply from you

my id :b4bhas@gmail.com

thank u

Hi there,

ReplyDeleteDo you know how OSPF calculates cost based on only "interface type"?

i.e. using the "no auto-cost" command in a OSPF routing process, GigEthernet interfaces produce a cost of 10.

Is there a table somewhere?

Hello Mark,

ReplyDeleteIf i understand your question correctly, you wanted to know how OSPF calculates cost based on interface. There is a default cost values defined on type of interface. You may find that in my post itself.

Thanx Vivek Sirr.... Its really helpfull

ReplyDelete