OSPF Metric Calculation, but which interface does it use to calculate its metric

We all know that OSPF uses the formula reference/bandwidth (the default reference value is 100Mbps) to calculate the cost per link then OSPF will use the SPF (Shorter Path First) Dijkstra Algorithm to calculate the metric to reach the target network.

However, which interface does OSPF uses to calculate its metric?  Is it the neighbor’s outbound interface or its inbound interface? Or both?

Let put this in the lab.  I will be using a simple OSPF topology, see Figure 1.1 below.

Figure 1.1

I have configured the IP addresses and enabled OSPF for all the routers.  I am going to focus on R3’s LAN, 172.16.1.0/24, metric from R1.  All the routers should have all the routes and their metrics.  Lets check R1’s routing table.

Example 1.1

Now, R1’s routing table is showing that the cost to get to the 172.16.1.0/24 network is 129.  Here is a quick review on how OSPF got the cost of 129.  Look back at the Figure 1.1, the link from R1 to R2 is a T1 link; and the link from R2 to R3 is T1 as well.  Each T1 link has a cost of 64 (100Mbps/1.544Mbps=64Mbps), so now we have two T1 connections which make them 128 plus the loopback interface, which is 172.16.1.0/24 (Loopback has a cost of 1, see the show ip ospf interface loopback0 output on R3)

Example 1.2

Let’s change R3’s serial 0/1 cost from 64 to 100 then let’s check R1’s routing table for the network 172.16.1.0/24 if the metric value has changed or not.

Example 1.3

Example 1.4

Well, after changing R3’s serial 0/1 cost to 100, R1 still sees the metric 129 for the network 172.16.1.0/24.  Nothing has changed.

Now, I am going to change R2’s serial 0/1 cost from 64 to 100 (see Example 1.5) then let’s check R1’s routing table (see Example 1.6) if the metric has changed or not.

Example 1.5

Example 1.6

Aha! The metric went up from 129 to 165.  Now, we know OSPF uses the inbound interface to calculate the metric.

In summary, OSPF does not use the sending interface cost to calculate the route metric, and we tested that by changing R3’s serial 0/1 interface cost to 100.  OSPF uses the receiving interface’s cost to calculate the metric for each network it receives.  All routes that R2 receives (and the network 10.1.23.0/24)  from its serial 0/1, R2 will calculate the metric using its serial 0/1 cost (100) plus the OSPF neighbor’s cost for those routes then R2 will advertise those routes to its OSPF neighbor/s in this case it is R1.

In a nutshell, when R3 advertises the network 172.16.1.0 to R2, R3 advertises it with the cost of 1 because it is a loopback interface. Now, when R2 receives the network 172.16.1.0 from R3, the received network has a cost of 1; therefore, R2 add its own cost which is 64 to the network. R2 add the cost of 64 because it is received from R2 inbound interface which is a serial interface. R2 advertise the network 172.16.1.0 to R1. R1 receives the network 172.16.1.0 from R2 with the cost of 65 (cost of 1 from R3 plus cost of 64 from R2 equals 65). Since R1 receives the network from its serial interface, R1 will add a cost of 64 to the network’s metric. This will give us a total of cost of 129.

Cheers!

Advertisements

About networkshinobi

This blog is about the things I learned about computers and networking to help me to remember them as I push further my studies. I created this blog to help myself to continue my education; and if you find this blog helpful for your studies, that is great. That is one of the reasons why I made this blog, to share my interest and knowledge. Also, all the entries/posts I made are based on my views, opinion and for educational purposes only. If you see some mistakes, feel free to drop some comments. I would appreciate all the helpful comments. Thanks
This entry was posted in CCNP, OSPF and tagged , , , , , , , , , , . Bookmark the permalink.

7 Responses to OSPF Metric Calculation, but which interface does it use to calculate its metric

  1. KANNAN says:

    Thanking yo, but i have little bit doubt why router R2 advertise R1. why not R3.
    please clear my doubt….

    • networkshinobi says:

      Hello,

      R2 will advertise R1’s network to R3. When R3 receives R1’s network 192.168.1.0 from R2, R3 will see it with the cost of 65. Now, since we changed R3’s serial interface cost value from the default value to 100, R3 will add its own cost, which is 100, to the received cost from R2 which is 65.
      Now, if we do a “show ip route ospf” on R3, we should see a metric of 129 for the network 192.168.1.0/24

  2. Allan says:

    Very good OSPF info. I understand it a lot better now but I’m confused when you say that OSPF uses inbound interfaces to calculate the metric. I can quite clearly see which interfaces are being used but I’m not sure why they are being described as inbound interfaces. Surely all interfaces can be describes as inbound or outbound.

  3. ed says:

    Don’t you mean OSPF uses the outbound interface to calculate the cost. R2 s1/0 is the outbound isn’t it?

    • networkshinobi says:

      I apologize for my late reply. I have not logged into my wordpress for quite sometime now. At this point, you probably know this.
      R2’s s1/0 is an inbound interface if the traffic is coming into R2; in this case the traffic is from R3 to R2. If the traffic is going out of R2’s s1/0 then it is an outbound.

      • sam says:

        since we are checking the route for loopback of R3 on R1 , i assume we are checking for traffic path from R1 to R3 thru R2’s s1/0 which makes it outbound, so i believe the metric is calculated based on outbound interfaces on the data path. But your last para very clearly explains this misconception i like many had, since the metric is calculated on the control plane inbound from where it received the route through. good explanation. thanks

      • Hey Sam, I am glad this post cleared some misunderstanding. Cheers!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s