Border Gateway Protocol (BGP) is a routing protocol designed to exchange routing and reachability information between Autonomous System (AS) networks. BGP manages how data gets delivered between networks. AS networks have BGP-speaking routers that advertise or announce to other BGP-speaking routers they are connected to (called neighbors) the prefixes of IP addresses that they can deliver traffic to. BGP routers then use decision-making algorithms and policies established in AS-peering agreements to analyze the data they gather via the prefix announcements and choose which peer is best to send each packet of data to at any given time.
Generally, the fastest path with the fewest number of network hops is selected. Once the data moves across an AS and reaches another BGP router connected to a different AS, the process repeats itself until the data reaches the AS where the destination site is located.