Distance Vector Routing is a foundational algorithm in computer networking, and the Routing Information Protocol (RIP) is one of its most well-known implementations. This article explains how distance vector routing works, using a simple example to illustrate how routers exchange routing tables and calculate the shortest path based on hop count.
How Distance Vector Routing Works
In distance vector routing, each router maintains a routing table that lists the known destinations and the distance (in hops) to reach them. Routers periodically share their entire routing table with directly connected neighbors. Upon receiving a neighbor's table, a router updates its own table if it finds a shorter path to any destination.
The algorithm is based on the Bellman-Ford equation: if router A knows its distance to B, and B knows its distance to C, then A can compute a path to C by adding those distances. Over time, all routers converge to consistent, optimal routes.
Example: A Simple Network
Consider a network with four routers: A, B, C, and D. Initially, each router knows only itself (distance 0) and its direct neighbors (distance 1). For example:
- A knows: A (0), B (1), C (1)
- B knows: B (0), A (1), D (1)
- C knows: C (0), A (1), D (1)
- D knows: D (0), B (1), C (1)
When neighbors exchange tables:
- A receives B's table and learns that D is reachable via B with total distance 2 (1 hop to B + 1 hop from B to D). Since A does not yet know D, it adds this route.
- Similarly, A learns from C that D is reachable via C with distance 2. Both routes are equal, so A may keep both or choose one.
- After another exchange, all routers have complete information about the network, and the routing tables converge.
RIP Details
RIP is a distance vector protocol that uses hop count as its metric. The maximum hop count is 15; destinations beyond that are considered unreachable. RIP routers broadcast their routing table every 30 seconds to maintain up-to-date routes.
Avoiding Routing Loops
Distance vector protocols are prone to routing loops, which occur when routers incorrectly believe a path exists through each other. RIP employs several countermeasures:
- Split Horizon: A router never advertises a route back out the interface from which it learned that route.
- Route Poisoning: When a link fails, the router advertises the failed route with an infinite metric (16 hops), signaling unreachability.
- Triggered Updates: Instead of waiting for the periodic update, routers send updates immediately upon detecting a topology change.
- Hold-Down Timers: After receiving a poisoned route, routers wait a certain time before accepting new information about that destination, preventing flapping.
Advantages and Disadvantages
Advantages: Simple to implement and configure; works well in small networks (fewer than 15 hops).
Disadvantages: Slow convergence; limited scalability due to hop count restriction; susceptible to loops without additional mechanisms.
Distance vector routing and RIP remain important for understanding network fundamentals, especially in CCNA and computer networking curricula.