Path selection
errorken
Member Posts: 21 ■□□□□□□□□□
in CCNA & CCENT
From several resources I understand that there are 3 factors in path selection;
- prefix
- administrative distance
- metric
Just as a verification; the odom book is saying that the route with the longest prefix is chosen. This makes sense to me; if you have multiple routes matching, and the prefixes are different, the one with the longest matching prefix is taken (disregarding distance/metric).
Now, when you have multiple routes with the same prefix ex :
1. 192.168.0.0 /24 [100/2464]
2. 192.168.0.0 /24 [110/2]
3. 192.168.0.0 /24 [100/5000]
In this case it would seem logic that the route with the lowest distance is chosen (matching 2 and 3) and then the route with the lowest metric within these routes (being 1). So the packets are sent out to 1. Is this somewhat correct?
- prefix
- administrative distance
- metric
Just as a verification; the odom book is saying that the route with the longest prefix is chosen. This makes sense to me; if you have multiple routes matching, and the prefixes are different, the one with the longest matching prefix is taken (disregarding distance/metric).
Now, when you have multiple routes with the same prefix ex :
1. 192.168.0.0 /24 [100/2464]
2. 192.168.0.0 /24 [110/2]
3. 192.168.0.0 /24 [100/5000]
In this case it would seem logic that the route with the lowest distance is chosen (matching 2 and 3) and then the route with the lowest metric within these routes (being 1). So the packets are sent out to 1. Is this somewhat correct?
Comments
-
dtlokee Member Posts: 2,378 ■■■■□□□□□□If only one path to a prefix exists the router will install that path in the routing table.
If more than one path to a prefix exists the router will compare the AD and install the path with the lowest AD in the routing table.
If there are multiple paths to the same prefix with the same AD the router will install the route with the lowest metric in the routing table.
If there are multiple paths to the same prefix with the same AD and the same metric the router will install up to the "maximum-paths" into the routing table. Depending on the routing protocol and code version the default number of paths will vary.The only easy day was yesterday! -
iworms Member Posts: 53 ■■□□□□□□□□Can someone tell me what "prefix" is in routing? (Or point me to a link.) I'm reading the Lammle book and he says nothing about it.
-
dtlokee Member Posts: 2,378 ■■■■□□□□□□It's a combination of the destination and mask. For example 192.168.0.0/24 and 192.168.0.0/25 are not the same prefix. It is a generic term instead of "network" which would indicate the classful network, 192.168.0.0/25 is technically a subnet, not a network.The only easy day was yesterday!
-
iworms Member Posts: 53 ■■□□□□□□□□Thanks dtlokee.errorken wrote:the route with the longest prefix is chosen
192.168.0.0/24 -- S1 (low AD/metric)
192.168.0.0/25 -- S2 (high AD/metric)
and a packet destined to 192.168.0.1 is received, then it gets sent out S2 even though AD on S1 is lower. Am I correct? -
dtlokee Member Posts: 2,378 ■■■■□□□□□□iworms wrote:Thanks dtlokee.errorken wrote:the route with the longest prefix is chosen
192.168.0.0/24 -- S1 (low AD/metric)
192.168.0.0/25 -- S2 (high AD/metric)
and a packet destined to 192.168.0.1 is received, then it gets sent out S2 even though AD on S1 is lower. Am I correct?
Yes.The only easy day was yesterday! -
errorken Member Posts: 21 ■□□□□□□□□□dtlokee wrote:If only one path to a prefix exists the router will install that path in the routing table.
If more than one path to a prefix exists the router will compare the AD and install the path with the lowest AD in the routing table.
If there are multiple paths to the same prefix with the same AD the router will install the route with the lowest metric in the routing table.
If there are multiple paths to the same prefix with the same AD and the same metric the router will install up to the "maximum-paths" into the routing table. Depending on the routing protocol and code version the default number of paths will vary.
Ok, your explanation is about multiple routes with 'same prefix' : in that case I can believe that only one route will physically be installed depending on the algorithm you described. But, isn't the interface also important? Supose the prefix is the same but the interface is different, won't I have the two routes simultaneously installed (one for interface x and one for interface y)? Again, the router would then choose based upon AD first, then metric. Leaving the other route/interface as failover.
Secondly, my example was about different prefixes. So I assume that my example and algorithm is still correct? The three routes will be installed simultaneously (since they have a different prefix) and the router will choose the route at "route time" based upon longest prefix first, then AD and lastly on metric? -
dtlokee Member Posts: 2,378 ■■■■□□□□□□First - You can't configure the same prefix or overlapping prefixes on different interfaces of the same router (except in some circumstances)
Second - If you you are looking at how the router will handle different prefixes, they will both be installed in the routing table.
Now once the routing table is built then path selection will be done on a longest match, assuming "ip classless" is on.The only easy day was yesterday! -
errorken Member Posts: 21 ■□□□□□□□□□dtlokee wrote:First - You can't configure the same prefix or overlapping prefixes on different interfaces of the same router (except in some circumstances)
Ok, so why is odom (page 484) saying this:172.160.0/16 is variably subnetted, 5 subnets, 4masks R 172.16.1.1/32 [120/1] via 172.16.25.2 serial 0/1/1 R 172.16.1.0/24 [120/2] via 172.16.25.129 serial 0/1/0 R 172.16.0.0/22 [120/1] via 172.16.25.2 serial 0/1/1 R 172.16.0.0/16 [120/2] via 172.16.25.129 serial 0/1/0 R 0.0.0.0/0 [120/3] via 172.16.25.129 serial 0/1/0
The third and fourth route have overlapping prefixes for different interfaces. So is this is a mistake in the book ?Second - If you you are looking at how the router will handle different prefixes, they will both be installed in the routing table.
Now once the routing table is built then path selection will be done on a longest match, assuming "ip classless" is on.
Well, I'm looking for the algorithm the router follows when deciding which route to take.
If I take all the information together, I come to this:
- When having routes installed with different prefixes or overlapping prefixes (wheter or not the interface is the same) the route with the longest matching prefix is taken, disregarding AD/metric
- When having multiple routes installed for the same prefix (whether or not the interface is the same) the route with the lowest AD is taken. When there are multiple for the same prefix and ame AD, the route with the lowest metric is taken.
Does this seem correct? -
dtlokee Member Posts: 2,378 ■■■■□□□□□□There is a fundamental disconnect here.
You can't assign overlapping networks or subnets to the directly attached interfaces. This is reagrding using the IP address on the directly connected interface. You can have a destination prefix that is reachable through different interfaces.
Your orginal post described path selection as using prefix/AD/Metric, that is not really accurate and I thought you were referring to how the routing table was built. The routing table is built based on the prefix then AD then metric. Once the routing table is buit the path is selected based on the longest match to what it already entered in the routing table (assuming ip classless is on). The routing of an individual packet does not consider the AD/Metric at all, that was taken into account when the routing table was built. As new routes are learned or removed the routing table is updated based on the prefix/ad/metric.The only easy day was yesterday! -
errorken Member Posts: 21 ■□□□□□□□□□dtlokee wrote:There is a fundamental disconnect here.
You can't assign overlapping networks or subnets to the directly attached interfaces. This is reagrding using the IP address on the directly connected interface. You can have a destination prefix that is reachable through different interfaces.
Ok.The routing table is built based on the prefix then AD then metric. Once the routing table is buit the path is selected based on the longest match to what it already entered in the routing table (assuming ip classless is on). The routing of an individual packet does not consider the AD/Metric at all, that was taken into account when the routing table was built. As new routes are learned or removed the routing table is updated based on the prefix/ad/metric.
Ok, thanks, that clears it out.
But the routing table will still be able to contain multiple routes for overlapping prefixes disregarding the interface right? (but only one route for a same prefix)
Second, I thought the "ip classless" was only good for supernet routing; if you have 4 interfaces with one interface being connected to network 'x' and 3 interface being connect to a subnet of network 'x' then a routing request to a subnet of 'x' that is not in the routing table will be routed to the network 'x'. I don't quite get what this has to do with taking the longest match out of the routing table....