In link state routing each router learns the complete topology by flooding link-state packets, then runs Dijkstra's shortest-path algorithm to build its own routing table.
Steps performed by every router
- Discover neighbours by sending HELLO packets and learn their addresses.
- Measure the cost (delay, bandwidth-based metric) to each neighbour, e.g. using ECHO packets.
- Build a link-state packet (LSP) containing its ID, sequence number, age, and the list of neighbours with costs.
- Flood the LSP to all routers. Sequence numbers and age prevent old or duplicate LSPs from circulating.
- Compute shortest paths with Dijkstra's algorithm on the full topology map and fill the routing table.
Example. Links: A–B 2, A–C 5, B–C 1, B–D 4, C–D 1. Router A runs Dijkstra:
| Step | Confirmed set | B | C | D |
|---|---|---|---|---|
| 0 | {A} | 2 (A) | 5 (A) | ∞ |
| 1 | {A, B} | 2 | min(5, 2+1) = 3 (B) | 2+4 = 6 (B) |
| 2 | {A, B, C} | 3 | min(6, 3+1) = 4 (C) | |
| 3 | {A, B, C, D} | 4 |
Routing table at A:
| Destination | Cost | Next hop |
|---|---|---|
| B | 2 | B |
| C | 3 | B |
| D | 4 | B |
(Path to D: A → B → C → D.)
Advantages over distance vector: faster convergence, no count-to-infinity problem, each router has a full view of the network. Disadvantages: more memory and CPU (storing the map and running Dijkstra) and flooding overhead. Protocols: OSPF and IS-IS.