Sub topic 11
Link-state routing: everyone holds the map
This chapter assumes you know basic IP addressing, the difference between a router and a switch, how longest-prefix match picks a route, and basic graph terms such as nodes, edges, and weights.
The core idea
A distance-vector router only knows what its neighbors tell it about distances. A link-state router works differently. Each router describes its own links and shares that description with every other router in the area. Every router then holds the same map of the network and computes its own routes from it.
The model has three steps:
- Each router discovers its directly connected neighbors and the cost of each link.
- Each router floods a record of those links to all other routers.
- Each router runs a shortest-path algorithm on the combined map and installs the results in its routing table.
Because every router starts from the same data, the results agree. The routers do not trade computed routes. They trade facts about links.
What a router advertises
A router's advertisement lists its own links: the neighbor on the other end and the cost. It does not list routes learned from others. A small example:
| Router | Advertised links (neighbor: cost) |
|---|---|
| A | B: 1, C: 4 |
| B | A: 1, C: 2 |
| C | A: 4, B: 2 |
Once every router holds these three records, each can draw the same triangle and compute paths. From A, the path to C through B costs 3. That beats the direct link at cost 4, so A uses B as the next hop for C.
Computing routes locally
The shortest-path computation is Dijkstra's algorithm, often called SPF (shortest path first). The router puts itself at the root of a tree and grows it toward the cheapest unreached node. For forwarding, it keeps the first hop on each path. Later chapters cover the algorithm and its code in detail.
Why this differs from distance-vector
| Property | Distance-vector | Link-state |
|---|---|---|
| What is shared | Distances to destinations | Link descriptions |
| Who shares with whom | Neighbors only | Flooded to all routers in the area |
| View of the network | Next hop and cost only | Full topology |
| Route computation | Incremental Bellman-Ford | Dijkstra on the whole map |
Having the full topology is the main benefit. A router cannot be misled by a rumor, because it sees the actual links. This is why link-state protocols avoid count to infinity.
Common errors
- Databases that disagree. If two routers hold different maps, they can compute routes that loop. Reliable flooding and sequence numbers exist to keep the maps identical.
- Unstable links. A link that goes up and down repeatedly triggers floods and SPF runs across the whole area. Implementations add timers to throttle this.
- Thinking routers exchange routes. They exchange link records. Each router derives the routes itself.
Exercise
Routers A, B, and C have these links: A-B cost 2, B-C cost 2, A-C cost 5. After flooding, what is A's cost to C and which next hop does it use?
Show answer
The cost is 4, using B as the next hop. The path A-B-C costs 2 + 2 = 4, which is less than the direct A-C link at cost 5.