how is route cost calculated

Unanswered Question
Jul 14th, 2008

When I do a show ip route command I see that routes have a metric like this [120/1] etc. How is the admin distance and offset weighted to calculate the cost? For example is a route with [100/5] as a metric preferred over a route showing [120/3]?



I have this problem too.
0 votes
  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (3 ratings)
buchholr Mon, 07/14/2008 - 16:08

What you are seeing in the brackets is the AD (administrative distance) and the metric. The AD is not used in calculating the cost at all. It is used to determine which route is the most believable in the case of two protocols having the same network.

For example if you had a route from RIP to and a route from IGRP to the same network, you cannot directly compare the metrics as they are calculated differently. The router will choose the IGRP route over the RIP route as the AD for IGRP is 100 and the AD for RIP is 120 (lower is better).



DIEGO ALONSO Mon, 07/14/2008 - 16:46

But part of my confusion is that the AD can be modified. I can easily have my RIP routes show an AD of 10 if I wanted. Ultimately if the router needs to make a choice between two routes I would think it used both AD and metric. So my question is how would it weigh each component? Maybe its just a simple multiplication problem? Going back to my example, which route would be chosen as the preferred route?

Syed Iftekhar Ahmed Mon, 07/14/2008 - 17:29

Router only takes AD into considerqtion when it has multiple routes in the routing table through different routing Protocols.Lets say you have two routes in routing table for a network x.x.x.x and they are reported by RIP and OSPF then router will select OSPF due to its AD.

If only one routing protocol is used then only metric is taken into consideration.

AD manipulation is used where it is required to give prefrence to a particular route which is learned throug a routing protocol with higher AD.


DIEGO ALONSO Mon, 07/14/2008 - 18:25

Somehow I don't think that's right. Isn't the metric the same as the hop count? So lets say I router has a route to that it learned via OSPF and the AD/metric looks like this [100/12]. AD is 100 but hop count is 12 which is a lot of hops! Now it gets a RIP route to that looks like this [120/1]. Yes the AD is higher but it is only 1 hop away. Will it still go with the OSPF?


Syed Iftekhar Ahmed Mon, 07/14/2008 - 20:32

Every routing protocol uses different metrics.

Rip uses Hop count as metric where as OSPF uses cost associated with the interface.

If every routing protocol was using the same metric then AD was not needed.

To answer your question if you see [100/12] then 12 is not the hop count in case of OSPF.

Its the cost to reach the advertised network.


buchholr Mon, 07/14/2008 - 20:42

Hop count is only used as the metric in RIP and RIPv2.

OSPF uses cost which is (10^8)/(b/w of slowest link)

IGRP and EIGRP use a composite of Bandwidth and Delay to calculate the metric by default, EIGRP multiplies the value by 256.

With this in mind, lets look at a very simple example:>(router a)--10mbps ethernet-->(router b)

The RIP metric from router b to is 1.

The OSPF metric from router b to is (10^8/10000000)=10

The IGRP metric is 1100 and EIGRP is 281600.

Since each of these metrics is derived differently they cannot be directly compared, so the router uses the AD to determine which is more trustworthy.

Protocol AD

RIP 120

OSPF 110

IGRP 100


So when all other things are equal, the lower AD always wins. The adjustment of the AD is for situations where you want to change the default behavior. For example, if you are trying to migrate to EIGRP from RIP, you can set the AD of EIGRP to higher than 120 until the entire network configuration is done, and then change the AD back when you are sure the EIGRP network configurations are stable.



P.S. Here is a Cisco document that also describes the route selection process, and a link at the bottom takes you to a document on administrative distance.

DIEGO ALONSO Tue, 07/15/2008 - 03:30

Thanks, I see where my confusion comes from now. Until now I have only used RIP and I am thinking about moving to EIGRP or maybe OSPF. I have made extensive use of AD and offset statements to modify default behavior due to a highly redundant network that we have put in place. What I was attempting to do is to gauge what the introduction of EIGRP or OSPF would do and how I would manage the AD/metric changes I will have to deal with when introducing the new routing protocol. I would assume that EIGRP or OSPF would also have extensive methods to modify AD/metrics/costs similar to RIP, no?

Also, do you know if there is a way to see the "hidden" routes that have been received but are not shown in "sho ip route" because they were not chosen as the preferred route? This might come in handy when troubleshooting my migration.



buchholr Tue, 07/15/2008 - 04:46

show ip rip database

show ip ospf [area-id] database

show ip eigrp [as-number]

These three commands will show their respective databases of information. These databases will have all of the information received by that protocol regardless of whether it is installed in the routing table.


DIEGO ALONSO Tue, 07/15/2008 - 05:16

I only have RIP running but the command doesn't seem to be working as you state. I know that I have at least two routes to all my subnets. I get rip from a router connected via Fa0 and another connected via GRE tunnel. If I were to use the defaults both routes would have [120/1] as their AD/metric and traffic would be sent thru both links. Since my GRE is a backup route only to be used when Fa0 path is not available I have purposely upped the metric to 10 on the GRE routes to suppress them. When the Fa0 is shutdown the GRE routes are installed. However when I use ip rip database I don't see the routes from the GRE tunnel only that Fa0 routes. I was looking for a way to confirm that we were receiving the routes from GRE without having to shutdown Fa0 but the ip rip database doesn't seem to do the trick.




Edison Ortiz Tue, 07/15/2008 - 05:29


What you see is normal. RIP isn't as advanced as EIGRP and OSPF.

As the previous poster stated, those commands will show you all available routes for such protocol with the exception of RIP.

With EIGRP, you have the concept of feasible successor of a route and OSPF is a link state protocol so all OSPF links will be listed.

RIP is a distance vector protocol and only active routes are kept in the database. If you were to lose the Fa0 link, RIP will recalculate the best path out of the network by flushing the entire database and requesting a new one from its neighbors. It doesn't have a 'successor' listed on its database.




buchholr Tue, 07/15/2008 - 05:43

Not sure why the routes aren't in the RIP database, can you post running-configs?


DIEGO ALONSO Tue, 07/15/2008 - 05:55

In a previous post ediortiz claims that RIP is not as sophisticated as the other protocols and the RIP database commmands will not work. That jives with what I am seeing.


Edison Ortiz Tue, 07/15/2008 - 06:40


want some confirmation ? :)

S2#sh ip rip data auto-summary

[1] via, 00:00:22, FastEthernet0/14

[1] via, 00:00:21, FastEthernet0/13 auto-summary directly connected, FastEthernet0/13 auto-summary

[10] via, 00:00:03, FastEthernet0/14 directly connected, FastEthernet0/14

S2(config)#router rip

S2(config-router)#offset-list 0 in 3 fastEthernet 0/13

S2#sh ip rip data auto-summary

[1] via, 00:00:05, FastEthernet0/14 auto-summary directly connected, FastEthernet0/13 auto-summary directly connected, FastEthernet0/14


S2(config)#int f0/14



00:13:07: %LINK-5-CHANGED: Interface FastEthernet0/14, changed state to administratively down

00:13:08: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/14, changed state to down

S2(config-if)#do show ip rip data auto-summary

[4] via, 00:00:21, FastEthernet0/13 auto-summary directly connected, FastEthernet0/13 is possibly down is possibly down




Please rate helpful posts

DIEGO ALONSO Tue, 07/15/2008 - 14:04

I believe you dude. I see the same thing. I was responding to a previous poster who was trying to help me with using the ip rip database command.

I realize now that I gotta learn OSPF!!




This Discussion