BGP (Border Gateway Protocol)

Algorithm that finds the best route on internet from source ip to destination ip in global scale of multiple AS (Autonomous System) that can be run on Router.

The way it works is based on a concept called peering. Where we assign certains router as BGP peer (BGP Speaker)

The way the algorithm works as follows

  1. Route discovery:
  2. Route storage:
  3. Path selection:
    • Use its algorithm to route the traffic optimally.
    • Select the best one by evaluate its attribute based on loads or have a tie breaker algorithm

We call a Router is eBGP (External border gateway protocol) router if it handles the external routing and iBGP (Interior Border Gateway Protocol) router if it handles the internal routing.

[!important]
A router can be both eBGP (External border gateway protocol) and iBGP (Interior Border Gateway Protocol)

Example

We have 4 AS (Autonomous System) system with each BGP (Border Gateway protocol) peer connects like this

Pasted image 20240713215328.png

Now C want to send a packet to B.

Route discovery

Every here and there, these router will broadcast the NLRI (Network Layer Reachibility Information), which I will simplify to just have the hop count:

As you can see in here, both A and D are sending C the advertisement information:

Pasted image 20240713215657.png

Basically A is saying that it has 1 hop from A -> B and 1 hop from A -> C. Similarly, D is saying that it has 1 hop from D -> B and 1 hop from D -> C.

Route storage

Based on these information, C will construct a routing table contains its information

Pasted image 20240713215918.png

Path selection

From here, based on route storage, C knows to reach B it can go either A -> B or D -> B. It will decides based on the traffic load at A or D or any other condition