Border Gateway Protocol: Determining the Best Routes
We left the last lesson off at the question: how do routers pick a path to reach a specific destination out of a given number of paths?
We'll cover the following
Terminology
Before addressing this question, we need to familiarize ourselves with some more BGP jargon.
- BGP Attributes: certain attributes are sent along with path advertisement. Two of the more important ones are as follows:
- AS-PATH: When a BGP router advertises a route towards a prefix, it announces the IP prefix and the path used to reach this prefix. In BGP, each domain is identified by a unique Autonomous System (AS) number. The AS-Path is just a list of AS numbers that you need to go through to get to a prefix. AS-PAThs are also used to avoid loops by domains rejecting advertisements that already contain the domain's AS number.
- NEXT-HOP: the next hop is the IP address of the relevant interface of the router that starts a certain AS-PATH.
BGP routes are written as a combination of many things out of which we will consider three:
- NEXT-HOP
- AS-PATH
- Destination Prefix
Hot Potato Routing
Assuming that a router has two paths to send a packet over to another domain, Hot Potato Routing would calculate the best path like so:
- The router will calculate the cost to reach the NEXT-HOP router of each given path. The cost can be calculated using intradomain routing protocols like OSPF.
- The path with the NEXT-HOP router that is least costly to send a packet to is chosen.
Essentially, a router has learned routes to a prefix from multiple BGP border routers. It consults its intra domain routing information to determine the border router that is reachable with the least cost. This is akin to getting rid of the packet as quickly as possible, without paying any attention to the fact that some other border router might offer a lower overall distance to the destination.
Let’s take a modification of our previous example to illustrate how this works in practice.
Note that this is a selfish algorithm, as it only cares about reducing the immediate cost and does not consider the cost of the path outside of its domain.
Furthermore, two routers within the same domain may select two different paths to reach the same destination. An example would be that would select the path via AS2 to the prefix , and that would undeniably bypass AS2 and reach via AS3.
BGP does use hot potato routing in some cases, but that is based on a more sophisticated algorithm described as follows.
Route Selection Algorithm
BGP uses a slightly more complicated algorithm in the real world.
To pick the best path out of two or more paths to the same prefix, BGP uses the following rules to eliminate each path until the best one is left:
- Each route is assigned a local preference value which is determined entirely by how the policy of each individual domain is set up by the network administrator. The route with the highest local preference value is chosen.
- Example:
- If several routes have the same highest value, then the one with the shortest AS-PATH is selected.
- Example:
- Prefer routes with the smallest MED.
- Prefer routes learned via eBGP sessions over routes learned via iBGP sessions.
- If we still have a tie, then hot potato routing is applied and the one with the least costly NEXT-HOP is chosen.
- If more than one route still remains, routes learned from the router with the lowest router ID is preferred.
- Example
Feel free to ask any questions related to the lesson in the following widget. Our AI will answer them and help you better understand the topic
Quick Quiz!
Hot potato routing always results in the overall least cost path being chosen.
True
False
This concludes our discussion of the network layer! We’ll get into the link layer next.
Get hands-on with 1400+ tech skills courses.