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.
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):
- 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.
- Periodic Updates: Broadcasts full routing table updates every 30 seconds over UDP Port 520.
- 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.
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):
- Link State Advertisements (LSAs): Each router floods small LSA packets describing only the state and cost of its directly connected links.
- Link State Database (LSDB): Every router accumulates all LSAs, constructing an identical, complete mathematical topology graph of the entire network.
- 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.
- Metric: Cost, inversely proportional to link bandwidth:
(A Fast Ethernet link has cost 1; a 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 to .
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:
- 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 () | 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 dial-up link the same as a 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.