How Router Select the Best Path

How Router Select the Best Path

A router works as a transformer. It receives some packets and then sends them to further destined IP addresses by choosing the best path.

But our concern is, how does a router choose the best path? This is what we’ll explore here in this blog post.

First of all, know that there are three factors that act in the process of choosing a path for a router. Therefore, to know about this topic, we’ll have to look for each aspect closely in order to understand this phenomenon.

How Router Select the Best Path

The three factors are:

  1. Prefix-length
  2. Administrative distance
  3. Metrics

It’s better to note that the factors do not always take place in the process. They only become part of this dispute when the process is manipulated by the similarities between them.

Below we’ve discussed them in detail; take a look at them. Longest prefix length – Multiple routes with a different prefix length The longest prefix length is the factor that comes first when selecting a route. Let’s say there are multiple routers with different prefix lengths leading to a destination. Then, for a router, the best path will be the IP address with maximum length, and in this process, there will be no more factors going to act on it. Even the type of protocol used does not matter.

For example:

These are the destinations with different prefix lengths.

10.1.1.0/22 10.1.1.0/25 10.1.1.0/28

And suppose a packet with an IP address of 10.1.1.1 is tended to reach the destination that is listed above. Now, the router will pick the 10.1.1.0/28, which is the largest among them regardless of the type of protocol, and it is because the longest prefix always matches the most. Here is why?

The listed example addresses have the following binary representation:

The Destined IP address is:

10.1.1.0 → 00001010.00000001.00000001.00000000

The destination IP addresses explored.

/20 → 00001010.00000001.0000|0001.00000000 /24 → 00001010.00000001.00000001|.00000000 /27 → 00001010.00000001.00000001.000|00000

As you can justify, from the given subnets the 10.1.1.0/27 is the longest prefix, and it makes it the best match of the address 10.1.1.1. That’s why the router will select this route first above all. Conclusively, it will always pick the longest prefix.

Administrative distance – When multiple routes with the same prefix length

This is the second way to choose a path for a router, and it exists when there are multiple prefixes with the same length, then a router follows the path depending upon the administrative distance, length values.

As a general rule of thumb, in this way, the protocol is an important subject. For instance, if there are static routers, BGP, OSPF, etc. you may know that already, each of these values has been assigned as the level of trust, and they all scale by a certain value. Where the lower the value means that the more trust for a router.

In the below table, you can see the administrative distance values of each protocol.

Protocol Administrative Distance Connected 0 Static 1 eBGP 20 EIGRP internal 90 IGRP 100 OSPF 110 IS-IS 115 RIP 120 EIGRP external 170 iBGP 200

For example

Let’s say if there is a destination IP address with the same prefix length. Then a router will look for the second way, which is administrative values. Below is an example. These are the three IP addresses with the same prefix length but the difference in protocol.

10.1.1.0/27 static 10.1.1.0/27 EBGP 10.1.1.0/27 IGRP

According to the rule of choosing the best path, the router will select the static route in order to forward the packet since it has the lowest administrative distance, which means more trust.

Note that if the prefix lengths are not equal and the static protocol IP’s prefix is lower than EBGP. Something like that;

10.1.1.0/22 static 10.1.1.0/28 EBGP

In this case, the router will go with the length prefix method, regardless of the protocol associated with them.

Metrics – When multiple routes with the same prefix length and protocol

This is the last way to choose the best path for a router, and it comes to exist when all the parameters are the same. For example, the prefix length, the protocols for multiple IP addresses are the same for each. At that point, a router follows the in-depth paths as speed, hops, distance, etc. And choose the one according to these scales.

A routing protocol can learn multiple paths for the same destination. In this case, each routing protocol uses its own internal metrics, for example, based on distance, speed, hops, etc.) to calculate which of those paths is the best one. For example: Suppose there are destined IP addresses with the same characters.

10.1.1.0/22 static 10.1.1.0/22 static 10.1.1.0/22 static 10.1.1.0/22 static

At this stage, a router chooses the one which has the more stability, speed, hops, and closer to it.

Summary

A router chooses the first by looking at the prefix length with the more excellent value by the given information. Mind that, the prefix should be different from each one. In case the prefix values are the same, then a router chooses the path by looking at the administrative weight, which ultimately relates to protocols. The lower value protocol is the best path for a router; for instance, the direct protocol has the 0 value, and static has one value.

Lastly, when the protocol and the prefix lengths both are the same in the various IP addresses. At that moment, a router chooses the path according to their sub-values, including speeds, distance, hops, and the list goes on, covering the many parameters that sometimes are hard to put in words.


Share post on
David Peter
By David Peter

Hi, this is David Peter from California, USA. By profession, I am working as an Telecommunication engineer with a reputable Telecommunications Company here in California. I am a tech savvy person, and that is why I love my job. This blog is my part time hobby, and I love to write reviews about different products based on my own knowledge and experience. When you go through my reviews, you will feel that they are unbiased reviews as they come direct from my heart for tech lovers. The purpose is to help and guide people who are looking to buy or upgrade their electronic gadgets like modems and routers etc. Enjoy and give your feedback in comments!


Please add "Disqus Shortname" in Customize > Post Settings > Disqus Shortname to enable disqus

Best of Router is reader-supported. When you buy through links on our site, we may earn an affiliate commission.

Blog

What Happens When You Reset Your Wireless Router

If you own a wireless router, you might think of the various functions it...

By David Peter
Blog

How To Change Wifi Password On Computer

It is suggested to change your default wifi password for better security. If your...

By David Peter
Blog

What ‌Is‌ ‌My‌ ‌Router‌ ‌Login‌

To change many necessary router settings like its name, password, create a guest network...

By David Peter
Blog

How To Connect Printer To Wireless Router Network

How to Connect Printer To Wireless Router Network Before we see how to connect...

By David Peter
Blog

How To Replace Router With A New One

If your router is older than four years and needs a replacement, you might...

By David Peter
Blog

How To Restart Wifi Router From Phone

Restarting wifi is the first solution we think of when we face any connectivity...

By David Peter
Blog

How To Protect Wifi From Neighbors

Suppose your wifi has been behaving sketchily recently, like turning on or off by...

By David Peter
Blog

How To Change Wifi Name In Mobile

When you purchase your router, it might have a name that is inconvenient to...

By David Peter

Latest Posts

Blog

What Happens When You Reset Your Wireless Router

If you own a wireless router, you might think of the various functions it...

By David Peter
Blog

How To Change Wifi Password On Computer

It is suggested to change your default wifi password for better security. If your...

By David Peter
Blog

What ‌Is‌ ‌My‌ ‌Router‌ ‌Login‌

To change many necessary router settings like its name, password, create a guest network...

By David Peter
Blog

How To Connect Printer To Wireless Router Network

How to Connect Printer To Wireless Router Network Before we see how to connect...

By David Peter
Blog

How To Replace Router With A New One

If your router is older than four years and needs a replacement, you might...

By David Peter
Blog

How To Restart Wifi Router From Phone

Restarting wifi is the first solution we think of when we face any connectivity...

By David Peter
Blog

How To Protect Wifi From Neighbors

Suppose your wifi has been behaving sketchily recently, like turning on or off by...

By David Peter
Best Router for 400 Mbps Home Routers

Best Router for 400 Mbps

Getting a good internet requires two main components. One is a good connection and...

By David Peter