Sub topic 8
Distance-vector protocols and RIP
This chapter assumes you know IPv4 addressing and CIDR prefixes, the difference between a router and a host, and basic router or Linux command-line use. You should also have read the earlier chapters on dynamic routing, convergence and metrics.
The working model
A distance-vector protocol is a routing protocol in which each router tells its neighbors what destinations it can reach and how far away they are. "Distance" is the metric. "Vector" is the direction, meaning the next-hop neighbor that advertised the route.
A router does not know the whole network map. It only knows what its neighbors claim. This is often called "routing by rumor".
Each router does three things:
- It starts with its directly connected networks at distance 0.
- It sends its table to its neighbors at regular intervals.
- When it hears a route from a neighbor, it adds the cost of the link to that neighbor. It keeps the route if it is new or cheaper than the one it has.
RIP
RIP (Routing Information Protocol) is the classic distance-vector protocol. Its main properties:
| Property | RIP value |
|---|---|
| Metric | Hop count |
| Maximum usable metric | 15 hops |
| Unreachable | Metric 16 |
| Update interval | Full table every 30 seconds |
| Administrative distance (Cisco) | 120 |
| Transport | UDP port 520 (RIPv1 and RIPv2) |
RIPv1 is classful and does not send subnet masks. RIPv2 sends masks, so it supports CIDR and variable-length subnets. It also multicasts to 224.0.0.9. Use RIPv2 if you use RIP at all.
Hop count ignores bandwidth. A path through one slow link beats a path through two fast links. The 15-hop limit also caps the size of the network.
Here is a basic RIPv2 configuration on Cisco IOS:
router rip
version 2
no auto-summary
network 10.1.0.0
network 192.168.1.0The network statements choose which interfaces send and receive RIP updates, and which connected networks are advertised. Use no auto-summary so RIP keeps your CIDR prefixes instead of summarizing to classful boundaries.
Failure handling and its problems
Distance-vector convergence is slow because news travels one neighbor at a time. If a route disappears, routers may keep advertising it to each other and slowly increase the metric. This is the count-to-infinity problem. RIP stops it at 16, which is why 16 means unreachable.
RIP uses several mechanisms to reduce the damage:
- Split horizon: a router does not advertise a route back out the interface it learned it from.
- Route poisoning: a failed route is advertised with metric 16 so neighbors drop it quickly.
- Poison reverse: a router advertises a route back toward its source with metric 16.
- Hold-down timers: after a route is reported as bad, a router ignores worse news about it for a period.
- Triggered updates: a router sends a change immediately instead of waiting for the 30-second timer.
Verifying RIP
show ip protocols
show ip route rip
show ip rip databaseRIP routes appear in the routing table with the code R and a value like [120/2]. The first number is the administrative distance. The second is the hop count.
Common errors
- Mismatched versions. A RIPv1 router and a RIPv2 router may not agree on masks.
- Missing
no auto-summary. Discontiguous subnets become unreachable or ambiguous. - Wrong
networkstatement. The interface does not send or receive updates. - Passive interface by mistake. A passive interface listens but does not send updates.
- Paths longer than 15 hops. Routes beyond that limit are treated as unreachable.
Exercise
Router A hears 10.3.0.0/16 from Router B with metric 2. It already has a RIP route to that prefix through Router C with metric 4. Which route does A install, and what metric does it show?
Show answer
A installs the route through B. The advertised metric is 2, and A adds 1 for the link to B, so the table shows metric 3. This is lower than the 4 it had through C.
Exercise
Why does RIP set a maximum of 15 hops, and what does metric 16 mean?
Show answer
The limit stops count-to-infinity from running forever, because a looping route reaches 16 and is dropped. Metric 16 means the destination is unreachable.