Sub topic 10
RIP in practice
This chapter covers how the Routing Information Protocol (RIP) behaves on real routers. It assumes you know the Bellman-Ford update, count to infinity, and split horizon with poison reverse from the earlier chapters. It also assumes you can read a routing table and a subnet mask.
What RIP is
RIP is the simplest distance-vector protocol still in use. Every router periodically sends its routing table to its neighbors. Each neighbor applies the Bellman-Ford rule from the earlier chapter and keeps the cheapest route it hears.
RIP uses three main design choices:
- Metric: hop count. Each router crossing adds 1. Link speed and delay are ignored.
- Infinity: 16. A metric of 16 means "unreachable", so the longest usable path is 15 hops. This bound is how RIP limits count to infinity.
- Transport: UDP port 520 (RIPng for IPv6 uses port 521).
The hop-count metric has a practical cost. A path over one 56 kbit/s link beats a path over two gigabit links, because 1 hop is less than 2.
RIP versions
| Property | RIPv1 | RIPv2 | RIPng |
|---|---|---|---|
| Address family | IPv4 | IPv4 | IPv6 |
| Subnet mask in updates | No (classful) | Yes | Prefix length |
| Delivery | Broadcast | Multicast 224.0.0.9 | Multicast ff02::9 |
| Authentication | None | Plain text or MD5 | Relies on IPsec |
| Explicit next hop | No | Yes | Yes |
RIPv1 sends no masks. It therefore cannot carry variable-length subnets or discontiguous networks. Use RIPv2 for any new IPv4 deployment.
Message format and limits
A RIP message has a 4-byte header, followed by up to 25 route entries of 20 bytes each. The maximum payload is 504 bytes, which fits in 512. A router with 1,000 routes needs at least 40 messages per full update. This cost is one reason RIP does not scale.
Each entry carries a destination prefix, a metric, and, in RIPv2, a subnet mask, a route tag, and an optional next hop.
Timers
RIP depends on timers. The usual defaults are:
- Update timer, 30 seconds. The router sends its full table, with a small random jitter to avoid synchronized bursts.
- Invalid timer, 180 seconds. If no update refreshes a route in this time, the router marks it unreachable with metric 16.
- Flush timer, 240 seconds. The router removes the route from the table.
- Hold-down timer, 180 seconds. This is a Cisco extension. After a route becomes unreachable, the router ignores worse news about it for a while.
A silent neighbor failure can take 180 seconds to notice. Real convergence is slower than any hop-count argument suggests. Two mechanisms speed it up:
- Triggered updates. When a metric changes, the router sends the change immediately instead of waiting for the next 30-second tick. RFC 2453 asks for a random delay of 1 to 5 seconds, so that many routers do not flood the network at once.
- Route poisoning. When a route fails, the router advertises it with metric 16 right away.
Two loop-prevention techniques also apply here. Split horizon with poison reverse is the default on most platforms. The maximum metric of 16 puts a ceiling on any count to infinity that still occurs.
A small simulation
The code below reuses the update and advertisement functions from this tutorial. It runs three routers in a line, A–B–C, with every link costing 1. Poison reverse is on.
INFINITY = 16
def dv_update(me, link_cost, table, neighbor, advertised):
changed = False
for dest, adv in advertised.items():
if dest == me:
continue
new = min(link_cost + adv, INFINITY)
cur = table.get(dest)
if cur is None:
if new < INFINITY:
table[dest] = (new, neighbor)
changed = True
elif new < cur[0] or cur[1] == neighbor:
if (new, neighbor) != cur:
table[dest] = (new, neighbor)
changed = True
return changed
def advertise_to(me, neighbor, table, poison_reverse=True):
out = {me: 0}
for dest, (cost, next_hop) in table.items():
if next_hop == neighbor:
if poison_reverse:
out[dest] = INFINITY
else:
out[dest] = cost
return out
links = {"A": ["B"], "B": ["A", "C"], "C": ["B"]}
tables = {name: {} for name in links}
for round_no in range(2):
for me in links:
for nbr in links[me]:
adv = advertise_to(nbr, me, tables[nbr])
dv_update(me, 1, tables[me], nbr, adv)
for name in sorted(tables):
print(name, sorted(tables[name].items()))After two rounds the output is:
A [('B', (1, 'B')), ('C', (2, 'B'))]
B [('A', (1, 'A')), ('C', (1, 'C'))]
C [('A', (2, 'B')), ('B', (1, 'B'))]A reaches C in 2 hops through B, and C reaches A the same way. In a line of routers, information needs about as many rounds as the network diameter. Each round is up to 30 seconds in real RIP.
Configuring RIPv2
This is a minimal Cisco IOS-style configuration:
router rip
version 2
network 10.0.0.0
no auto-summaryversion 2selects RIPv2 behavior.network 10.0.0.0enables RIP on every interface whose address falls in that classful network. RIP then sends and receives updates there and advertises the connected subnet.no auto-summarystops the router from summarizing subnets to their classful boundary. Without it, a router can advertise10.0.0.0/8toward another network, which breaks discontiguous subnets.
Useful checks are show ip protocols for timers and enabled interfaces, and show ip route rip for learned routes. RIP routes appear with code R and, on Cisco, an administrative distance of 120. A route from OSPF (distance 110) wins over a RIP route to the same prefix.
Common errors
- Version mismatch. A router set to RIPv1 and a neighbor on RIPv2 may ignore or misread each other's updates, so routes never appear.
- Left auto-summary on. Two sites that share a classful network, such as 10.1.0.0/24 and 10.2.0.0/24 on opposite sides of 172.16.0.0, can black-hole traffic.
- Paths over 15 hops. Destinations beyond that distance are unreachable, even if the topology is valid.
- Slow failover assumptions. Counting on sub-second recovery with default timers is a mistake. Detecting a silent failure takes up to 180 seconds.
- Equal hop counts, unequal links. RIP may load-share across a fast and a slow path because both are the same number of hops.
When RIP is still the right choice
RIP fits very small networks of a few routers, lab setups, and devices with limited CPU or memory where the configuration is a few lines. Its low overhead and simplicity also make it easy to debug. Beyond roughly a dozen routers, or when links differ widely in speed, link-state protocols such as OSPF become a better fit. They are covered in later chapters.
Exercise
A RIPv2 router stops hearing updates from a neighbor at time 0. Using the default timers, when does it mark the neighbor's routes unreachable, and when does it remove them? What would speed up the other routers learning about the failure once the first router notices?
Show answer
It marks the routes invalid, with metric 16, at 180 seconds. It removes them at 240 seconds. Once the router has marked them unreachable, triggered updates let it advertise the metric-16 route immediately instead of waiting for the next 30-second update. Neighbors then update their own tables sooner.