Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Routing Protocols: RIP, OSPF, BGP & Routing Algorithms

Lesson 12 of 15 in the free Computer Networks notes on Siksha Sarovar, written by Rohit Jangra.

Routing Protocols: RIP, OSPF, BGP & Routing Algorithms

---

1. Routing Algorithm Types

Distance-Vector Routing

  • Each router knows only the distance (hop count or metric) to each destination and the direction (vector/next hop) to reach it
  • Bellman-Ford algorithm: Iteratively update shortest path estimates based on neighbours' information
  • Distributed computation: Each router shares its routing table with direct neighbours only
  • Convergence: Slow — changes propagate hop-by-hop ("count to infinity" problem)

Link-State Routing

  • Each router knows the complete network topology (all links and their costs)
  • Dijkstra's algorithm: Each router independently computes the shortest path tree
  • Flooding: Each router floods Link State Advertisements (LSAs) to all other routers
  • Convergence: Fast — all routers have consistent topology view after flooding

Path-Vector Routing

  • Extension of distance-vector for inter-domain routing (between Autonomous Systems)
  • Each route advertisement includes the complete AS path to the destination
  • Prevents routing loops and allows policy-based routing decisions
AlgorithmProtocolConvergenceScaleLoop Risk
Distance-VectorRIPSlowSmallYes (count to infinity)
Link-StateOSPF, IS-ISFastLargeNo (each router has full map)
Path-VectorBGPSlowInternet-scaleNo (AS path prevents loops)

---

2. RIP (Routing Information Protocol)

RIP is a classic distance-vector protocol using hop count as its metric.

RIP Characteristics

FeatureRIPv1RIPv2
MetricHop count (max 15)Hop count (max 15)
Classful/ClasslessClassful onlyClassless (CIDR support)
UpdatesBroadcast (255.255.255.255)Multicast (224.0.0.9)
AuthenticationNoneMD5 or plain text
VLSM supportNoYes

RIP Limitations

  • Maximum 15 hops — any destination with metric ≥ 16 is considered unreachable. Cannot be used in large networks.
  • Count-to-infinity problem: When a link fails, routers may iteratively increment metric in a loop until it reaches 16. Solutions: split horizon, route poisoning, holddown timers.
  • Convergence: Very slow — uses periodic updates every 30 seconds.

Split Horizon Rule: A router does not advertise a route back out the interface through which it was learned — prevents some routing loops.

---

3. OSPF (Open Shortest Path First)

OSPF is a link-state protocol using bandwidth-based cost as its metric.

OSPF Concepts

ConceptDescription
Router ID32-bit identifier for each OSPF router (highest IP or configured)
LSA (Link State Advertisement)Each router floods LSAs describing its directly connected links
LSDB (Link State Database)All received LSAs — complete topology map
SPF AlgorithmDijkstra runs on LSDB to compute shortest path tree
Designated Router (DR)Elected on multi-access networks to reduce LSA flooding
AreaOSPF divides large networks into areas to limit LSA flooding scope

OSPF Hierarchy

  • Area 0 (Backbone): The central OSPF area — all other areas must connect to it
  • Internal routers: All interfaces in same area
  • ABR (Area Border Router): Connects two or more areas; summarises routes
  • ASBR (Autonomous System Boundary Router): Connects OSPF domain to external routing domains

OSPF Metric (Cost)

Cost = 10^8 / Bandwidth (bps)

  • 100 Mbps Ethernet: cost = 10^8 / 10^8 = 1
  • 10 Mbps Ethernet: cost = 10^8 / 10^7 = 10
  • T1 (1.544 Mbps): cost = 10^8 / 1,544,000 ≈ 64
Exam Tip: OSPF uses Dijkstra's algorithm; RIP uses Bellman-Ford. OSPF metric = 10^8 / bandwidth. OSPF is open standard; EIGRP is Cisco proprietary. OSPF area 0 is the backbone — required.

---

4. BGP (Border Gateway Protocol)

BGP is the path-vector protocol that runs the global internet — the only protocol connecting different Autonomous Systems (ASes).

BGP Key Concepts

ConceptDescription
AS (Autonomous System)Set of networks under single administrative control
ASN (AS Number)Unique identifier for each AS (e.g., AS 15169 = Google)
eBGPBGP between routers in different ASes
iBGPBGP between routers in the same AS
AS PathList of AS numbers a route has passed through — loop prevention
Next HopIP address of the next-hop router to reach the prefix

BGP Path Selection (simplified priority order)

  1. Highest Local Preference (iBGP — prefer certain exit points)
  2. Shortest AS Path length
  3. Lowest Origin type (IGP < EGP < Incomplete)
  4. Lowest MED (Multi-Exit Discriminator — hint to neighbours)
  5. eBGP over iBGP
  6. Lowest IGP cost to Next Hop
  7. Lowest Router ID as tiebreaker

---

5. Static vs Dynamic Routing

FeatureStatic RoutingDynamic Routing (RIP/OSPF/BGP)
ConfigurationManualAutomatic (protocol learns routes)
MaintenanceManual update needed on changeAuto-converges after topology change
ScalabilityPoor (impractical for large nets)Good
SecurityHigher (no routing protocol exploits)Lower (routing protocol attacks possible)
OverheadNone (no protocol bandwidth)Some (update/LSA messages)
Best forSmall networks, stub routes, default routesMedium to large networks

---

6. Routing Protocol Comparison Table

FeatureRIPOSPFEIGRPBGP
TypeDistance-VectorLink-StateAdvanced D-VPath-Vector
AlgorithmBellman-FordDijkstraDUALPath-Vector
MetricHop countCost (bandwidth)CompositeAS Path + attrs
ConvergenceSlow (minutes)Fast (seconds)Very fastSlow (minutes)
Max hops15UnlimitedUnlimitedUnlimited
ScaleSmallLargeLargeInternet-scale
StandardOpenOpenCisco proprietaryOpen
AD (Cisco)1201109020 (eBGP)
Exam Tip: Administrative Distance (AD) on Cisco routers: directly connected = 0, static = 1, EIGRP = 90, OSPF = 110, RIP = 120. Lower AD = more trusted. When multiple protocols know a route, the lowest AD wins.

---

Study Deep: How Internet Routing Works

  • BGP is the glue of the internet: ~70,000 ASes worldwide exchange reachability information via BGP. When you access a website, BGP determines which path your packets take across international networks.
  • Route flapping: Unstable BGP routes (repeatedly appearing/disappearing) cause massive convergence events. Route dampening suppresses unstable routes temporarily.
  • OSPF in enterprise: Most corporate networks use OSPF internally with multiple areas to partition the network and limit LSA flooding scope.
  • Software-defined routing: Modern data centres increasingly use BGP even for internal routing (BGP in the data centre), replacing traditional OSPF.