Best Path Selection Algorithm in BGP

Border Gateway Protocol (BGP) is a routing protocol used to exchange routing information between different autonomous systems (AS). When multiple paths are available for a particular destination, BGP uses a best path selection algorithm to determine the best path for the traffic. In this blog post, we will discuss the best path selection algorithm in BGP.

BGP Best Path Selection Criteria

BGP uses the following criteria to select the best path:

  1. Prefer the path with the highest weight value: The weight attribute is a Cisco-specific parameter that is assigned locally to each path. Paths with a higher weight value are preferred over paths with a lower weight value.
  2. Prefer the path with the highest local preference value: Local preference is an attribute that is used to indicate the preference for a particular path within the local AS. Paths with a higher local preference value are preferred over paths with a lower local preference value.
  3. Prefer the path that was originated locally: Paths that were originated by the local router are preferred over paths that were learned from a neighbor.
  4. Prefer the path with the shortest AS path: The AS path attribute is used to indicate the sequence of ASes that a route has traversed. Paths with the shortest AS path length are preferred over paths with a longer AS path length.
  5. Prefer the path with the lowest origin type: The origin type attribute is used to indicate how a particular BGP route was learned. Paths with a lower origin type value are preferred over paths with a higher origin type value.
  6. Prefer the path with the lowest multi-exit discriminator (MED) value: MED is an optional attribute that is used to indicate the preference for a particular path when multiple paths are available from the same AS. Paths with a lower MED value are preferred over paths with a higher MED value.
  7. Prefer the path with the highest external BGP (EBGP) preference: When multiple paths are learned from EBGP neighbors, the path with the highest EBGP preference value is preferred.
  8. Prefer the path with the lowest IGP metric to the next hop: When multiple paths are available with the same attributes, the path with the lowest IGP metric to the next hop is preferred.
  9. Prefer the path that was received first: If all other criteria are equal, the path that was received first is preferred.

BGP Best Path Selection Algorithm Example

Let’s consider an example to illustrate the BGP best path selection algorithm. Suppose a router has learned the following paths for a particular destination:

Path 1: Weight = 100, Local Preference = 200, AS Path = AS 100, Origin Type = IGP, MED = 50

Path 2: Weight = 200, Local Preference = 100, AS Path = AS 200, Origin Type = EGP, MED = 100

Path 3: Weight = 150, Local Preference = 150, AS Path = AS 300, Origin Type = IGP, MED = 75

In this case, the best path selection algorithm would select Path 2 as the best path for the traffic because it has the highest weight value. If Path 2 was not available, the algorithm would select Path 1 as the best path because it has the highest local preference value. If both Path 1 and Path 2 were not available, the algorithm would select Path 3 as the best path because it has the shortest AS path length.

Conclusion

The BGP best path selection algorithm is an important aspect of BGP routing. By following the criteria outlined in this post, network engineers can ensure that BGP selects the best path for the traffic. It’s important to note that it’s possible to influence the best path selection algorithm by manipulating the BGP attributes, such as the local preference and MED values. However, it’s crucial to do so carefully and with a clear understanding of the potential impact on the network. By understanding the BGP best path selection algorithm and the factors that influence it, network engineers can optimize network performance and ensure that traffic is routed efficiently and reliably.

Leave a comment