How does OSPF work, at a high level?
Show the answer
Say this first
OSPF is a link-state IGP. Every router describes its own links in LSAs and floods them to every router in the area, so all routers in an area hold an identical link-state database. Each router then runs Dijkstra's SPF algorithm on that database with itself as the root and installs the shortest paths in the routing table.
Go deeper
The steps
- Discover neighbors with Hello packets (IP protocol 89, multicast
224.0.0.5). - Form adjacencies and synchronize databases with DBD, LSR, LSU and LSAck packets.
- Flood LSAs reliably. Every LSA is acknowledged, has a sequence number and an age.
- Run SPF. Each router builds a shortest-path tree from the LSDB, with itself as root.
- Install routes with administrative distance 110 and the summed cost as the metric.
What makes it link state
Routers do not pass routes to each other as distance vector protocols do. They pass topology facts ("I am R1, I have a link to R2 with cost 10, and a stub network 10.1.1.0/24") and each router computes routes itself. That is why every router in an area must have the same LSDB, and why you cannot summarize or filter LSAs inside an area.
Why areas
SPF cost grows with the size of the database. Areas limit flooding and SPF to one area. Between areas, ABRs advertise summaries (Type 3 LSAs), so inter-area routing behaves more like distance vector.
They will ask next
What triggers a full SPF run versus a partial one?
A change in Type 1 or Type 2 LSAs changes the topology inside the area, so the router runs a full SPF. A change in Type 3, 4, 5 or 7 LSAs only changes leaves of the tree, so IOS runs a partial route calculation (PRC), which is much cheaper.
What is the administrative distance of OSPF?
110 for all OSPF route types on Cisco. Junos uses 10 for internal OSPF routes and 150 for externals.
Traps
- Saying OSPF routers exchange routing tables. They exchange LSAs and each router computes its own table.
- Saying OSPF runs over TCP or UDP. It runs directly over IP as protocol 89 and does its own reliability.