Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
What is the Border Gateway Protocol BGP?
3.
History of BGP 
4.
Working of Border Gateway Protocol
5.
Characteristics of Border Gateway Protocol (BGP)
6.
Function of Border Gateway Protocol (BGP)
7.
BGP's Loop prevention mechanism
8.
Management Functions for BGP Route Information
9.
BGP Autonomous Systems
10.
Who operates BGP autonomous systems?
11.
Types of Autonomous systems
12.
Path Attributes
13.
BGP Neighbors
14.
BGP Tables:
15.
BGP Sessions
16.
BGP Packet Format
17.
Difference Between External BGP and Internal BGP
18.
Frequently Asked Questions
18.1.
Why is BGP a layer 7 protocol?
18.2.
What is the BGP protocol algorithm?
18.3.
How many types of BGP are there?
18.4.
How many tables are in BGP?
19.
Conclusion
Last Updated: Mar 27, 2024
Easy

Border Gateway Protocol (BGP)

Author Gunjan Batra
0 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

BGP Protocol is a routing protocol used for exchanging reachability and routing details between several autonomous systems. But that's not it. Keep reading to find out more about BGP Protocol.

This article, ‘What is BGP? Border Gateway Protocol Explained’, will discuss about BGP and its various characteristics and functionalities. We will also discuss the difference between external and internal BGP. So let's get started.

What is the Border Gateway Protocol BGP?

A BGP Protocol is a routing protocol for exchanging reachability and routing details between several autonomous systems. It is an interdomain routing protocol, and it employs path-vector routing. It is a gateway protocol to communicate routing data among internet-based autonomous systems. 

As we know, the Border Gateway Protocol operates on different autonomous systems; therefore, we need to know the history of BGP, types of autonomous systems, etc.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

History of BGP 

Learning the history of BGP protocol is vital to understand how it has evolved and came into existence. The BCP protocol was developed way before and is still in use. 

Year Update
1989 At the Internet Engineering Task Force(IETF) in Austin, on January 1989, BGP  was created, and during this time, BGP version 1 was released with RFC 1105. 
1990 -1991 During this time, two updates of BGP have released BGP Algorithm in RFC 1265 and the next in RFC 1267  BGP version 3.
1994 - 1995 BGP version 4 was released first in RFC 1654 and next in RFC 1771. Version 4 RFC 1771 is currently in use.

When the internet came and maintaining BGP became difficult, ARPANET (Advanced Research Projects Agency Network) developed the first autonomous systems. ARPANET developed it after carefully examining the issues with the maintenance of BGP. 

Also see,  Personal Area Network

Working of Border Gateway Protocol

The working of BGP includes following steps:

  1. Initialization: BGP routers establish a TCP connection, exchange open messages, and negotiate parameters.
     
  2. Route Advertisement: Routers share route information, including attributes like prefix, AS path, and next-hop.
     
  3. Path Decision: BGP routers select the best path based on criteria like AS path length and local preference.
     
  4. Route Installation: Selected routes are installed in the local routing table for forwarding decisions.
     
  5. Loop Prevention: BGP uses the AS path attribute to prevent routing loops.
     
  6. Route Aggregation: BGP supports route aggregation to reduce the global routing table size.
     
  7. BGP Peering: Routers establish peering sessions to exchange routing information.
     
  8. Policy Enforcement: Route policies are applied for control, including filtering and redistribution.
     
  9. Prefix Advertisement: BGP routers advertise prefixes to peers, indicating reachability.
     
  10. Path Attributes: BGP uses attributes like AS path and local preference for routing decisions.

Characteristics of Border Gateway Protocol (BGP)

Following are the characteristics of BGP:

  • Path Vector Protocol: BGP is a path vector protocol using AS path for routing decisions.
     
  • Policy-Based Routing: Allows administrators to define policies for fine-grained control.
     
  • Scalability: Designed for efficiency in handling large networks and the global internet routing table.
     
  • Interdomain Routing: Primarily used for connecting different autonomous systems.
     
  • Stability: Prioritizes stability in route convergence with incremental updates.
     
  • Path Selection Criteria: Uses criteria like AS path length for optimal path selection.
     
  • Hierarchical Structure: Supports hierarchical structure through route aggregation.
     
  • TCP-Based: Relies on TCP for reliable and connection-oriented communication.

Function of Border Gateway Protocol (BGP)

BGP protocol is used to transfer the routing information between different autonomous systems. It allows and manages the routers to share routing information, explore all possible pathways, and select the best path for the data to carry and share information.
 

The main function of the BGP protocol is to exchange the routing information between different AS and ensure that data takes the best route possible to its destination. It follows all the security and policy measures to maintain network security. 
 

When BGP routers establish a connection, a BGP session is introduced between them. When this session begins, they become BGP Peers. These BGP peers perform the three most important functions of the BGP protocol. 
 

  1. Authentication and Acquisition: The first is to get the authentication and acquisition between the peers. This means both peers establish a TCP connection, share the information, and agree on further communication.
     
  2. Sending Information: The following function is to send all the positive and negative reachability information.
     
  3. Verification: The last function is to verify that the connection between the routers and the network is working perfectly. 
     

BGP's Loop prevention mechanism

BGP uses the "AS Path" attribute to prevent routing loops. When a BGP router receives an update, it checks the AS Path to make sure that it doesn't contain its own AS. If it does, the update is denied to prevent loops. This helps in efficient routing and maintains stability in the network.

Management Functions for BGP Route Information

Management functions for BGP route information include:

  • Route Aggregation: Combine IP prefixes for a streamlined routing table.
     
  • Route Filtering: Control which routes are advertised or accepted.
     
  • Route Redistribution: Exchange routing info between BGP and other protocols.
     
  • Route Policy Enforcement: Implement policies for route selection and propagation.
     
  • Load Balancing: Distribute traffic across multiple paths.
     
  • Prefix Manipulation: Adjust attributes like AS path or next-hop information.
     
  • Path Selection: Determine the best path based on BGP attributes.
     
  • Monitoring and Logging: Observe route status and performance for analysis.
     
  • Security Measures: Implement safeguards against BGP security threats.
     
  • Route Refresh: Dynamically update BGP routers without session disruption.

BGP Autonomous Systems

BGP (Border Gateway Protocol) is a protocol used for routing data between different networks on the Internet. An Autonomous System is a collection of these networks under a single organization's control. BGP helps  Autonomous systems share routing information and decide the best paths for data to travel between them and enables efficient and reliable Internet communication.

Who operates BGP autonomous systems?

BGP autonomous systems are operated by a variety of entities, including:

  • Internet Service Providers (ISPs): Manage network routing and connect with other ISPs.
     
  • Enterprises: Control internal network routing and manage traffic flow.
     
  • Cloud Service Providers: Use BGP for routing within cloud infrastructure and to connect customer networks.
     
  • Content Delivery Networks (CDNs): Optimize content delivery by directing traffic efficiently.
     
  • Internet Exchange Points (IXPs): Facilitate traffic exchange between multiple networks.
     
  • Research and Education Networks: Operate BGP for internal routing and network connections.

Types of Autonomous systems

The types of Autonomous Systems (ASes) are:

  1. Transit AS: It facilitates traffic between other autonomous systems, often ISPs or large networks.
  2. Stub AS: It connects to transit Autonomous systems for outbound and inbound traffic but doesn't provide transit.
  3. Peering AS: It directly exchanges traffic with other Autonomous systems, bypassing transit.
  4. Multihomed AS: Connects to multiple transit Autonomous systems for redundancy and load balancing.
  5. Content Provider AS: It optimizes content delivery, for example, extensive cloud services or websites.

Path Attributes

Path attributes are pieces of information associated with BGP routes. They provide facts about the characteristics of the route, like the route's origin, the sequence of Autonomous Systems the route has traversed (AS path), next-hop IP address, and various other attributes that routers use to make routing decisions.

BGP Neighbors

BGP neighbors are routers that establish a connection to exchange routing information. They form looking relationships to share information about routes. BGP neighbors can be within the same or different autonomous systems (external BGP or eBGP).

BGP Tables:

BGP maintains several tables:

  • Adj-RIB-In: It received routes from BGP neighbors.
  • Adj-RIB-Out: Routes being advertised to BGP neighbors.
  • Loc-RIB: It selects the best routes for outbound traffic.

BGP Sessions

BGP sessions are logical connections between BGP neighbors to exchange routing updates. These sessions are built using TCP connections. It allows routers to share information about reachable networks.

BGP Packet Format

BGP messages are organized into packets with a header and a body. The header contains information like the message type, while the body holds the specific data, such as updates or routes being exchanged between BGP routers.

Difference Between External BGP and Internal BGP

Feature External BGP (eBGP) Internal BGP (iBGP)
Purpose Connects different autonomous systems (ASes) Operates within a single autonomous system (AS)
Neighbor Relationship Between routers in different ASes Between routers within the same AS
Metric Consideration Typically considers multiple metrics, such as AS path and MED Typically considers only the AS path
Administrative Distance Higher administrative distance (usually 20) Lower administrative distance (usually 200)
Update Propagation Must propagate routing updates to all neighbors Propagates updates within the AS
Loop Prevention Relies on AS path information to prevent loops Requires additional mechanisms to prevent loops
Next-Hop Attribute The next-hop attribute is modified during route propagation The next-hop attribute remains unchanged within the AS
Peer Relationships Usually established between different organizations Typically established between routers in the same organization
eBGP Multihop Can operate across multiple hops in the network Typically operates within a single hop or with the use of loopback interfaces
Configuration Configured with the neighbor's IP address Configured with the neighbor's router ID or IP address
Typical Use Case Used for interconnecting different ISPs or organizations Used for distributing external routing information within an AS
Examples of Uses Connectivity between different ISPs, interconnecting data centers Disseminating internet routes within an enterprise network

Frequently Asked Questions

Why is BGP a layer 7 protocol?

BGP operates at the application layer (Layer 7) of the OSI model because it involves complex routing decisions and policy-based interactions between different autonomous systems.

What is the BGP protocol algorithm?

BGP uses the path vector algorithm for route selection, considering factors like AS path length, local preference, and other attributes to determine the best path.

How many types of BGP are there?

There are two types of BGP: eBGP (External BGP) for communication between different autonomous systems and iBGP (Internal BGP) for communication within a single autonomous system.

How many tables are in BGP?

BGP maintains three main tables: the Neighbor Table, the Routing Information Base (RIB), and the Adj-RIB-Out, each serving specific functions in the BGP routing process.

Conclusion

In the article, ‘What is BGP? Border Gateway Protocol Explained’, we discussed about BGP and its various characteristics and functionalities. We have also discussed the difference between external and internal BGP. If you want to dig deeper into this topic, here are some related articles - 

You may refer to our Guided Path on Code Studios to enhance your skill set on DSA and many more. Check out essential interview questions, practice our available mock tests, and more!

Previous article
Leaky Bucket Algorithm
Next article
OSI Model
Live masterclass