Communication Networks · Visualized

Link-State Routing (Dijkstra)

Routing

How routers choose paths — flooding everything, computing shortest-path trees, or exchanging distance tables.

3 interactive subtopics — each one animated, step-through and explained.

Link-State Routing (Dijkstra)

Routing

In link-state routing every router floods a tiny description of its own links (an LSA). Once all LSAs arrive, each router holds an identical map of the network and independently runs Dijkstra’s algorithm to build a shortest-path tree rooted at itself. OSPF works exactly this way inside an area.

How Link-State Routing (Dijkstra) Works

  1. Each router announces its links and costs to everyone (flooding the LSA).
  2. All routers assemble the same topology database — a complete map.
  3. Dijkstra starts at the router itself: settled set = {self}.
  4. Repeatedly settle the closest unsettled neighbour, relaxing distances through it.
  5. The resulting tree gives the next hop for every destination; tables update whenever an LSA changes.

Link-State Routing (Dijkstra) Worked Example

Try it: Play — LSAs flash first, then watch nodes settle into the shortest-path tree one by one with running distances.

B settles at cost 1, then C improves from 5 to 3 through B — the classic relaxation moment. The final table lists each destination with its total cost and next hop.

12432334ABCDEFsource
shortest-path tree LSA / just settled unvisited
Stage 1 / 13
A floods its LSA: “my links: B(1) C(2)”. Soon every router holds the identical map.

Link-State Routing (Dijkstra): Key Facts to Remember

ComplexityO((V+E) log V) with a heap — recomputed on every topology change
Memoryeach router stores the whole area map, not just routes
ProtocolsOSPF and IS-IS; BGP’s path-vector approach scales beyond what maps allow

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses

See how packets really travel

Networks are built on the structures and algorithms you can watch step by step — queues, trees, and routing algorithms.