OSPF shortest path and cost
From advertisements to a shortest-path tree
An LSA describes routing information, while the link-state database (LSDB) stores the collected advertisements. Within one converged OSPF area, routers aim to have consistent area topology information. Each router runs SPF (shortest path first, based on Dijkstra’s algorithm) from its own viewpoint. In OSPFv2, a Type 1 router LSA describes a router’s area links; a Type 2 network LSA represents a transit multi-access network and is originated by its DR. Other LSA types and flooding scopes are covered in the multi-area chapter. The LSDB is not itself the forwarding table.
Calculate a route with three routers
All three links are modeled as point-to-point. Costs are positive, symmetric in this example only, and explicitly assigned; actual interface costs are directional and need not match in reverse. R3 advertises a connected stub network with cost 5. From R1, direct cost to the prefix through R3 is 40 + 5 = 45; through R2 it is 10 + 10 + 5 = 25. Thus R2 is the preferred next hop for that prefix under the stated model. OSPF cost is additive, not a hop count or a measurement of current latency.
Area 0; symmetric link costs for this paper modelR1 ----10---- R2 | |40 10 | | +----------- R3 ---- 5 ---- 203.0.113.0/24What changes after a link failure?
If R2–R3 fails and the remaining graph is unchanged, updated topology information eventually leads R1 to prefer its direct link to R3: total cost 45. If R1–R3 also fails, there is no remaining path to the prefix in this graph. Equal-cost paths may both be installed subject to implementation and policy limits: setting the direct cost to 20 would make both total costs 25. These are stable-state predictions, not convergence timing measurements. During transitions packets can be dropped or temporarily loop.
Read-only checks on an approved FRRouting lab
These commands are documented for FRRouting 10.0 OSPFv2 inside its routing CLI (vtysh), assuming a prepared, isolated lab with ospfd and zebra already operating and authorized access. They are static references, not executed commands or observed output. Compare the interface settings, neighbor states, LSDB contents and OSPF-calculated route. The OSPF route still needs to be selected by the routing system and installed for forwarding. Check the actual forwarding table and return path separately before inferring application health. Automatic cost formulas and reference bandwidth are implementation settings; use consistent settings across routers and verify effective interface cost rather than guessing it from the advertised link speed.
show ip ospf interfaceshow ip ospf neighborshow ip ospf databaseshow ip ospf routePractice and next step
In the original graph, raise only the R1-to-R2 cost to 35, leaving its reverse cost unchanged. Compare the two forward routes to the prefix. Explain why the reverse direction cannot be inferred merely by reversing the preferred path. Next, compare point-to-point and multi-access networks.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
OSPF shortest path and cost — knowledge check
Apply OSPF single-area concepts to fictional routing situations.
R1–R2 cost 6, R2–R3 cost 8, R1–R3 cost 20; a prefix attached to R3 costs 4. What is the preferred total cost from R1?
In the preceding graph, the R2–R3 link fails. What is the stable cost from R1 to that prefix if the other links remain?
Which OSPFv2 advertisement is originated by a DR to describe a transit multi-access network?
Two eligible intra-area paths have equal additive cost. What can OSPF support?
Which FRRouting 10.0 command displays OSPF-calculated routes?