Pcornel
Networking · Routing › OSPF › OSPF Fundamentals

SPF (Shortest Path First)

Cheat sheet · https://pcornel.dk/topic.php?topic=1093

Back to the Topic

Answer

SPF (Shortest Path First, Dijkstra's algorithm) is how OSPF calculates routes: each router puts itself at the root and computes the lowest-cost path to every destination in its LSDB. SPF reruns when topology LSAs change.

Remember

Do not infer service health from one command. For SPF, distinguish configured intent, protocol/security state, installed forwarding state and the original workload result.

First checks

  • show ip ospf statistics — SPF runs and timing
  • show ip route ospf — SPF result

Commands

show ip ospf statistics
Shows how often OSPF ran SPF in each area, how long it took and what triggered it.
show ip ospf interface brief

Verify in this order

LSDB change → SPF throttle → SPF run → RIB update

Where it usually breaks

underlay/interface reachability → protocol adjacency/session → received/originated state → policy → best path/RIB → FIB/adjacency → traffic path

SPF · technical reference

ItemMeaning
InputArea topology in LSDB
MetricOSPF cost
OutputOSPF candidate paths/routes
Later stagesRIB selection then CEF forwarding

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=1093

Confirmation

Confirm action

Continue?