100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Python

Routing Protocols

Distinguish distance-vector, link-state, and path-vector routing protocols including RIP, OSPF, and BGP.

Network LayerAdvanced12 min readJul 8, 2026
Analogies

Introduction

Dynamic routing relies on routing protocols that let routers exchange information about network reachability and compute paths automatically. The three major families are distance-vector protocols, link-state protocols, and path-vector protocols, each with a different algorithm and use case.

🏏

Cricket analogy: Routing protocols are like different ways a team plans field placements automatically; some rely on quick word-of-mouth from nearby fielders (distance-vector), others map the entire ground before deciding (link-state), and international matches need agreements between boards about which routes players' visas take (path-vector).

Explanation

Distance-vector protocols, exemplified by RIP (Routing Information Protocol), have each router share its entire routing table with directly connected neighbors periodically. Routes are chosen using a simple metric, typically hop count (the number of routers a packet must pass through), and each router only knows the distance and direction (vector) to a destination, not the full topology — it trusts what its neighbors tell it, a model sometimes summarized as 'routing by rumor.' RIP limits hop count to 15 (16 is considered unreachable), which caps its usefulness to small networks. Link-state protocols, exemplified by OSPF (Open Shortest Path First), take a different approach: every router floods information about its directly connected links to all other routers in the area, so each router builds a complete map (link-state database) of the network topology. Each router then independently runs Dijkstra's shortest path first algorithm over that map to compute the best path to every destination. This gives faster convergence and better scalability than distance-vector protocols, at the cost of higher memory and CPU usage. Path-vector protocols, of which BGP (Border Gateway Protocol) is the standard example, are used between autonomous systems (large networks under independent administrative control, like ISPs) rather than within a single organization. BGP routes carry the full list (vector) of autonomous system numbers a route has traversed, which lets routers detect and avoid loops and apply rich policy-based decisions (such as preferring certain providers) rather than picking purely by a numeric distance metric.

🏏

Cricket analogy: RIP is like a fielder who only trusts what the nearest teammate shouts about where the ball went, capping useful advice at 15 relays before it's ignored as unreliable rumor. OSPF is like the whole team studying a complete video map of the ground before positioning, using Dijkstra-style shortest-path thinking. BGP is like international boards negotiating tour schedules based on political relationships, not just distance.

Example

python
# Conceptual comparison of routing protocol metrics/behavior
protocols = {
    "RIP": {"type": "distance-vector", "metric": "hop count", "max_hops": 15},
    "OSPF": {"type": "link-state", "metric": "cost (bandwidth-based)", "algorithm": "Dijkstra SPF"},
    "BGP": {"type": "path-vector", "scope": "between autonomous systems", "loop_prevention": "AS-path list"},
}

for name, info in protocols.items():
    print(name, "->", info)

# RIP -> {'type': 'distance-vector', 'metric': 'hop count', 'max_hops': 15}
# OSPF -> {'type': 'link-state', 'metric': 'cost (bandwidth-based)', 'algorithm': 'Dijkstra SPF'}
# BGP -> {'type': 'path-vector', 'scope': 'between autonomous systems', 'loop_prevention': 'AS-path list'}

Analysis

The three protocol families trade off simplicity, scalability, and control. RIP's simplicity (share your table, count hops) makes it easy to configure but slow to converge after a failure and blind to link quality — a low-hop path over a slow link looks 'better' than a higher-hop path over fast links. OSPF's full-topology, Dijkstra-based approach converges much faster and can factor in link cost/bandwidth, making it the standard interior gateway protocol (IGP) for medium-to-large enterprise and campus networks. BGP operates at an entirely different scale: it is the exterior gateway protocol (EGP) that glues the independently administered networks of the global internet together, and because different autonomous systems have different business relationships and policies, BGP's route selection is policy-driven (using attributes like AS-path length, local preference, and MED) rather than a simple shortest-path calculation, which is essential for representing real-world peering and transit agreements.

🏏

Cricket analogy: RIP's simplicity, just count hops, makes it easy but slow to adapt after a bowling change, like judging bowlers purely by over count rather than economy rate. OSPF's full-picture, shortest-path approach converges fast and factors in pitch conditions, making it ideal for a single team's domestic strategy. BGP operates at ICC scale, where routing decisions between boards are driven by political and commercial relationships, not pure distance.

Key Takeaways

  • Distance-vector (e.g., RIP) shares whole routing tables with neighbors and uses a simple metric like hop count.
  • Link-state (e.g., OSPF) floods link information so every router builds a full topology map and runs Dijkstra's algorithm.
  • Path-vector (e.g., BGP) is used between autonomous systems and tracks the AS-path for loop prevention and policy-based route selection.
  • OSPF converges faster and scales better than RIP; BGP is designed for internet-scale interconnection, not intra-network routing.

Practice what you learned

Was this page helpful?

Topics covered

#Python#ComputerNetworksStudyNotes#ComputerNetworks#RoutingProtocols#Routing#Protocols#Explanation#Example#StudyNotes#SkillVeris