Free lesson · Computer Networking
Distance Vector Routing Rip
The First Dynamic Routing Protocol
Before dynamic routing protocols existed, every route on every router was configured manually. If a network had 50 routers and 200 subnets, an administrator had to manually enter hundreds of routes - and manually update them whenever the topology changed. This was manageable when networks were small, but as the internet grew in the 1980s, the operational burden became impossible. The networking community needed a protocol that would let routers discover routes automatically.
RIP (Routing Information Protocol) was one of the earliest answers to this problem. Standardized in RFC 1058 (1988), RIP is a distance vector routing protocol that uses the Bellman-Ford algorithm to compute shortest paths. Each router knows the distance (measured in hop count) to each destination network and shares this information with its directly connected neighbors. Through iterative exchanges, every router eventually learns the best path to every destination - without any router having a complete picture of the network topology.
RIP is largely historical today. Modern networks use OSPF, IS-IS, or BGP instead, because RIP's limitations - slow convergence, a maximum of 15 hops, and susceptibility to routing loops - make it unsuitable for networks of any significant size. However, understanding RIP is essential because it illustrates the fundamental principles of distance vector routing, including the convergence problems that motivated the development of more sophisticated protocols.
How Distance Vector Routing Works
The name "distance vector" describes exactly what each router knows: the distance (metric) to each destination, and the vector (direction - which next-hop router to use). A router does not know the complete path to a destination. It only knows "to reach network X, send traffic to neighbor Y, and the total cost is Z hops."
The Algorithm
Each router maintains a routing table with three columns for each known destination: the destination network, the next-hop router, and the hop count (distance). The algorithm proceeds through iterative exchanges:
Step 1 - Initialize. Each router starts knowing only about the networks directly connected to its own interfaces. These entries have a hop count of 0 (directly connected) or 1 depending on the implementation.
Step 2 - Share. Periodically (every 30 seconds in RIP), each router broadcasts its entire routing table to all directly connected neighbors. This is called a routing update.
Step 3 - Update. When a router receives a routing update from a neighbor, it examines each entry. For each destination in the neighbor's table, the router calculates: "If I go through this neighbor, the total distance is the neighbor's distance + 1 hop (to reach the neighbor)." If this calculated distance is shorter than the current best distance in the router's own table, the router updates its entry with the new shorter path. If the destination is unknown, the router adds it.
Step 4 - Repeat. The process repeats every 30 seconds. Over multiple iterations, routing information propagates across the entire network. After enough iterations, every router has learned the shortest path to every destination - the network has converged.
graph LR
subgraph Network["Three-Router Network"]
A["Router A<br/>Connected to<br/>10.0.1.0/24"] --- B["Router B<br/>Connected to<br/>10.0.2.0/24"]
B --- C["Router C<br/>Connected to<br/>10.0.3.0/24"]
end
style A fill:#4f46e5,stroke:#4338ca,color:#fff
style B fill:#7c3aed,stroke:#6d28d9,color:#fff
style C fill:#8b5cf6,stroke:#7c3aed,color:#fff
This diagram shows a simple three-router network. Router A is connected to network 10.0.1.0/24. Router B is in the middle, connected to network 10.0.2.0/24. Router C is connected to network 10.0.3.0/24. Router A connects to Router B, and Router B connects to Router C. There is no direct link between Router A and Router C.
Convergence Example
Consider the three-router network above. Initially, each router knows only its directly connected networks:
| Router A's Table | Destination | Next Hop | Hops |
|---|---|---|---|
| 10.0.1.0/24 | direct | 0 |
| Router B's Table | Destination | Next Hop | Hops |
|---|---|---|---|
| 10.0.2.0/24 | direct | 0 |
| Router C's Table | Destination | Next Hop | Hops |
|---|---|---|---|
| 10.0.3.0/24 | direct | 0 |
After the first exchange (30 seconds):
- Router A sends its table to B. B learns: "10.0.1.0/24 is 1 hop away via A."
- Router C sends its table to B. B learns: "10.0.3.0/24 is 1 hop away via C."
- Router B sends its table to A and C. A learns: "10.0.2.0/24 is 1 hop via B." C learns: "10.0.2.0/24 is 1 hop via B."
After the second exchange (60 seconds):
- B now knows about 10.0.1.0/24 and 10.0.3.0/24. It shares these with A and C.
- A learns: "10.0.3.0/24 is 2 hops away via B" (B's 1 hop + 1 hop to reach B).
- C learns: "10.0.1.0/24 is 2 hops away via B."
The network has converged. Every router knows how to reach every network. Router A can now send traffic to 10.0.3.0/24 by sending it to B, which forwards it to C.
RIP Specifics
RIP implements the distance vector algorithm with these specific parameters:
Metric: Hop count. The distance to any destination is simply the number of routers between the source and the destination. A directly connected network is 0 hops. A network one router away is 1 hop. RIP's hop count metric is the simplest possible metric - and also the crudest. It treats a 100 Gbps fiber link and a 1 Mbps satellite link as equivalent (both are "1 hop"), which can lead to highly suboptimal path selection.
Maximum distance: 15 hops. Any destination more than 15 hops away is considered unreachable. A hop count of 16 is used as "infinity" - representing an unreachable destination. This limits RIP to small networks. A network spanning more than 15 routers in any path cannot use RIP.
Update interval: 30 seconds. Every 30 seconds, each router broadcasts its entire routing table to all neighbors. This means that in the worst case, a topology change takes multiple 30-second cycles to propagate across the network - convergence can take several minutes for large RIP networks. For a network spanning 10 hops, convergence after a failure could take 5+ minutes as the information propagates one hop per update cycle.
Timeout and garbage collection. If a router does not receive an update for a route within 180 seconds (6 missed updates), it marks the route as unreachable. After an additional 120 seconds (the garbage-collection timer), it removes the route from the table entirely. These long timers contribute to RIP's slow response to failures - a downed router's routes linger in neighboring routers' tables for minutes before being purged.
Full-table broadcasts. Every update includes the router's entire routing table, regardless of whether anything changed since the last update. In a network with 200 known routes, each router sends all 200 entries every 30 seconds to every neighbor. This wastes bandwidth and CPU compared to protocols like OSPF that send updates only when something changes.
RIP versions: RIPv1 (RFC 1058) uses broadcast and does not support CIDR (it sends classful network addresses without subnet masks). RIPv2 (RFC 2453) adds multicast (using 224.0.0.9 instead of broadcast), CIDR support with subnet mask information in each update, and simple password authentication. Only RIPv2 is relevant today where RIP is used at all. RIPng extends the protocol for IPv6 networks.
The Count-to-Infinity Problem
The most famous flaw in distance vector routing is the count-to-infinity problem - a situation where a network failure causes routing loops and extremely slow convergence as routers gradually increment the hop count toward infinity (16 in RIP's case).
How It Happens
Consider routers A and B connected to each other. Network X is connected to A with a hop count of 1. B learns about X through A with a hop count of 2.
Now suppose the link between A and network X fails. A detects the failure and marks X as unreachable (hop count 16). But before A can broadcast this update, B sends its regular 30-second update to A. B's update says: "I can reach X with hop count 2."
A receives this and thinks: "I can't reach X directly anymore, but B says it can reach X in 2 hops. If I go through B, I can reach X in 3 hops." A updates its table: X via B, hop count 3.
In the next exchange, A tells B: "I can reach X in 3 hops." B updates: "I can reach X via A in 4 hops." Then B tells A: "4 hops." A updates: "5 hops." This continues - the hop count slowly increments toward 16 (infinity) - while both routers are sending traffic for X in a loop between themselves. This is the count-to-infinity problem: a routing loop where the metric gradually increases until it reaches the unreachable threshold.
Mitigations
RIP implements several mechanisms to reduce (but not eliminate) the count-to-infinity problem:
Split horizon: A router does not advertise a route back to the neighbor it learned the route from. If B learned about X from A, B does not include X in its updates to A. This prevents the simple two-router loop described above.
Split horizon with poison reverse: Instead of simply omitting the route, the router explicitly advertises it back with a metric of 16 (unreachable). This is more aggressive than split horizon and speeds up convergence by immediately telling the neighbor "do not use me to reach this destination."
Triggered updates: Instead of waiting for the next 30-second periodic update, a router immediately sends an update when it detects a topology change. This reduces the window during which stale information can cause loops.
Hold-down timers: After a route becomes unreachable, the router ignores any new information about that route for a hold-down period (typically 180 seconds in RIP). This prevents the router from accepting stale information from slow-converging neighbors.
Even with all these mitigations, RIP's convergence remains slow compared to link-state protocols. In a large RIP network with 10+ routers, convergence after a failure can take several minutes - during which time some traffic is being looped and dropped. This fundamental limitation is the primary reason RIP was replaced by OSPF and IS-IS in production networks.
sequenceDiagram
participant A as Router A
participant B as Router B
Note over A: Connected to Net X<br/>X = 1 hop
Note over B: Learned from A:<br/>X = 2 hops via A
Note over A: Link to X fails!<br/>X = unreachable (16)
B->>A: Update: "X = 2 hops"<br/>(stale info, sent before<br/>learning about failure)
Note over A: "B can reach X in 2?<br/>Then I can reach it in 3!"<br/>X = 3 hops via B
A->>B: Update: "X = 3 hops"
Note over B: "A says 3... I'll update<br/>to 4 hops via A"
B->>A: Update: "X = 4 hops"
Note over A: Updates to 5 hops
Note over A,B: Continues incrementing...<br/>4→5→6→7→...→16<br/>Traffic loops between A and B<br/>until both reach 16 (infinity)
This sequence diagram illustrates the count-to-infinity problem. Router A is connected to Network X at 1 hop. Router B learned about X from A at 2 hops. When the link between A and X fails, A marks X as unreachable. But before A's update reaches B, B sends A an update saying X is 2 hops away. A mistakenly believes it can reach X through B in 3 hops. A tells B 3 hops, B updates to 4, tells A 4, A updates to 5 - this loop continues with the hop count incrementing by 1 each cycle until both routers reach 16, the infinity value, and finally declare X unreachable. During this entire process, traffic for X loops between the two routers and is dropped.
Why RIP Still Matters to Learn
RIP is rarely deployed in new networks. But understanding it serves several purposes:
It teaches the Bellman-Ford algorithm in a practical context. If you have studied algorithms, you know Bellman-Ford as a shortest-path algorithm. RIP is Bellman-Ford running in a distributed system - each router independently executing the algorithm with information from its neighbors. This connection between algorithm theory and real-world networking is valuable for interview preparation, particularly for candidates who need to demonstrate understanding of how theoretical algorithms manifest in production systems.
It explains why OSPF exists. OSPF was designed specifically to solve RIP's problems: slow convergence, routing loops, and the crude hop-count metric. Understanding RIP's limitations makes OSPF's design decisions comprehensible rather than arbitrary. You appreciate why OSPF uses link-state advertisements instead of distance vectors, why it runs Dijkstra instead of Bellman-Ford, and why it converges in seconds instead of minutes.
It provides vocabulary for understanding BGP. BGP is a path vector protocol - an evolution of the distance vector concept. BGP's loop prevention mechanism (rejecting paths containing your own AS number) is a sophisticated solution to the same loop problem that plagued RIP. Understanding RIP's count-to-infinity problem helps you understand why BGP was designed the way it was.
Interview: RIP itself is unlikely to appear in interviews, but distance vector concepts do:
"What is the count-to-infinity problem?" - A routing loop in distance vector protocols where two routers keep incrementing the hop count toward infinity after a link failure, because each believes the other has a valid path. It causes traffic to loop and takes a long time to resolve.
"Why do modern networks prefer OSPF over RIP?" - Three reasons: OSPF converges faster (seconds vs minutes), OSPF uses a bandwidth-based metric (more intelligent than hop count), and OSPF builds a complete topology map (preventing the routing loops that plague distance vector protocols). RIP's 15-hop limit also makes it unsuitable for large networks.
"How does the Bellman-Ford algorithm relate to networking?" - It is the algorithmic foundation of distance vector routing. Each router runs a distributed version of Bellman-Ford, updating its distance estimates based on information from neighbors.
What Comes Next
The next topic covers OSPF (Open Shortest Path First) - the link-state routing protocol that replaced RIP in most networks. OSPF builds a complete map of the network topology and runs Dijkstra's algorithm to compute shortest paths, solving the convergence and loop problems that limited RIP.
Exercise: Starter: Given a four-router linear network (A—B—C—D), where each router connects to one local network, trace the convergence of RIP step by step. How many 30-second update cycles does it take for Router A to learn about Router D's network? What is the hop count of that learned route?
Intermediate: Simulate the count-to-infinity problem on paper. In the four-router network above, suppose the link between C and D fails. Trace what happens at each update cycle. At which cycle does A's entry for D's network reach infinity (16)? Does split horizon help? Does split horizon with poison reverse help? Work through both scenarios and compare convergence times.
Advanced: Research EIGRP (Enhanced Interior Gateway Routing Protocol), Cisco's proprietary improvement on distance vector routing. How does EIGRP's DUAL (Diffusing Update Algorithm) solve the count-to-infinity problem without requiring a complete topology map? How does EIGRP's composite metric (bandwidth + delay) improve on RIP's hop count? Why, despite being technically superior to RIP, has EIGRP not replaced OSPF as the dominant interior routing protocol? (Hint: consider the implications of vendor lock-in.)