Border gateway protocol is the way routers communicate with each other and is responsible for the communication between internet service providers. Every internet service provider is assigned with a unique ID which is known as an autonomous system (AS).
As we can see from the picture above, it shows the interconnectivity of different internet service providers. AS4788 is Telekom Malaysia (TM), the direct connection betweenTelekom Malaysia to other providers can be achieved through the undersea fiber cable network.
How do these communications work? Can one internet service provider connect to any internet service provider in the world? To explain these, we basically need to understand BGP peering.
BGP peering is essentially an agreement between internet service providers that facilitates the communication process. It is only with the consent of the involved parties that communication is allowed across..
From the technical perspective, BGP peering can be categorized into two, iBGP (internal BGP) and eBGP (external BGP). iBGP are establishments between BGP speakers within an AS, while eBGP are establishments from AS to another AS. So, in order for you to access Facebook or Youtube while you are using your TM Unifi, you are basically accessing from the internet from TM and going across multiple ASs before eventually reaching the website that you wish to visit.
BGP Path Attributes
When your BGP speaker receives a BGP prefix, there are going to be many path attributes tagged to it, and we know that these are going to be critical when it comes to the BGP doing things like choosing an optimal path to a destination and not all path attributes are created equal.
All BGP path attributes fall into four main categories.
Well known mandatory attributes; these attributes must be recognized by all BGP speakers, and must be included in all update messages. Almost all of the attributes impacting the path decision process, described in the next section, are well known mandatory attributes. (for example: Origin, AS Path, and Next Hop)
Well known discretionary attributes; these attributes must be recognized by all BGP speakers, and may be carried in updates, but are not required in every update. (for example: Local Preference)
Optional transitive attributes; these attributes may be recognized by some BGP speakers, but not all. They should be preserved and advertised to all peers whether or not they are recognized. (for example: Community)
Optional non-transitive attributes; these attributes may be recognized by some BGP speakers, but not all. If an update containing an optional transitive attribute is received, the update should be advertised to peers without the unrecognized attributes. (for example: Multiple Exit Discriminator (MED))
This list of path attributes is used by every BGP router along the path to compare different network paths and to select the ones that move to the BGP table on the routing table.
BGP Attributes list:
The best path selection algorithm for a BGP is used to choose and install the best routes into the router’s routing table from over 814,000 routes and because a BGP router can receive numerous copies of those routes from various providers, it has to compare the multiple BGP routing tables and choose the optimal route on the router.
If there are no specific settings that can affect the outcome, the BGP Best Path Selection Algorithm determines the best route by selecting the shortest path to the destination. An Autonomous System is a single network or a set of networks and routers, which are under the control of one administrative entity. Nevertheless, network administrators frequently manipulate such options as local preference, lowest multi-exit discriminator and weight.
The list of the selection criteria is presented below in the same order in which BGP uses them to select the optimal routes to be injected into the IP Routing table:
- Weight — weight is the first criterion used by the router and it is set locally on the user’s router. The Weight is not passed to the following router updates. In case there are multiple paths to a certain IP address, BGP always selects the path with the highest weight. The weight parameter can be set either through neighbor command, route maps or via the AS-path access list.
- Local Preference — this criterion indicates which route has local preference and BGP selects the one with the highest preference. Local Preference default is 100.
- Network or Aggregate — this criterion chooses the path that was originated locally via an aggregate or a network, as the aggregation of certain routes in one is quite effective and helps to save a lot of space on the network.
- Shortest AS_PATH — this criterion is used by BGP only in case it detects two similar paths with nearly the same local preference, weight and locally originated or aggregate addresses.
- Lowest origin type — this criterion assigns higher preference to Exterior Gateway Protocol (EGP) and lower preference to Interior Gateway Protocol (IGP).
- Lowest multi-exit discriminator (MED) — this criterion, representing the external metric of a route, gives preference to the lower MED value.
- eBGP over iBGP — just like the “Lowest origin type” criterion, this criterion prefers eBGP rather than iBGP.
- Lowest IGP metric — this criterion selects the path with the lowest IGP metric to the BGP next hop.
- Multiple paths — this criterion serves as indication whether multiple routes need to be installed in the routing table.
- External paths — out of several external paths, this criterion selects the first received path.
- Lowest router ID — this criterion selects the path which connects to the BGP router that has the lowest router ID.
- Minimum cluster list — in case multiple paths have the same router ID or originator, this criterion selects the path with the minimum length of the cluster list.
- Lowest neighbor address — this criterion selects the path, which originates from the lowest neighbor address.