question about OSPF cost

Unanswered Question
Sep 16th, 2009

Hi !

I'm currently studding OSPF for BSCI certification Exam.

I would to understand how router know the cost of the link to be able to calculate the optimal route base on bandwith.... I did not see anything about the link speed or cost in debug output command on the router and nothing more by using a sniffer between 2 OSPF router like is proposed in OSPF Network Design Solution books from Cisco Press....

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
Loading.
Peter Paluch Wed, 09/16/2009 - 16:08

Hello,

The cost of a link is by default calculated by the formula (100 Mbps / interface bandwidth in Mbps) in Cisco's OSPF implementation. The way of calculating costs is not mandated by the RFC 2328 where the OSPF is specified and each vendor may implement it differently.

As you can see, this default formula assigns a cost of 1 to a FastEthernet and faster interface (OSPF does not use fractions or real numbers). With today's Gigabit Ethernet (and faster) interfaces, it is reasonable to change the 100 Mbps constant in this formula to a higher number so that it is possible to have different costs for GigE and FastE. The change is implemented using the command auto-cost reference-bandwidth in the OSPF configuration, for example:

auto-cost reference-bandwidth 100000

where the reference bandwidth is now 100000 Mbps = 100 Gbps and the metric calculations will now be (100000 / interface bandwidth). This change must be implemented manually on all OSPF routers, as the reference bandwidth is not propagated in OSPF packets.

Best regards,

Peter

xine xine Thu, 09/17/2009 - 04:13

Hi !

Definitely, I was'nt enough clear in my question.....

If I compare with EIGRP, each time the route annonce route the cumulative cost of this route is also annonced in the advertivement it self. And If I remember, we can see this copst value when we use debug eigrp command. But, when we use OSPF because each route must calculate itself the topology and create it's route map and base on that map decide the best route base on the bandwith of each route, how the router can know the cost or bandwith between 2 router if this link is not a link which is directly connected to it-self....

Example R1 need to know the bandwich between R2 and R3, R2 and R4, R4 and R3 to decide the best route to reach each destination.... but by using sniffer to analyse OSPF packet or by using debug command on the router, I did not see any value refer of the bandwith of each link... I see a lot of information but nothing about the speed of the link if self....

Joseph W. Doherty Thu, 09/17/2009 - 04:37

The metric, not bandwidth, is contained within a "metric" field within LSAs. Size and location vary per LSA type.

Perhaps "the" place to see this documented is the RFC 2328 (as mentioned by Peter). For example, within http://www.ietf.org/rfc/rfc2328.txt, if you look at "A.4.2 Router-LSAs", look for "metric" under "Link Data".

xine xine Thu, 09/17/2009 - 16:48

Hi everybody !

you talking the metric itself is include in the LSA.....

which value should interpretes as a metric in those output command.... see in the zip file output command....

and in the sniffers case interpretation please sniffers 1.bmp & sniffer2.bmp attached files.....

I aks the question to some at my office he response me if the cost is base on bandwith, the bandwith command must be present to make the bandwith can be used, if not bandwith command not metric can be announced on bandwith....

This response left me perplex.... I think this not a good response because first bandwith command is not use on family ehternet interface, the command is accepted there but is not used most of the time... On serial interface I know a default value is used when bandwith command is not specified, if I remember correctly this value is 1.54Mbps and this value is used as a bandwith value to calculate the metric independantly what is the real bandwith of the interface.

other question always on OSPF

in the followin text is domain mean Autonomous system ?

``Routers in a domain Minimum 20 Mean 510 Maximum 1000

Routers per single area Minimum 20 Mean 160 Maximum 350

Areas per domain Minimum 1 Mean 23 Maximum 60

In "Designing Large-Scale IP Internetworks," Cisco recommends the following guidelines:

An area should have no more than 50 routers.

Each router should have no more than 60 OSPF neighbors.

A router should not be in more than three areas.

These values are recommended to ensure that OSPF calculations do not overwhelm the routers. Of course, the

network design and link stability can also affect the load on the routers.``

Attachment: 
Joseph W. Doherty Thu, 09/17/2009 - 18:46

I don't see the metric field in your sniffer BMP files. Perhaps the sniffer version you're using doesn't show it decoded?

I wouldn't expect any of the Cisco debug options to decode this part of the OSPF LSA. However, if you show ip route, costs shown should be cummulative metric cost. If you set up a small lab, should be easy to see them change as you change OSPF interface costs.

There's, I believe, a default bandwidth for Ethernet interfaces based on active line speed.

re: AS and OSPF

http://en.wikipedia.org/wiki/Open_Shortest_Path_First

http://en.wikipedia.org/wiki/Autonomous_system_(Internet)

It's also described in the RFC 2328 (see post's reference link).

xine xine Sun, 09/20/2009 - 17:02

Hi !

In my previous posting the sniffer snapshot I had provide came from CiscoPress Book OSPF Network Design Solutions. I don'.t know which software was used to create those, but when I had use WireShark software in my lab in the my packet analysist, I was'nt see anything about metric also in LSA packet....

About the second part of my last posting, the author provide a design guide here copy paste from Authorized Self Study Guide :

"

Routers in a domain Minimum 20 Mean 510 Maximum 1000

Routers per single area Minimum 20 Mean 160 Maximum 350

Areas per domain Minimum 1 Mean 23 Maximum 60

In "Designing Large-Scale IP Internetworks," Cisco recommends the following guidelines:

An area should have no more than 50 routers.

Each router should have no more than 60 OSPF neighbors.

A router should not be in more than three areas.

These values are recommended to ensure that OSPF calculations do not overwhelm the routers. Of course, the

network design and link stability can also affect the load on the routers.

"

when she's talking about "domain" is she mean : Autonomous System ?

Later in it's text she saying it's important to setup route summarisation because OSPF does'nt do any summarization by defaut.

I'm confuse about the utilisty about the argument advertise/not-advertise in command : area AREA_ID range ADDRESS MASK [advertise|not-advertise][cost COST]

If I have a route why we do not advise it ? If I don't want this network reacheable why I was installed router and the link itself ?

and when advertise keyword is-it necessairy ? same question are good for both ABR and ASBR, but for ASBR we have only not-advertise keyword !! (I don't know why exactly)

Joseph W. Doherty Wed, 09/16/2009 - 20:00

How a router "knows" OSPF link cost varies per vendor. All should have a method to provide this information to the OSPF routing protocol. With Cisco, you can manually configure the OSPF cost per interface, or as Peter describes, Cisco will "autocost" (based on the interface's bandwidth statement). (Also note, other vendors [at least until more recently] might not offer an OSPF autocost feature, and if they do, the default reference bandwidth might be different and might not be adjustable. The latter can be very important when using OSPF across different vendor platforms.)

Optimal route is based on least cost using the sum of the costs from any particular router to the OSPF egress point. (BTW, it can differ in the reverse direction.)

PS:

Also BTW, what Peter describes for addressing links with more than 100 Mbps (if Cisco autocosting), i.e. the issue with being able to distinguish between different high bandwidth links is correct, but when you do, you might have a similar problem at the low end of the link bandwidths when using Cisco OSPF autocosting with a higher reference bandwidth. I.e., you might no longer be able to distinguish between a full T1 and half T1. (NB: This because, I recall[?] OSPF cost uses 16 bits. I.e. it can overflow.)

Peter Paluch Thu, 09/17/2009 - 12:14

Hello Joseph,

Regarding the metric size, you are right. The interface metric is 16 bits long as given by the LSA1 format. The total metric of a route in OSPF must fit into 24 bits, as that is the size of the metric field in the LSAs 3, 4, and 5.

Regarding the autocost - yes, if the reference bandwidth is too high then the result of the computation might not fit into 16 bits. However, for a T1 of 1544 kbps, the constant would have to be at least 1544*65536 kbits which is over 100 Gbps. But you are completely right, the reference bandwidth has to be chosen wisely to not to cause metric overflows.

Best regards,

Peter

Joseph W. Doherty Thu, 09/17/2009 - 18:08

Peter,

BTW, I did bump into the overflow issue once when I tried to use 10 gig for an autocost reference bandwidth. It was some years ago, also using mixed routers environment (Cisco and another vendor). At the time, it appeared OSPF cost metric overflowed (on the router computing SPF) when cumulative metric exceeded 16 bits. If what I observed was correct, possibly incorrect implementation of OSPFv2 standard. (During the same period, also had an issue with Cisco not doing multiple OSPF equal cost routes, I thought, correctly when number of such routes exceeded max paths defined for OSPF router process.) Haven't retried either of these on current Cisco software.

Actions

This Discussion