Networking - Routing Protocols

1. What Are Routing Protocols?

Routing protocols are rules and algorithms used by routers to:

  • Discover available networks.

  • Exchange routing information with other routers.

  • Build and maintain routing tables.

  • Select the best path for data packets.

Routing protocols work at Layer 3 (Network Layer) of the OSI model.


2. Types of Routing Protocols

Type Example Protocols Scope
IGP (Interior Gateway Protocol) RIP, OSPF, EIGRP Inside a single organization
EGP (Exterior Gateway Protocol) BGP Between different organizations
Distance Vector RIP, EIGRP Uses hop count as metric
Link State OSPF Uses topology database
Path Vector BGP Uses AS-path attributes

3. Routing Protocols Overview

A. RIP (Routing Information Protocol)

Overview

  • Type: IGP, Distance Vector

  • Metric: Hop count (max 15 hops)

  • Algorithm: Bellman-Ford

  • Versions: RIP v1, RIP v2

  • Best for: Small networks

How RIP Works

  • Routers send routing updates every 30 seconds.

  • Uses hop count to choose the shortest path.

  • If more than 15 hops, the network is unreachable.

Example Command (Cisco)

Router(config)# router rip
Router(config-router)# network 192.168.1.0
Router(config-router)# network 192.168.2.0

Advantages

  • Simple to configure.

  • Works well for small networks.

Disadvantages

  • Slow convergence.

  • Limited scalability.

  • Uses more bandwidth due to frequent updates.


B. OSPF (Open Shortest Path First)

Overview

  • Type: IGP, Link State

  • Metric: Cost (based on bandwidth)

  • Algorithm: Dijkstra’s Shortest Path First (SPF)

  • Best for: Medium to large enterprise networks

How OSPF Works

  • Divides a network into areas for efficiency.

  • Uses a link-state database to calculate the best path.

  • Sends updates only when topology changes, not periodically.

Example Command (Cisco)

Router(config)# router ospf 1
Router(config-router)# network 192.168.1.0 0.0.0.255 area 0
Router(config-router)# network 192.168.2.0 0.0.0.255 area 0

Advantages

  • Fast convergence.

  • Scalable for large networks.

  • Supports VLSM and CIDR.

Disadvantages

  • More complex configuration.

  • Consumes more memory and CPU.


C. BGP (Border Gateway Protocol)

Overview

  • Type: EGP, Path Vector

  • Metric: AS-Path, policy-based

  • Best for: Internet routing between Autonomous Systems (AS)

How BGP Works

  • BGP connects different organizations or ISPs.

  • Chooses the best path based on multiple attributes like:

    • AS-path length

    • Local preference

    • MED (Multi-Exit Discriminator)

  • Ensures global routing stability.

Example Command (Cisco)

Router(config)# router bgp 65001
Router(config-router)# neighbor 192.168.1.2 remote-as 65002
Router(config-router)# network 203.0.113.0 mask 255.255.255.0

Advantages

  • Highly scalable.

  • Can handle thousands of routes.

  • Used on the Internet backbone.

Disadvantages

  • Complex configuration.

  • Slower convergence than OSPF or EIGRP.


D. EIGRP (Enhanced Interior Gateway Routing Protocol)

Overview

  • Type: IGP, Hybrid (Distance Vector + Link State)

  • Metric: Composite (Bandwidth, Delay, Reliability, Load)

  • Algorithm: DUAL (Diffusing Update Algorithm)

  • Best for: Medium to large Cisco-based networks

How EIGRP Works

  • Uses DUAL algorithm to ensure loop-free and fast convergence.

  • Supports VLSM and CIDR.

  • Sends partial updates instead of entire routing tables.

Example Command (Cisco)

Router(config)# router eigrp 100
Router(config-router)# network 192.168.1.0
Router(config-router)# network 192.168.2.0

Advantages

  • Faster convergence than RIP and OSPF.

  • Uses multiple metrics for better path selection.

  • Less bandwidth usage due to partial updates.

Disadvantages

  • Cisco proprietary (not fully supported on all devices).

  • More complex than RIP.


4. Comparison of RIP, OSPF, BGP, and EIGRP

Feature RIP OSPF BGP EIGRP
Type IGP, Distance Vector IGP, Link State EGP, Path Vector IGP, Hybrid
Algorithm Bellman-Ford Dijkstra SPF Path Vector DUAL
Metric Hop count Cost (bandwidth) AS-Path, policies Bandwidth + Delay
Updates Every 30s Event-driven Event-driven Event-driven
Scalability Small networks Large enterprise Global Internet Medium/Large
Convergence Slow Fast Slow Very fast
Protocol Port UDP 520 IP 89 TCP 179 IP 88
Vendor Support Open standard Open standard Open standard Cisco proprietary
Best Use Case Small LANs Enterprise LANs Internet routing Cisco-based networks

5. Diagram: Routing Protocols

      [LAN A] -------- Router 1 --- OSPF --- Router 2 -------- [LAN B]
                            \                       /
                             \---- EIGRP ---------/
                              \
                               \------ BGP ------- Internet Backbone
  • RIP → For very small LANs.

  • OSPF → Inside organizations.

  • EIGRP → Cisco-heavy networks.

  • BGP → Internet-wide routing.


6. Summary

  • RIP → Simple, but limited (15 hops max).

  • OSPF → Best for large enterprise networks.

  • BGP → Backbone of the Internet.

  • EIGRP → Fast, efficient, and Cisco-optimized.