Table of Contents
Introduction
Path selection is the process a routing protocol uses to decide which route to install in the routing table when there are multiple possible paths to the same destination network. It is not about how routes are exchanged in detail, and it is not about how a router forwards individual packets. It is specifically about how a routing protocol decides that one route is better than another.
Each routing protocol has its own rules for what makes a path best. Understanding these rules helps you predict routing behavior, avoid surprises, and design stable networks.
Administrative Distance vs Path Selection
Before comparing paths inside a single routing protocol, a router must choose which routing source to trust. This is handled by administrative distance, which is covered in its own chapter. Path selection operates after that first step.
So, for one destination, a router might receive:
- A static route.
- A route from OSPF.
- A route from BGP.
Administrative distance decides which of these routing sources wins. Once the winning source is chosen, path selection happens inside that protocol to determine the single best path that will be placed in the routing table.
Path selection always happens per protocol. The router does not compare a BGP metric directly with an OSPF cost. It compares BGP paths only with other BGP paths, OSPF paths only with other OSPF paths, and so on.
Basic Tie Breaking Rules Inside a Protocol
Inside a single protocol, the routing protocol:
- Collects all known paths to a given destination network from its neighbors.
- Evaluates each path using its own metric and attributes.
- Chooses the single best path according to a fixed order of comparison rules.
- Installs that best path into the routing table.
If two paths have the same metric, the protocol uses secondary criteria. For many protocols, if all tied values are equal, the router can perform equal cost multipath routing (ECMP), where several equal routes are used for load sharing.
In path selection, the lowest metric value usually represents the best path. If multiple paths have exactly the same metric and other key attributes, the router can install several of them as equal cost paths.
Metrics and Path Selection Behavior per Protocol
Each main routing protocol uses a different metric and a different order of path selection rules.
RIP Path Selection
RIP uses hop count as its metric. Each router the packet must pass through adds 1 hop. A path is considered unreachable if the hop count reaches 16.
For RIP:
- Fewer hops means a better path.
- If two paths have the same hop count, RIP can use ECMP if the implementation supports it.
RIP does not consider bandwidth, delay, or link reliability. A slow one hop path is always preferred to a fast two hop path.
OSPF Path Selection
OSPF uses cost as its metric. The cost is usually based on the interface bandwidth. Lower cost is better.
Path selection in OSPF follows a specific order:
- Prefer the route with the most specific prefix (longest prefix match) among all OSPF routes to that destination. Prefix length comparison is a routing table function, but it is very important for OSPF design.
- Prefer intra area routes over inter area routes.
- Prefer inter area routes over external routes.
- Among external routes, prefer E1 routes over E2 routes if they exist for the same prefix.
- If route type is the same, prefer the lowest cost path to the destination.
- If multiple paths have equal cost and are allowed by design, use ECMP.
There are also tie breakers such as router ID, but those depend on specific OSPF implementations.
OSPF Route Types and Path Preference
OSPF gives priority to where a route originates:
| Route type | Description | Preference (higher is more preferred) |
|---|---|---|
| Intra area | Learned inside the same OSPF area | Highest |
| Inter area | Learned from a different OSPF area | Medium |
| External type 1 | Redistributed route with cost that adds internal path cost | Lower |
| External type 2 | Redistributed route with fixed external cost only | Lowest |
Within each type, cost determines the preferred path.
EIGRP Path Selection
EIGRP uses a composite metric based on several values, commonly bandwidth and delay. Reliability and load can be used but usually are not.
The default EIGRP metric formula uses a set of weights called K values. With default K values, the metric is primarily a function of the minimum bandwidth along the path and the cumulative delay.
Although the raw formula is rarely configured manually, it is useful to remember that:
- A path with higher minimum bandwidth is usually preferred.
- A path with lower total delay is usually preferred.
- Reliability and load are monitored but do not influence the metric by default.
EIGRP path selection steps are:
- Prefer the route with the lowest feasible distance (the EIGRP metric).
- Only consider paths that satisfy the feasibility condition, which protects against loops.
- Among feasible successors, EIGRP can select multiple equal or near equal cost paths for load sharing, depending on configuration.
The feasibility condition is a loop prevention rule and belongs to distance vector behavior. For path selection it means that not all lower metric paths are always considered valid if they might create loops.
BGP Path Selection
BGP path selection is more complex. BGP is used for large scale routing, especially between organizations on the Internet. It uses many attributes and a strict order when selecting the best path.
BGP does not use a simple numeric metric at first. Instead, it compares attributes in a fixed sequence until one path wins. Only if all compared values are equal does it continue to the next step.
A simplified BGP path selection order is:
- Highest weight (Cisco specific, local to the router).
- Highest local preference.
- Prefer locally originated routes over routes learned from neighbors.
- Shortest AS path.
- Lowest origin type (IGP over EGP over incomplete).
- Lowest MED (Multi Exit Discriminator) if compared from the same AS.
- Prefer eBGP paths over iBGP paths.
- Prefer the path with the lowest IGP cost to the BGP next hop.
- Prefer the path received from the neighbor with the lowest BGP router ID.
- Prefer the path received from the neighbor with the lowest IP address.
Real implementations have more detail, but this simplified order shows that BGP checks several attributes before it considers any kind of classic hop or distance measurement.
Key BGP Attributes in Path Selection
Here is a brief comparison of several BGP attributes and how they influence path choice.
| Attribute | Scope | Preference rule in BGP |
|---|---|---|
| Weight | Local only | Highest preferred first |
| Local preference | Within an AS | Highest preferred |
| AS path length | Global | Shortest preferred |
| MED | Between ASes | Lowest preferred, with restrictions |
| Origin type | Global | IGP preferred, then EGP, then incomplete |
This makes BGP path selection very tunable. Network engineers often adjust these attributes to influence how traffic enters or leaves their network.
Longest Prefix Match vs Path Selection
Path selection chooses a best path for each destination prefix that a routing protocol knows. Routing itself then uses the longest prefix match rule to choose which prefix to use for a given IP address.
For example, if the routing table has:
- 10.0.0.0/8 with cost 10
- 10.1.0.0/16 with cost 100
A packet destined for 10.1.2.3 will always match 10.1.0.0/16 because /16 is longer than /8, even if its metric is worse. Path selection compares only routes for the same prefix length. Longest prefix match compares across different prefixes.
It is important to separate these two ideas when thinking about routing behavior.
Equal Cost Multipath (ECMP)
ECMP happens when a routing protocol discovers two or more paths to the same destination prefix with identical metrics and attributes. The protocol then instructs the router to install multiple next hops for that route.
Common properties of ECMP:
- Traffic can be load shared over several links.
- Load sharing is often per flow, not per packet, to avoid packet reordering.
- The number of equal cost paths is limited by the router implementation.
For example, OSPF can place up to a configured number of equal cost paths in the routing table. EIGRP can also install multiple equal cost, and with extra configuration even some unequal cost, paths.
For ECMP to work correctly, the paths must be truly equal in metric and type as seen by the protocol. Differences in attributes, or in route type (for example OSPF intra area vs external), usually prevent ECMP.
Path Selection and Policy Control
In many networks, the raw metric is not enough. Engineers shape traffic flows by influencing path selection with policy features, depending on the protocol:
- In OSPF or EIGRP, metrics or interface costs can be adjusted to steer paths.
- In BGP, attributes such as local preference, AS path, and MED can be modified.
These adjustments influence which path each routing protocol considers best, without changing the underlying physical topology.
Path selection plus policy control gives you fine grained control over how traffic moves through the network.
Path Selection and Convergence
Once a network change occurs, such as a link failure, the routing protocol must:
- Discover the change.
- Recalculate best paths using the path selection rules.
- Update the routing table and, if needed, send updates to neighbors.
The speed at which this process completes is called convergence. Path selection directly affects convergence time. More complex calculations or many attributes can slow down selection, but better decisions may lead to more stable traffic behavior in large networks.
Path selection is therefore not only about choosing the best path, but also about how quickly the network can adapt to a new best path when the old one is no longer available.