We can think of BGP as the GPS system of the internet, showing all data being exchanged on the internet which route it should take for efficient delivery. Imagine you are sending a text message with photos over a messenger to a friend in another country. Your message and photos traverse multiple countries before reaching their destination. BGP guides this journey by ensuring that your email data takes the most efficient path across different networks. In this article, weâll explain exactly how BGP works, so you can understand how your data moves reliably across the internet.
Introduction
While we interact with the internet seamlessly every single day, the internetâs functionality relies on a complex infrastructure that enables rapid data delivery. This infrastructure consists of an intricate web of fiber optic cables spanning countries and continents combined with cell towers and, in remote areas, satellite transmission.
Beneath this physical layer, various industries orchestrate intricate processes to harness the infrastructureâs full potential. Among these processes, routing stands out as a critical core function, facilitated by routing protocols. Routing is the method by which data, housed in data packets, is directed from its source to its destination. At the heart of internet routing lies the Border Gateway Protocol (BGP) the subject of this article.
How Does BGP Work?
Simply put, BGP helps different parts of the internet talk to each other. Each part has its own set of IP addresses, like a unique ID. BGP collects these IDs and stores them in a database. When data needs to move from one place (autonomous system) to another on the internet, BGP checks this database to find the most direct way to get there.
Now letâs explain this in more depth. To understand fully how BGP works, we first need to understand what an autonomous system (AS) is in the context of the networking world. Think of it as a part or a region of the internet, managed by a service provider, enterprise (e.g., banks, companies), or institution (e.g., universities, non-profit organizations.) So-called Tier I service providers (for example, Arelion (ex-Telia), NTT, Deutsche Telekom) serve as the internetâs backbone, with most companies and regional providers connecting to them to establish mutual network links. Organizations linked to such backbone providers become integral components of the internet, collectively forming a network of thousands of ASes. Among these, certain ASes assume the role of backbone entities (ISPs,) while others connect as smaller ASes or regions.
Each AS manages its own unique address space, which encompasses a range of IP addresses unique to that AS. ASes exchange their IP ranges, a task primarily executed by BGP. BGPâs principal function is to facilitate this exchange, sharing its own ASâs unique addresses with other ASes and receiving their IP address information from them.
IP address information is termed a ârouteâ or a âprefixâ if accompanied by its length (subnet mask). When BGP receives such routes, BGP adds them to its own database that consists of routes and ASes where they originated from. Routes can be interpreted as roads, while autonomous systems are like cities.
BGP Peering
Routers are high performance data transferring devices that receive our data, figure out the best path to send them, helping to reach the right destination as quickly as possible. Routers leverage BGP to establish connections, known as âpeering,â with other BGP routers. During this process, they exchange all IP routes stored within their databases, seeking to determine the optimal routes suggested by neighboring networks.
The fewer BGP ASes crossed, the better the path. Ideally, network operators aim to establish direct peering relationships with route owners, minimizing additional AS hops. If a router has several routes with the same prefix from a few neighboring autonomous systems, there will be only one best route that wins the competition to be installed in the BGP database. If one neighbor fails, the second-best route takes over the role in the database. This underscores BGPâs robust nature.
BGP Route Selection
We mentioned that we can imagine BGP as a GPS system that ensures all data packets take the optimal path across the internet. This process would be impossible without the BGP path attributes, which are the characteristics of each route. BGP scores potential routes using these attributes and uses an algorithm to decide which route is best. Letâs look at some of the attributes it considers when selecting the best route.
- Weight: A proprietary attribute developed by Cisco, the Weight metric is held privately by individual routers and is not communicated to neighboring routers.
- Local Preference: This attribute defaults to a value of 100. Assigning a higher value to a route elevates its priority within the network. The Local Preference value is disseminated to all routers within the AS, effectively designating the preferred exit point from the AS.
- AS Path Length: Represents the number of ASes a data packet must pass through en route to its destination. Shorter AS Path Lengths are generally preferred.
- Origin: Indicates the source of the route information, either acquired from another routing protocol like OSPF or directly from BGP.
- MED (Multi-Exit Discriminator): This metric allows routers outside an AS to gauge the most efficient entry point into that AS.
Attributes collectively help network operators make intelligent decisions to control their organizationsâ traffic patterns with the help of BGP, ensuring efficient data transmission. This approach can also help with cost savings for companies. By setting path attributes, companies can prefer cheaper links over pricier alternatives, simply by configuring weight or local preference values on routers.
Attribute Priority
When the above attributes are systematically applied to incoming routes from BGP neighbors, the result is a well-defined routing policy. The way this works is by considering multiple attributes, but not all at once, according to numeric values. Within a routing policy, specific values can be assigned to different sets of routes based on the BGP attributes. For example, one group of routes might be assigned a Local Preference value of 150 to indicate high priority, whereas another group of routes could be designated with a Weight value of 200. These numerical values serve as criteria for the routing algorithm to make decisions on which path data packets should take.
If two or more routes have different Weight values, the one with the highest Weight is selected, and the process stops there. Local Preference, AS Path Length, and other attributes are not even considered for those routes.
However, if all routes have the same Weight or if Weight is not set (which could be the case for routers from vendors other than Cisco, as Weight is a Cisco-specific attribute,) the routing decision moves to the next attribute in the hierarchy: Local Preference. At this stage, the route with the highest Local Preference is chosen. Again, this stops the process and the lower-priority attributes are ignored.
So, when the routing policy assigns a Local Preference value of 150 and a Weight value of 200, itâs not that one is necessarily better or stronger than the other. Instead, itâs about which attribute will be examined first based on the hierarchical order. Weight will be looked at before Local Preference, and if Weight alone can determine the best route, then Local Preference wonât even come into play.
Conclusion
In this article, weâve discovered the vital role that Border Gateway Protocol (BGP) plays in orchestrating the routes and packets across the Internet. When the protocol was first invented, there were just a few thousand routes that existed in the public networks. Fast forward to the present day, there are over 930,000 routes on the internet. This astonishing growth not only signifies the growth of the Internet but also shows the evolution of our global landscape. It proves the remarkable level of scalability of BGP. As technologies evolve and the world becomes more open and interconnected, BGP remains solid, efficient, and reliable.
We provide various networking services with our customers using BGP. Customers frequently establish peering when they hold their own prefixes and bring them to our infrastructure. We establish a BGP session with them with flexible and scalable BGP routing policies. BGP can also be used when customers are seeking ways to protect their services against DDoS attacks.
Get a dedicated server and establish peering today!