Sub topic 15
RIP: Hop Count and Link-State Routing
Assume you know IPv4 prefixes, forwarding tables, and basic weighted graphs. RIP and OSPF are routing protocols: they help routers learn paths. Forwarding then uses the selected path to send each packet.
RIP and the infinity value of 16
RIP is a distance-vector routing protocol. Each router stores a distance, or metric, to each destination and periodically shares that table with its neighbors. RIP uses hop count as its metric. A directly connected network has distance 1, and every router crossed adds one hop.
RIP limits a usable route to 15 hops. A metric of 16 means infinity, or unreachable. This small limit prevents a routing table from representing very long paths, but it also restricts RIP to small networks.
| RIP metric | Meaning |
|---|---|
| 1 through 15 | Reachable destination |
| 16 | Unreachable destination |
A router applies the Bellman-Ford update rule:
new_distance = neighbor_distance + 1For each destination, it chooses the neighbor advertising the smallest distance. If router A reaches network X through B, and B reports distance 3, A records distance 4.
Count-to-infinity
Distance-vector routing can react badly when a route fails. Suppose A reaches X through B, while B reaches X through A. After X fails, A may believe B still has a route, and B may believe A still has one. Their reported distances increase repeatedly:
- A reports 2 to X.
- B reports 3.
- A reports 4.
- The values continue until they reach 16.
This is the count-to-infinity problem. Split horizon prevents a router from advertising a route back through the interface from which it learned that route. Poison reverse goes further: it advertises that route back with metric 16.
Link-state routing and Dijkstra's algorithm
A link-state router learns the complete topology of its routing area. Routers flood link-state advertisements, which describe their neighbors and link costs. After building the same topology map, each router runs Dijkstra's shortest-path algorithm with itself as the source.
Dijkstra repeatedly chooses the unvisited node with the smallest known distance, then relaxes its outgoing edges. For the graph above, A reaches D through A-B-C-D with cost 4, rather than the direct-looking path A-B-D with cost 6.
RIP distributes distance information and computes routes from neighbor reports. Link-state routing distributes topology information and computes routes locally. OSPF is a common link-state protocol. It normally uses configured link costs, not hop count, and supports areas to limit flooding.
Exercise
A RIP router receives routes to a network with metrics 7 and 12. Which route does it choose, and what does metric 16 mean?
Show answer
It chooses metric 7. Metric 16 means the destination is unreachable.