The idea: two ways to learn routes
Every router needs a table: for each destination, which neighbour gets the packet next. A routing protocol fills that table in and keeps it right when links fail. There are two big families. In distance vector (RIP), a router only hears from its neighbours: "I can reach D at cost 2". In link state (OSPF, IS-IS), every router learns the whole map and works out the routes itself. The page runs both on the same four routers, round by round, so you can see where they differ.
Distance vector: rumours from neighbours
Each router keeps a distance vector: its cost to every destination. In each round it sends the whole vector to every neighbour. A router that hears "B: D = 2" over a link of cost 1 knows it can reach D at 3 through B. It keeps the cheapest offer for each destination. This is the Bellman-Ford update, run by many routers at once:
cost(me, d) = min over neighbours n of ( link(me, n) + cost(n, d) as n last told me )
RIP sends its table every 30 seconds (and at once when something changes, a triggered update), uses hop count as the cost, and calls 16 infinity: unreachable. On the canvas one round stands for one such exchange. (Demo 1: cold start) shows routes spreading one hop further each round.
Link state: everyone gets the map
Each router describes only itself: its links and their costs, in a link-state advertisement (LSA) with a
sequence number. It floods the LSA: every router that gets a newer one stores it in its link-state
database (LSDB) and passes it on to its other neighbours. Soon every router has the same LSDB, the whole map, and
runs Dijkstra (OSPF calls it SPF, shortest path first) on it. The LSDB row under each table shows which
LSAs a router holds: C2 is C's LSA with sequence number 2.
A router uses a link only if both ends' LSAs list it (the two-way check). When C–D fails, D's old LSA still says "I am linked to C", but C's new LSA does not, so nobody routes over it. Link state is not loop-free either: for the one round before B gets C's new LSA, B still sends D's packets to C and C sends them back (a short microloop, marked purple). It ends as soon as the flood arrives.
Count-to-infinity
Take the ring A–B–C–D with a backup link D–A of cost 6. C reaches D directly; B goes through C at cost 2. Now C–D fails. C has lost its route, but it still holds B's last vector, "D = 2". C does not know that B's route goes through C itself, so it believes it: D = 3 via B. Next round B hears "D = 3" from C and moves to 4. C hears 4 and moves to 5. The two routers bounce a dead route back and forth, each round adding 2, until the cost passes the real backup path (D–A: 6 from A, 7 from B, 8 from C). (Demo 2) While it lasts, packets for D loop between B and C until their TTL runs out.
If there is no backup at all, the counting goes on to infinity. When router D crashes (Demo 4), A, B and C count 3, 5, 7 … up to 16 before they agree D is gone: 14 rounds, about seven minutes of RIP updates. That is why RIP's infinity is as small as 16, and why RIP is only used in small networks.
Split horizon and poisoned reverse
The fix for the two-router echo: split horizon, never tell a neighbour about a route you learned from that neighbour. With poisoned reverse you do tell it, but with cost 16, so it drops the route at once. B learned D from C, so it tells C "D = 16"; when C–D fails, C has nothing stale to believe. With split horizon on, the crash of D is settled in 2 rounds instead of 14 (Demo 5).
Split horizon only breaks loops of two routers. In a loop of three (A tells B, B tells C, C tells A), each router hears the stale route from a neighbour it did not learn it from, and the counting comes back. RIP adds hold-down timers for that; EIGRP replaces the whole rule with feasibility checks.
Side by side
| Distance vector (RIP) | Link state (OSPF) | |
|---|---|---|
| What is sent | The whole table: my cost to every destination | Only my own links (an LSA) |
| To whom | Neighbours only | Flooded to every router in the area |
| When | Every 30 s, plus triggered updates | On a change, plus a refresh every 30 min |
| What a router knows | Next hop and cost, not the path | The whole map (LSDB) |
| Algorithm | Bellman-Ford, spread over the routers | Dijkstra, run in every router |
| After a failure | Slow; can count to infinity (16) | As fast as the flood + SPF |
| Cost | Little memory and CPU | LSDB memory, SPF CPU; areas to scale |
Good news travels fast in both: when C–D comes back, the cheaper route spreads one hop per round (Demo 6). It is only bad news that distance vector learns slowly. The same split runs through the shortest-path algorithms themselves: see Dijkstra vs Bellman-Ford, and How a Router Forwards a Packet for what the finished table is used for.
What the page leaves out
Real RIP keeps timers per route (180 s timeout, 120 s garbage collection, hold-down) and sends updates out of step; here every router sends in lockstep rounds. OSPF forms adjacencies with Hello and Database Description packets, acknowledges every LSA, ages LSAs out after an hour (MaxAge), elects a designated router on shared LANs, splits big networks into areas and waits a little (SPF throttling) before rerunning Dijkstra. Destinations are routers here, not IP prefixes. Path-vector protocols like BGP, which send the whole path to stop loops, are left out.