Computer Networks Essentials / Network Protocols in Detail

BGP (Border Gateway Protocol)

๐Ÿค” What is BGP? (Basic Idea)

Inside a small network (like a company), protocols like RIP and OSPF work well.

But the Internet is:

  • Huge ๐ŸŒ

  • Made of thousands of independent networks

  • Controlled by different organizations

๐Ÿ“Œ How do these large networks communicate with each other?

๐Ÿ‘‰ Answer: BGP


๐Ÿง  Simple Definition

๐Ÿ“Œ BGP (Border Gateway Protocol) is an inter-domain routing protocol used to exchange routing information between different autonomous systems on the Internet.


๐Ÿง  One-Line Understanding

BGP decides how data travels between large networks on the Internet.


๐Ÿง  Real-Life Analogy

โœˆ๏ธ International Flight Routing

  • Inside a city โ†’ local roads (OSPF, RIP)

  • Between countries โ†’ international air routes (BGP)

๐Ÿ‘‰ BGP = Internetโ€™s global traffic controller


๐Ÿงญ Where Does BGP Work?

  • BGP works at the Network Layer

  • Uses TCP (reliable delivery)

  • Uses Port 179

๐Ÿ“Œ This makes BGP reliable and stable.


๐Ÿงฉ What is an Autonomous System (AS)?

๐Ÿ“Œ An Autonomous System (AS) is a collection of IP networks controlled by a single organization that follows a common routing policy.

๐Ÿง  Examples of AS

  • ISP networks

  • Google network

  • University networks

๐Ÿ“Œ Each AS is identified by a unique ASN (Autonomous System Number).

AS15169 โ†’ Google

๐Ÿ” Why BGP is Needed (Compared to OSPF/RIP)

Protocol

Scope

RIP

Small internal networks

OSPF

Large internal networks

BGP

Between different networks (Internet)

๐Ÿ‘‰ BGP is used for inter-domain routing.


๐Ÿง  Type of Routing Protocol

๐Ÿ“Œ BGP is a Path Vector Routing Protocol

Protocol

Type

RIP

Distance Vector

OSPF

Link State

BGP

Path Vector


๐Ÿง  What is Path Vector Routing?

  • Routes include:

    • Destination network

    • Complete path of AS numbers

๐Ÿ“Œ This helps prevent routing loops.


๐Ÿงฎ Routing Metric Used by BGP

โŒ BGP does NOT use:

  • Hop count

  • Bandwidth

๐Ÿ“Œ BGP uses POLICY-BASED routing.


๐Ÿ”‘ Important BGP Attributes

Attribute

Purpose

AS-PATH

List of ASes a route passes through

NEXT-HOP

Next router to reach destination

LOCAL-PREF

Preferred path inside AS

MED

Entry point preference

ORIGIN

Route source

๐Ÿ‘‰ Shortest AS-PATH is usually preferred.


๐Ÿงญ Types of BGP


๐Ÿ”ต 1. eBGP (External BGP)

๐Ÿ“Œ Used between different ASes

Example:

  • ISP โ†” ISP

  • Company โ†” ISP

๐ŸŸข 2. iBGP (Internal BGP)

๐Ÿ“Œ Used inside the same AS

Purpose:

  • Share external routes within AS


โš–๏ธ iBGP vs eBGP

Feature

iBGP

eBGP

AS

Same AS

Different AS

Usage

Internal sharing

External routing

Hop count

Not changed

Incremented


๐Ÿ”„ How BGP Works (Step-by-Step)

1๏ธโƒฃ BGP routers establish TCP connection

2๏ธโƒฃ Exchange OPEN messages

3๏ธโƒฃ Establish neighbor relationship

4๏ธโƒฃ Exchange routing updates

5๏ธโƒฃ Apply routing policies

6๏ธโƒฃ Best path selected

๐Ÿ“Œ BGP converges slowly but safely.


๐Ÿ“ฆ BGP Message Types

Message

Purpose

OPEN

Start BGP session

UPDATE

Share routing info

KEEPALIVE

Maintain connection

NOTIFICATION

Report errors


๐Ÿง  Why BGP Uses TCP?

  • Reliable delivery โœ”๏ธ

  • Ordered updates โœ”๏ธ

  • No packet loss โœ”๏ธ

๐Ÿ“Œ Routing stability is critical for Internet.


๐Ÿง  Advantages of BGP

  • Scales to Internet size ๐ŸŒ

  • Prevents routing loops

  • Supports routing policies

  • Very reliable

โŒ Disadvantages of BGP

  • Complex configuration

  • Slow convergence

  • Requires expert knowledge


๐Ÿง  OSPF vs BGP

Feature

OSPF

BGP

Scope

Intra-domain

Inter-domain

Algorithm

Link State

Path Vector

Metric

Cost

Policy

Speed

Fast

Slow

Usage

Enterprise

Internet


๐Ÿ›ก๏ธ Security Issues in BGP

  • Route hijacking

  • Fake route advertisement

๐Ÿ“Œ Protection methods:

  • Route filtering

  • RPKI

  • Authentication


๐Ÿง  Memory Tricks

  • BGP = Big Global Paths ๐ŸŒ

  • AS = Autonomous System

  • 179 = BGP port

  • Policy > Distance


โญ One-Line Summary

๐Ÿ”น BGP is a path-vector routing protocol that controls how data is routed between autonomous systems on the Internet.