{"id":987,"date":"2022-01-12T14:37:39","date_gmt":"2022-01-12T19:37:39","guid":{"rendered":"https:\/\/itp.nyu.edu\/networks\/?page_id=987"},"modified":"2024-04-01T18:22:10","modified_gmt":"2024-04-01T22:22:10","slug":"border-gateway-protocol-bgp","status":"publish","type":"page","link":"https:\/\/itp.nyu.edu\/networks\/border-gateway-protocol-bgp\/","title":{"rendered":"Border Gateway Protocol (BGP)"},"content":{"rendered":"\n<p>by Sam Heckle<\/p>\n\n\n\n<p>Border gateway protocol (and will subsequently be referred to as BGP) is the duct tape of the internet. But to really understand what BGP is we need to define a few other things.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Autonomous_System_AS\"><\/span>Autonomous System (AS)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Firstly we need to establish the hierarchy of the internet. At the top most level we have <strong>The Internet<\/strong> which is a network of networks. This includes but is absolutely not limited by: the network that is your home system (so your wifi with encompassing infrastructure such as your router and modem), networks controlled by your internet service provider (ISP, such as Comcast or Spectrum), or even your school or work network. Effectively, every single device connected to the internet is connected to an autonomous system.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"798\" height=\"640\" src=\"https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/autonomous-networks.png\" alt=\"a flowchart with 3 layers. the topmost layer is a box titled &quot;the internet&quot; that feeds into the second layer composed of 4 boxes, each titled &quot;autonomous system #&quot; that are numbered 1-4. The third layer is composed of purple boxes with the text &quot;ip address&quot; inside of them. there are 3 purple boxes connected to the first autonomous system, 1 purple box connected to the second autonomous system, 2 purple boxes connected to the third autonomous system, and 3 purple boxes connected to the fourth autonomous system.\" class=\"wp-image-1219\" srcset=\"https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/autonomous-networks.png 798w, https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/autonomous-networks-300x241.png 300w, https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/autonomous-networks-768x616.png 768w\" sizes=\"(max-width: 798px) 85vw, 798px\" \/><\/figure>\n\n\n\n<p>An autonomous system in this case operates as a set of protocols, but it is also a generic term for an independent network. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh7-us.googleusercontent.com\/HxJcAlTtyFT8bSyIxMPHpFKYpxPLu8WEU1sfG4LcApb6Fin-Pcy8kbzYBXX2J9K2OmUEVnrFmXA01L0qflRn9kCsiPoGAjdB_Tv4mxIYOv6P9balqNfAxAuMWAcpCq0M6ZLrT4Dnal1nghrCJX60jg\" alt=\"An image of the globe that has 7 clusters. Each cluster has a central node and 6 expanding nodes. Of each cluster, there is one node selected with a color and has a name such as AS13335 and is highlighted orange.\" width=\"400\" height=\"353\"\/><\/figure><\/div>\n\n\n<p>However, what we are explicitly looking at is how data is transferred <em>between <\/em>each autonomous system. How do we get information from here:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"641\" height=\"481\" src=\"https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/2.png\" alt=\"the same 3 layer flowchart with internet, autonomous systems and ip addresses with the bottommost ip address highlighted in red.\" class=\"wp-image-1223\" srcset=\"https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/2.png 641w, https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/2-300x225.png 300w\" sizes=\"(max-width: 641px) 85vw, 641px\" \/><\/figure><\/div>\n\n\n<p>To here:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"626\" height=\"503\" src=\"https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/3-as.png\" alt=\"the same 3 layer flowchart with internet, autonomous systems and ip addresses with the topmost ip address highlighted in red.\" class=\"wp-image-1224\" srcset=\"https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/3-as.png 626w, https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/3-as-300x241.png 300w\" sizes=\"(max-width: 626px) 85vw, 626px\" \/><\/figure><\/div>\n\n\n<p>Well, BGP is effectively this: <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"626\" height=\"503\" src=\"https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/4-as.png\" alt=\"the same 3 layer flowchart with internet, autonomous systems and ip addresses with the connections between the internet and autonomous systems highlighted in red.\" class=\"wp-image-1225\" srcset=\"https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/4-as.png 626w, https:\/\/itp.nyu.edu\/networks\/wp-content\/uploads\/2024\/04\/4-as-300x241.png 300w\" sizes=\"(max-width: 626px) 85vw, 626px\" \/><\/figure><\/div>\n\n\n<p>To reiterate, BGP is the duct tape. Another analogy would be each autonomous system is a highway exit, where each IP address is a location on that exit route. BGP operates as the highway that connects each exit to another.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"BGP_vs_IP\"><\/span>BGP vs. IP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Internet protocol (IP) is <em>different<\/em> from <em>border gateway <\/em>protocol because the IP address is the destination and BGP is the journey. Again, BGP is the freeway that gets us from one place to another.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"BGP_and_AS\"><\/span>BGP and AS<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<p>So, border gateway <em>protocol<\/em> is the set of rules that autonomous systems use to direct data packets to the correct destination in the <em>fastest <\/em>possible route. The destination will not always be within the same AS, might need to cross multiple autonomous systems to get there. The data packet can and will jump across networks. In order to understand how BGP and AS interact with each other, we also need to understand how each element of an autonomous system knows about another autonomous system. To reiterate, each autonomous system knows the exact IP addresses it controls, which is called the \u201cIP address space\u201d.&nbsp; What each AS does <em>not<\/em> know is how it is connected to other autonomous systems. <strong>This is what BGP handles<\/strong>. BGP knows which AS connects to other AS, which is defined as a \u201cNext Hop\u201d attribute. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/lh7-us.googleusercontent.com\/jaE3VdtemnaiQzPjRZ9Jgmojaxplm14zK3UY8SknGUQQwkyXda5jP8qymFlcZ4epxwS6xJrcB0jf2zjFEoeBef9g1CRYsJpOKVAAHm-UI4MbZkFL3xjofLXxFOT2mimYfq4D9_ED43oS02ln7fnDuQ\" alt=\"An example of routing table attributes and information. The text shows a screenshot from a terminal that has a table that lists &quot;network&quot;, &quot;next hop&quot;, and &quot;metric locprf weight path&quot;.\"\/><figcaption class=\"wp-element-caption\">an example of a BGP file output<\/figcaption><\/figure><\/div>\n\n\n<p>Every time that a network (AS) is updated, or goes down, or a new one comes up, the route between neighboring autonomous systems changes. This can happen when there is a power outage in an area, or if there are system issues related to an ISP.&nbsp; Similar to an exit closure on a highway! The BGP registers the failed hop, and subsequently updates the routing tables where each packet should go after the route itself is updated.&nbsp;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/www.shutterstock.com\/image-photo\/electronic-traffic-sign-stating-use-600nw-1684276420.jpg\" alt=\"image of an led road sign that says in orange text: &quot;use alt routes&quot;\"\/><\/figure><\/div>\n\n\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_does_BGP_actually_work\"><\/span>How does BGP actually work?<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<p>And, how is BGP actually represented? As pictured above, it is effectively a table that shows the current network, and the places that that data can go to from the current network. To do this, effectively BGP is a <em>finite state machine<\/em>, meaning it does a specific set of computations which ultimately changes the <em>state<\/em> of the operation. There are six states in BGP: Idle, Connect, Active, OpenSent, OpenConfirm, and Established. BGP is inherently a program that exists on each device that connects other devices to the internet (eg. router), and these are called \u201cBGP-speaking devices\u201d. For example, your home router is connected to the internet via an ISP will has its own routing table, but the default route connects it to an overarching set of rules that your ISP manages.&nbsp;However, your home router does not have its own BGP since it takes up too much memory. Instead, it is directed to your ISP BGP router which manages all the connections.<\/p>\n\n\n\n<p>An interesting aside \u2013 BGP does not have a broader specific certification as of now and can be relatively insecure. But, Cloudflare has created a certification to validate that each AS that is logged in a BGP is secure. I personally will not go into this too much, but you can read about the certification <a href=\"https:\/\/blog.cloudflare.com\/rpki\/\">here<\/a>, along with a list of Internet Service Providers that are \/ are not secure <a href=\"https:\/\/isbgpsafeyet.com\/\">here<\/a>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_does_this_have_to_do_with_the_internet\"><\/span>What does this have to do with the internet?<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<p>So, what does this have to do with the internet as a whole? As you might have guessed, and to reiterate, border gateway protocol is the duct tape of the internet, connecting all of the data pertaining to the IP addresses, and wires them together in a <em>route table<\/em>. This table has a list of several IP ranges. Each router exists as an IP address, and they each have their own BGP that stores all of the information of where each IP address goes and the fastest way to get there.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_about_Facebook_now_called_Meta\"><\/span>What about Facebook (now called <em>Meta<\/em>)?<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<p>In October 2021 (right before this explainer was written), Facebook went down for an entire day. Every app they own, from Facebook, to Instagram, to Whatsapp, to their <em>authentication for their employees<\/em> was down. Facebook has its own autonomous system that they own and operate themselves. So, they also maintain their own BGP rules. Somehow, someone updated a rule that connected the IP addresses (that point to facebook.com), to their \u201cNext Hop\u201d. Their entire AS was effectively disconnected from the broader network of the internet.&nbsp; Now we know what this is on a technical level, but the <a href=\"https:\/\/engineering.fb.com\/2021\/10\/05\/networking-traffic\/outage-details\/\">press release<\/a> described it as \u201ca command was issued with the intention to assess the availability of global backbone capacity, which unintentionally took down all the connections in our backbone network, effectively disconnecting Facebook data centers globally\u201d. Someone had gone in, changed the routing table (read, BGP), and had completely removed all of the paths that connected Facebook\u2019s autonomous systems to the web.&nbsp;<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<p>Hopefully you are now a little bit more well versed in border gateway protocol!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"References\"><\/span>References:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><a href=\"https:\/\/www.cloudflare.com\/learning\/network-layer\/what-is-an-autonomous-system\/\">https:\/\/www.cloudflare.com\/learning\/network-layer\/what-is-an-autonomous-system\/<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/jvns.ca\/blog\/2021\/10\/05\/tools-to-look-at-bgp-routes\/\">https:\/\/jvns.ca\/blog\/2021\/10\/05\/tools-to-look-at-bgp-routes\/<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/web.archive.org\/web\/20130928115120\/http:\/\/www.orbit-computer-solutions.com\/BGP.php\">https:\/\/web.archive.org\/web\/20130928115120\/http:\/\/www.orbit-computer-solutions.com\/BGP.php<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/engineering.fb.com\/2021\/10\/05\/networking-traffic\/outage-details\/\">https:\/\/engineering.fb.com\/2021\/10\/05\/networking-traffic\/outage-details\/<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/ipcisco.com\/lesson\/bgp-path-attributes-origin\/\">https:\/\/ipcisco.com\/lesson\/bgp-path-attributes-origin\/<\/a><\/p>\n\n\n\n<p class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\"><a href=\"https:\/\/www.youtube.com\/watch?v=wHfYUbKNEyc\">https:\/\/www.youtube.com\/watch?v=wHfYUbKNEyc<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.techrepublic.com\/article\/understanding-routing-tables\/\">https:\/\/www.techrepublic.com\/article\/understanding-routing-tables\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>by Sam Heckle Border gateway protocol (and will subsequently be referred to as BGP) is the duct tape of the internet. But to really understand what BGP is we need to define a few other things. Autonomous System (AS) Firstly we need to establish the hierarchy of the internet. At the top most level we &hellip; <a href=\"https:\/\/itp.nyu.edu\/networks\/border-gateway-protocol-bgp\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Border Gateway Protocol (BGP)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":48,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-987","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/itp.nyu.edu\/networks\/wp-json\/wp\/v2\/pages\/987"}],"collection":[{"href":"https:\/\/itp.nyu.edu\/networks\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/itp.nyu.edu\/networks\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/itp.nyu.edu\/networks\/wp-json\/wp\/v2\/users\/48"}],"replies":[{"embeddable":true,"href":"https:\/\/itp.nyu.edu\/networks\/wp-json\/wp\/v2\/comments?post=987"}],"version-history":[{"count":7,"href":"https:\/\/itp.nyu.edu\/networks\/wp-json\/wp\/v2\/pages\/987\/revisions"}],"predecessor-version":[{"id":1230,"href":"https:\/\/itp.nyu.edu\/networks\/wp-json\/wp\/v2\/pages\/987\/revisions\/1230"}],"wp:attachment":[{"href":"https:\/\/itp.nyu.edu\/networks\/wp-json\/wp\/v2\/media?parent=987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}