Network Layer · Computer Networks

Unicast Routing Protocols

Watch lectures
SVGVector Architecture Diagram (SVG)
COMPUTER NETWORKS · Module 3★ High PriorityUnicast Routing: RIP, OSPF, BGPIT Sem 6 · Code 100602 · Interior and exterior routingMNEMONICRIP = Bellman-Ford hops (max 15). OSPF = Dijkstra cost. BGP = path vector with AS-Path.IGP inside an AS (RIP, OSPF); EGP between ASes (BGP).Core BreakdownAS and typesAS = routers under one administration with one routing policy.IGP routes inside an AS; EGP routes between ASes.RIPDistance vector (Bellman-Ford); metric is hop count, max 15.Hop 16 = infinity; full table every 30 s over UDP port 520.Count to inf.After a link fails, routers keep raising the hop count to 16.Fixes: split horizon, poison reverse (16), hold-down timers.OSPFLink state: flood LSAs, build the same LSDB, run Dijkstra SPF.Cost = 10^8 / bandwidth; Area 0 backbone; DR and BDR elected.BGPPath vector, BGP-4, runs over TCP port 179 between ASes.Each AS prepends its ASN to the AS-Path attribute.Loop controlBGP drops any route that already contains its own ASN.OSPF is loop-free because everyone holds the same full topology.Diagram: Routing ProtocolsAutonomous System (AS) = one admin domainIGP: inside an ASEGP: between ASesRIPDistance Vectorhops max 15OSPFLink StateDijkstra SPFBGPPath VectorTCP port 179Count-to-infinity fixes:SplithorizonPoisonreverse (16)Hold-down180 sRIP: UDP 520, update every 30 sOSPF cost = 10^8 / bandwidth, Area 0BGP: own ASN in AS-Path = discard⚠️ Exam Traps & Viva Favorites① Why is RIP limited to 15?Hop count 16 means infinity (unreachable). Thisbounds how long count-to-infinity can last, butlimits RIP to small networks.② Split horizon, poison?Split horizon: never advertise a route back out theinterface it came from. Poison reverse: advertise itback with metric 16.③ BGP loop prevention?Check the AS-Path. If your own ASN is already inthe list, discard the advertisement. Policy, notspeed, picks the path.Tip: RIP hops, OSPF cost, BGP policyMaster Revision Table(learn it row by row!)FeatureRIP (v2)OSPFBGP-4TypeDistance vector (IGP)Link state (IGP)Path vector (EGP)AlgorithmBellman-FordDijkstra (SPF)Path vector with policyMetricHop count, max 15Cost = 10^8 / bandwidthAS-Path and policyConvergenceSlow, count to infinityVery fastModerateTransportUDP port 520IP protocol 89 (raw IP)TCP port 179UpdatesEvery 30 s, full tableEvent-triggered LSAsIncremental updatesQUICK FACTSOSPF cost: 100 Mbps = 1, 10 Mbps = 10 · Areas join through Area 0 via ABRsRIP hold-down timer 180 s · BGP RFC 4271 · DR / BDR cut adjacencies O(n^2) to O(n)RIP: tell neighbors about everything · OSPF: tell everyone about neighborsVERIFIED★ Golden rule: IGP for inside an AS,BGP for between ASes.

Unicast Routing Protocols: RIP, OSPF, and BGP


1. Unicast Routing Concepts & Architecture

Routing is the process of selecting the best path across an internetwork to deliver a packet from source to destination.

The global Internet is structured as a collection of Autonomous Systems (AS):

  • Autonomous System (AS): A collection of connected routers and subnets under the administrative control of a single organization (such as an ISP, university, or enterprise) that presents a unified routing policy.
MermaidDiagram
Rendering diagram…

2. Distance Vector Routing: RIP

Distance Vector Routing is based on the classical Bellman-Ford Algorithm:

  • Philosophical Principle: "Each router tells its immediate neighbors about the entire world."
  • Routers periodically broadcast their entire routing table to their directly connected neighbors.

Routing Information Protocol (RIP):

  1. Metric: Hop Count (number of routers traversed).
    • Maximum allowed hop count = 15.
    • A hop count of 16 denotes infinity (network unreachable). This restricts RIP to small-to-medium networks.
  2. Periodic Updates: Broadcasts full routing table updates every 30 seconds over UDP Port 520.
  3. Slow Convergence & The Count-to-Infinity Problem:
    • If a link fails, routers may pass outdated routing information in a loop, incrementally incrementing the hop count up to 16 before discovering the link is down.
MermaidDiagram
Rendering diagram…

Solutions to Count-to-Infinity:

  • Split Horizon: A router never advertises a route back out the same interface through which it learned that route.
  • Poison Reverse: A router advertises unreachable routes back out the learned interface with a metric of 16 (infinity), actively "poisoning" the route.
  • Hold-down Timers: When a link fails, routers refuse updates for that destination for a cooldown period (e.g., 180 seconds).

3. Link-State Routing: OSPF

Link-State Routing is based on Dijkstra's Shortest Path First (SPF) Algorithm:

  • Philosophical Principle: "Each router tells the entire world about its immediate neighbors."

Open Shortest Path First (OSPF):

  1. Link State Advertisements (LSAs): Each router floods small LSA packets describing only the state and cost of its directly connected links.
  2. Link State Database (LSDB): Every router accumulates all LSAs, constructing an identical, complete mathematical topology graph of the entire network.
  3. Dijkstra's Algorithm: Each router runs Dijkstra's SPF algorithm independently, with itself as the root node, calculating the shortest path tree to all destination networks.
  4. Metric: Cost, inversely proportional to link bandwidth:
Cost=Reference Bandwidth (108 bps)Interface Bandwidth\text{Cost} = \frac{\text{Reference Bandwidth } (10^8\text{ bps})}{\text{Interface Bandwidth}}

(A 100 Mbps100\text{ Mbps} Fast Ethernet link has cost 1; a 10 Mbps10\text{ Mbps} link has cost 10).
5. Hierarchical Areas: Large OSPF networks are divided into Areas to contain LSA flooding. All secondary areas must connect to Area 0 (Backbone Area) via Area Border Routers (ABRs).
6. Designated Router (DR) & Backup DR (BDR): On shared multi-access networks (switched Ethernet), routers elect a DR and BDR to reduce adjacency mesh overhead from O(n2)O(n^2) to O(n)O(n).


4. Path-Vector Routing: BGP

Path-Vector Routing is the inter-domain protocol of the global Internet, implemented by BGP-4 (Border Gateway Protocol Version 4) (RFC 4271):

  • Exterior Gateway Protocol (EGP): Operates between distinct Autonomous Systems.
  • Runs over TCP Port 179: Provides reliable, connection-oriented session exchange without requiring periodic broadcast flooding.
  • Path Vector Concept: When BGP advertises a route to a destination network, it prepends its own Autonomous System Number (ASN) to the AS-Path Attribute:
MermaidDiagram
Rendering diagram…
  • Loop Prevention: If an AS receives a BGP advertisement containing its own ASN in the AS-Path list, it immediately discards the route, completely eliminating inter-domain routing loops!
  • Policy-Based Routing: Path selection is based on political, economic, and security business agreements rather than raw physical latency.

5. Comprehensive Comparison: RIP vs. OSPF vs. BGP

Feature RIP (v2) OSPF (v2/v3) BGP (BGP-4)
Type Distance Vector (IGP) Link-State (IGP) Path Vector (EGP)
Algorithm Bellman-Ford Dijkstra (SPF) Path Vector / Policy
Metric Hop Count (Max 15) Cost (∝1Bandwidth\propto \frac{1}{\text{Bandwidth}}) AS-Path & Policy Attributes
Scope Small, simple LANs Large enterprise campus / AS Global Internet Core
Convergence Slow (Count-to-infinity) Very Fast Moderate
Transport Protocol UDP Port 520 IP Protocol 89 (Raw IP) TCP Port 179
Update Mechanism Periodic (every 30s) Event-triggered LSAs Incremental event-triggered
Hierarchy Flat Areas (Area 0 Backbone) Autonomous Systems

Frequently Asked Questions

QWhy does RIP limit hop count to 15?

To prevent routing loops from circulating packets indefinitely. Hop count 16 is mathematically defined as "infinity" (unreachable), bounding the worst-case duration of the Count-to-Infinity problem.

QHow does OSPF prevent routing loops?

Every router possesses the complete identical topological map of the entire network (LSDB) and computes loop-free shortest paths using Dijkstra's SPF algorithm.

QHow does BGP detect and prevent routing loops?

By inspecting the AS-Path attribute. If a receiving BGP router detects its own Autonomous System Number already present in the advertised path sequence, it discards the advertisement.

QCompare the metrics used by RIP and OSPF.

RIP uses Hop Count (treats a 56 kbps56\text{ kbps} dial-up link the same as a 10 Gbps10\text{ Gbps} optical fiber link). OSPF uses Cost (inversely proportional to bandwidth), selecting faster, high-capacity physical links over slow links.

QWhat are Split Horizon and Poison Reverse?

Both fight count-to-infinity in distance-vector routing. Split Horizon never advertises a route back out the interface it was learned on. Poison Reverse advertises that route back with metric 16 (infinity) so neighbors mark it unreachable.

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.

← All Computer Networks modules