Sub topic 23
Comparing distance-vector, link-state and path-vector routing
This chapter assumes you have read the earlier chapters on forwarding versus routing, distance-vector routing with Bellman-Ford, link-state routing with Dijkstra, and the short sketches of RIP, OSPF and BGP. You should also be comfortable with weighted graphs. Here we put the three families side by side, so you can pick the right one for an exam question or a design decision.
The question each family answers
All three families fill the routing table that the forwarding plane then uses for longest-prefix match. They differ in what a router tells others and what it learns.
- Distance-vector: "Here is my distance to every destination." A router sends its distance table only to its direct neighbours. It never sees the whole map.
- Link-state: "Here are my links and their costs." A router floods this information to every router in its area. Each router builds the same map and runs Dijkstra on it.
- Path-vector: "Here is the full list of autonomous systems (AS) I would cross to reach this prefix." Each route carries its AS path, and the receiving router applies its own policy.
Side-by-side comparison
| Property | Distance-vector | Link-state | Path-vector |
|---|---|---|---|
| Example protocol | RIP | OSPF | BGP |
| Algorithm | Bellman-Ford | Dijkstra | Policy-based best-path selection |
| Information shared | Distance vector | Link costs (LSAs) | Prefix and AS path |
| Shared with | Neighbours | All routers in the area | Neighbouring ASes |
| Metric | Hop count, 16 means infinity | Cost, usually based on bandwidth | AS-path length, then policy attributes |
| Knowledge of topology | None beyond neighbours | Complete map of the area | AS-level only |
| Convergence | Slow after bad news | Fast | Can be slow in a large internet |
| Loop handling | Split horizon, poison reverse, small infinity | Loop-free if databases agree | Reject a route whose AS path contains your own AS |
| Scope | Small networks | Within one AS, split into areas | Between ASes |
Working model for each family
Distance-vector
A router computes D(x,y) = min over neighbours v of [c(x,v) + D(v,y)]. This repeated relaxation is the Bellman-Ford computation from the earlier chapter. Each router stores one entry per destination, which keeps memory small. The cost is that a router trusts what its neighbours say. If a link fails, the bad news spreads one exchange at a time. That is the root of count-to-infinity.
Link-state
Every router floods a link-state advertisement (LSA) when its links change. Every router then holds the same database and computes its own shortest-path tree. Because routers compute from the same data, they agree on the result, which makes loops short-lived. The costs are flooding traffic, memory for the whole database, and CPU time for Dijkstra. OSPF reduces these costs by splitting an AS into areas, so flooding stays inside an area.
Path-vector
A path vector is a distance vector with the full path attached. A BGP router checks the AS path before accepting a route. If its own AS number is already in the path, it discards the route, which prevents loops without needing a small infinity. The check looks like this:
def accept(my_as, as_path):
return my_as not in as_path
print(accept(65001, [65002, 65003]))
print(accept(65001, [65002, 65001, 65003]))This prints True and then False. BGP does not pick the cheapest path in any metric. It first applies local policy, such as preferring a customer link over a provider link, and only then compares AS-path length.
Failure modes and common errors
- Count-to-infinity belongs to distance-vector only. Split horizon stops a router advertising a route back to the neighbour it learned it from. Poison reverse advertises that route back with an infinite metric. Neither fully prevents loops that span three or more routers.
- Stale or inconsistent databases affect link-state. If two routers hold different maps for a moment, they can briefly forward packets in a loop. Sequence numbers on LSAs make the newest one win.
- Policy conflicts affect path-vector. Because BGP follows business policy, the best route for your provider may not be the shortest, and misconfiguration can leak or hijack routes.
- A frequent exam mistake is to say OSPF "sends its routing table to neighbours". It sends link-state information to all routers in the area. Another mistake is to say RIP knows the network topology. It does not.
Choosing between them
- Use distance-vector only for small, simple networks where low configuration effort matters more than fast convergence.
- Use link-state inside a larger organisation that needs fast convergence and cost-based paths, and use areas to keep it scalable.
- Use path-vector between independent organisations, because it lets each AS hide its internal structure and enforce its own policy.
In practice, a network runs an interior protocol such as OSPF inside each AS and BGP between ASes.
Exercise
A router in AS 100 receives a BGP route to a prefix with the AS path 200, 300, 100, 400. Should it accept the route? Which property of path-vector routing does this show, and why does RIP need a different mechanism to avoid the same problem?
Show answer
It should reject the route, because its own AS number 100 already appears in the path, so accepting it would create a loop. This shows that path-vector routing detects loops directly from the recorded path. RIP carries only a hop count, so it has no record of the route's path. It relies on split horizon, poison reverse and a small infinity of 16 to limit loops.
Exercise
A network has 50 routers. Name one reason link-state routing uses more memory per router than distance-vector, and one reason it recovers faster from a link failure.
Show answer
Each link-state router stores the complete topology database, while a distance-vector router stores only one entry per destination. After a failure, the router next to the failed link floods an LSA immediately, and every router recomputes its shortest paths from the same updated map. Distance-vector information moves only one neighbour at a time.