**Christmas Offer**- Every Learner Must Check Out -

**Flat 88% OFF on All Access Pass**

00

days

:

00

hours

:

00

minutes

:

00

seconds

Author : Pankaj Kumar

Last Modified: February 7, 2024

Metric calculation is a critical component for any routing protocol. OSPF metric calculation is used to find the shortest path by using cost as a metric and determining the cost of paths to know the best path to the destination. Before understanding the OSPF and EIGRP Metric calculation, you need to know that:

The automatic and dynamic exchange of routing information between routers is made possible by the use of routing protocols. Numerous routing protocols exist, each with its own set of advantages and disadvantages due to being tailored to perform best in a certain kind of network deployment. Open Shortest Path First (OSPF) and Enhanced Interior Gateway Routing Protocol (EIGRP) are two of the most widely deployed routing protocols. In this article, we’ll explain and comprehend the two best-path-calculating routing protocols.

Check out PyNet Labs’ OSPF BGP Training

OSPF stands for Open Shortest Path First, is a dynamic routing protocol commonly used in large-scale networks, such as the internet or enterprise networks. It is an interior gateway protocol (IGP) designed to determine the most efficient routes for IP packet forwarding within a network.

OSPF Protocol operates by exchanging link-state advertisements (LSAs) between routers to build and maintain a topology database of the network. Each router uses this database to calculate the shortest path to reach a destination network, taking into account factors like link costs and network congestion.

As we know, OSPF is a link state protocol, so the router learns all the paths and their costs to the destination and selects the routes with the lowest costs to the destination. This is known as OSPF Metric calculation.

**Metric** – It is a parameter that OSPF uses to choose its best path. OSPF metrics are calculated using a cost-based algorithm.

For any given interface, the cost is always inversely proportional to the bandwidth.

- A higher bandwidth leads to a lower cost.
- A lower bandwidth leads to a higher cost.

So, the path with the lowest cost will be the best path for OSPF.

Now, as we know, OSPF utilizes link-state advertisements for network destinations, and it is known as a link-state routing protocol. For this reason, the (shortest path first) SPF algorithm is used for routing calculations based on link-state information. With OSPF, all routers share metrics and link-state information about their connected interfaces with each other.

Let’s move on to know more about the shortest-path-first algorithm.

Specifically, OSPF employs a (shortest-path-first) SPF algorithm to determine and construct the shortest route to all known destinations.

- In OSPF, routers generate a link state advertisement (LSA). This advertisement depicts the all-link states of the router.
- All routers in OSPF exchange link states by flooding LSAs. Every router that receives an LSA will store a copy of its link-state database and then forward the LSA to other routers.
- Once the database of every router is synced, it will calculate the shortest path to all possible destinations, which we call the shortest path tree (SPT).
- The algorithm puts every router in a tree and determines the shortest path to each destination by taking into account the total cost of getting there.
- Lastly, when the router builds the SPT, it starts creating the routing table.

We hope you have a good overview of the SPF Algorithm. Let’s understand the OSPF cost formula now.

Know more about OSPF LSA types here.

**You can learn more about OSPF from this video –**

The formula used by OSPF to determine cost is as follows:

**Cost = Reference bandwidth/Interface bandwidth**

In OSPF’s documentation (RFC 2338), reference bandwidth was given a completely random number. Each manufacturer must determine its reference bandwidth. When referring to bandwidth, Cisco uses 100 Mbps (108) as reference bandwidth. With this, the equation would be:

Some of the key points to follow while calculating cost is discussed below.

**Key points** –

- Cost is a positive integer value.
- All decimal values will be rounded to the nearest positive integer.
- Any value in decimal or less than 1 will be considered 1.

Now that we have the formula let’s perform the arithmetic and get the base cost of the necessary interfaces.

**Default cost of essential interfaces.**

Interface type | Bandwidth | Metric Calculation | Cost |

Serial Link | 1544Kbps | 100000000/1544000 = 64.76 | 64 |

Ethernet Link | 10Mbps | 100000000/10000000 = 10 | 10 |

FastEthernet Link | 100Mbps | 100000000/100000000 = 1 | 1 |

**The image below shows the default OSPF Cost values for various interface bandwidths.**

#show ip ospf interface fa0/0 | include cost

Router(config)#Router ospf 1

Router(config)#auto-cost reference-bandwidth 10000 (in Mbps)

#Show ip ospf | include reference

#Show ip ospf interface fa0/0 | include BW

This is everything you need to learn about OSPF Metric Calculation. Moving on to the EIGRP Section.

EIGRP stands for Enhanced Interior Gateway Routing Protocol. It is a dynamic routing protocol developed by Cisco Systems and is primarily used in enterprise networks offering advanced features for efficient and scalable routing.

EIGRP is a hybrid routing protocol that incorporates elements of both distance vector and link-state protocols. It uses the Diffusing Update Algorithm (DUAL) to calculate the shortest path to a destination network and maintain a routing table.

In EIGRP, K-Values are parameters that determine how different network characteristics contribute to the overall metric calculation. There are 5 K-Values used by EIGRP to weigh various factors while calculating metric. These K-Values allow network admins to customize the metric calculation according to the specific network requirements.

Here is the explanation of these 5 K-Values –

**K1 (Bandwidth)**– This value represents the bandwidth of the path, and it determines the contribution of the path’s bandwidth to the metric calculation.**K2 (Load)**– K2 represents the current load on the path.**K3 (Delay)**– K3 reflects the delay or latency of the path.**K4 (Reliability)**– K4 represents the reliability of the path.**K5 (MTU – Maximum Transmission Unit)**– This value represents the Maximum Transmission Unit of the path.

Network admins can change the values and prioritize the K-values as per needs when calculating metric. It’s important to note that the default values for the K-values in EIGRP are 1 for K1, K3, K5, and 0 for K2 and K4. However, these values can be modified to suit specific network requirements.

Just like OSPF, EIGRP also has a metric calculation. The Metric of EIGRP depends on five parameters which are considered as K-Values as discussed above.

**These parameters are:**

**Bandwidth**– In computing, it is the quantity of information that can be sent through a connection in a certain length of time. Bandwidth is measured in Kilobits.**Load –**It is defined as the traffic passing through the interface. It is measured on a scale of 255 where 1 represents that an interface is empty and 255 represents that an interface is fully utilized.**Delay –**The time that has been passed in processing a particular packet. It is generally calculated in microseconds.**Reliability**– It is expressed on a scale of 0 to 255. Where 255 expresses 100% reliability, and 0 represents 0% reliability.**MTU****–**stands for Maximum Transmission Unit.

**So, EIGRP uses these five factors (Bandwidth, Delay, Reliability, Load, and MTU) to calculate its metric, i.e., cost.**

CISCO technically calls these five factors** K Values **which** **are** **represented as shown in the image below –

Because load and reliability are dynamic variables, EIGRP’s default metric calculation values are (K1 & K3). However, the EIGRP procedure will become a more over-headed protocol if these values are constantly updated.

You should also check out – OSPF vs EIGRP

**Formula used for EIGRP Metric = (10^7/BW + Delay/10)} *256**

Now that we have learned about EIGRP Metric Calculation, it is time to under the EIGRP dual-diffused update algorithm.

The default K-values for the route’s EIGRP metric calculation algorithm are K1 and K3, which should always be 1, and K2, K4, and K5, which should always be 0. The IGRP metric formula is used to create the EIGRP formula, which is then multiplied by 256 to increase the calculation’s precision from 24 to 32 bits.

When we calculate the above equation with default K-Values, we will get the EIGRP Metric Formula.

You can learn more about how EIGRP Metric Calculation is done from this video –

DUAL Algorithm uses four parameters –

**Feasible distance (FD):**Total cost from the local router to the destination.

**Advertised distance/Reported distance (AD/RD):**Cost from the next-hop router to the destination.

**Successor:**The best path of EIGRP to reach a destination network. It is Stored in the routing table as well as the topology table.

**Feasible successor:**A backup path that is stored in the topology table only.

The Feasibility Condition states that a route will not be accepted if the Reported Distance exceeds the best path’s Feasible Distance.

The 5 metrics used by EIGRP to calculate the route are also known as composite metrics or components of the EIGRP metric. These are Bandwidth, Delay, Reliability, Load and MTU (Maximum Transmission Unit).

Yes, in EIGRP, a lower metric is considered better. The metric in EIGRP represents the overall cost or desirability of a route. When multiple paths are available to reach a destination, EIGRP selects the path with the lowest metric as the best route.

K-Values in EIGRP are parameters used to determine the importance or weight of different network characteristics when calculating the overall metric for a route. EIGRP uses 5 K-Values from K1 to K5.

The Hop count in EIGRP refers to the number of routers or network segments that a packet must traverse to reach its destination. However, it’s important to note that hop count is not the primary metric used by EIGRP for route selection.

Now, we have discussed both EIGRP and OSPF Metric Calculation. Open Shortest Path First (OSPF) and the extended Interior Gateway Routing Protocol (EIGRP) are two of the most widely deployed IGPs today. Both are commonly used in various business networks and have shown to be stable and reliable options throughout the years. The OSPF metric calculation depends on a metric known as cost; the lower the cost, the more suitable path will be. At the same time, EIGRP Metric Calculation is dependent on five factors.

If you are eager to learn more about EIGRP and OSPF Metric Calculation, you should join PyNet Labs’ CCNP ENCOR Training. The CCNP ENCOR Training will help you comprehend all the advanced networking skills, including OSPF and EIGRP. If you are a network engineer who wants to grow in your career, then you should check out PyNet Labs’ Job Guarantee Courses. These courses will help you upskill and get your dream networking job.