SkarpSkarp

Chapter 15 of 29

OSPFv2 Concepts: Link-State Routing Inside an Autonomous System

Step into link-state routing with OSPFv2, understanding areas, LSAs, and neighbor relationships that power scalable IPv4 routing domains.

27 min readen

From Static Routes to OSPFv2: Why Link-State?

Why We Need OSPFv2

Static routes work in small, stable networks. In real campus or enterprise networks with many subnets and changing links, you need a dynamic routing protocol that can learn and adapt automatically.

OSPFv2 in One Sentence

OSPFv2: "Open Shortest Path First version 2 (OSPFv2) is a link-state interior gateway protocol used to exchange IPv4 routing information within a single autonomous system."

Key Ideas in the Definition

OSPFv2 is an Interior Gateway Protocol, meaning it runs inside one organization or autonomous system. It is used for IPv4 and is a link-state protocol, which shares detailed link information, not just distances.

What You Will Learn

You will compare link-state vs distance-vector routing, see how OSPFv2 uses LSAs and areas, understand cost and shortest-path calculation, and walk through a small, CCNA-style OSPF example.

Link-State vs Distance-Vector: Big-Picture Comparison

Distance-Vector Basics

Distance-vector protocols (like RIP) know distances and next-hops. Routers share their routing tables with neighbors but do not know the full network topology, only what neighbors tell them.

Link-State Basics

Link-state protocols (like OSPFv2) discover local links and neighbors, then flood LSAs so every router has the same link-state database. Each router runs a shortest-path algorithm on that database.

Convergence and Loops

Distance-vector convergence can be slower and vulnerable to routing loops. Link-state protocols typically converge faster and scale better in large networks because every router has a full map.

Exam Memory Hook

Think of DV as "routing by rumor" and LS as "routing by map". CCNA questions often ask which type sends full routing tables or which builds a complete view of the topology.

OSPFv2 Inside an Autonomous System and Areas

Autonomous System Context

An autonomous system is a set of IP networks under one administrative control. OSPFv2 runs inside this AS as an interior gateway protocol for IPv4 routing.

Why OSPF Uses Areas

If all OSPF routers shared LSAs with everyone, the link-state database and CPU load would grow too large. Areas group routers so each only maintains a smaller LSDB.

Backbone vs Non-Backbone

Area 0 is the OSPF backbone. Other areas (1, 2, etc.) must connect to Area 0. Routers in multiple areas are Area Border Routers (ABRs) and keep separate LSDBs per area.

Typical Campus Design

In many designs, core and distribution routers are in Area 0, while access or branch routers are in non-backbone areas. CCNA questions often ask you to identify areas and ABRs in such topologies.

OSPFv2 Neighbors and Adjacencies

Hello Packets and Neighbors

OSPFv2 sends Hello packets to 224.0.0.5 on enabled interfaces. Routers that see each other’s Hellos and match key parameters become neighbors.

Matching Parameters

For neighbors to form, area ID, subnet/mask, Hello and Dead timers, authentication, and stub flags must match. If they differ, no adjacency forms and no routes are exchanged.

Neighbors vs Adjacencies

A neighbor has basic communication established. An adjacency is a full relationship where LSDBs are synchronized. On point-to-point links, neighbors usually become fully adjacent.

DR and BDR on Broadcast Links

On Ethernet, OSPF elects a Designated Router and Backup DR. Full adjacencies are typically built with the DR/BDR, reducing flooding. This often appears in CCNA topology questions.

Inside the OSPFv2 Brain: LSAs, LSDB, and SPF

What is an LSA?

A Link-State Advertisement (LSA) is a structured message describing part of the topology, such as a router’s links or a network segment. LSAs are flooded so all routers share the same information.

The Link-State Database (LSDB)

All LSAs received in an area are stored in the Link-State Database. Every router in the same area should have an identical LSDB, giving them a common map of the network.

SPF Algorithm

Each router runs the Shortest Path First (Dijkstra) algorithm on the LSDB. Links have a cost, and SPF finds the lowest-cost path from the router to all destinations.

From Map to Routes

After SPF runs, the best paths are installed in the routing table as OSPF routes (like `O` for intra-area, `O IA` for inter-area). LSAs create the map; SPF turns the map into forwarding decisions.

OSPFv2 Cost and Path Selection

OSPF Metric: Cost

OSPFv2 uses cost as its metric. Lower cost means a better path. Cost is typically calculated from interface bandwidth using a reference bandwidth value.

Default Cost Formula

A common formula is cost = referencebandwidth / interfacebandwidth. With a 100 Mbps reference, 10 Mbps = cost 10, 100 Mbps = cost 1, and 1 Gbps also becomes cost 1 unless you raise the reference.

Total Path Cost

For each possible route, OSPF adds the costs of all outgoing interfaces along the path. The path with the lowest total cost is selected as the best route.

Common Exam Traps

Do not confuse cost with hop count. A longer-hop path can win if its total cost is lower. Remember cost is per interface, and equal-cost paths can be load balanced.

Worked Example: Choosing the Best OSPF Path

Topology Overview

R1 connects to R2 at 100 Mbps (cost 1) and to R3 at 10 Mbps (cost 10). R2 and R3 connect at 100 Mbps (cost 1). R3 connects to LAN 10.10.10.0/24 with cost 1.

Direct Path Cost

Path A: R1 → R3 → LAN. R1-R3 link cost 10, R3-LAN cost 1. Total cost = 10 + 1 = 11.

Indirect Path Cost

Path B: R1 → R2 → R3 → LAN. R1-R2 cost 1, R2-R3 cost 1, R3-LAN cost 1. Total cost = 1 + 1 + 1 = 3.

Which Path Wins?

OSPF chooses the path with the lowest total cost. Here, Path B with cost 3 is better than Path A with cost 11, so R1 routes to 10.10.10.0/24 via R2.

Thought Exercise: Link-State Map vs Distance-Vector Rumor

Goal for this step: Strengthen your intuition by predicting behavior in failure scenarios.

Consider this scenario:

  • Three routers in a line: R1 – R2 – R3
  • R1 and R3 are not directly connected.
  • All run a distance-vector protocol in Scenario A, and OSPFv2 in Scenario B.
  • Initially, all links are up, and R1 has a route to a LAN behind R3.

Now the link between R2 and R3 fails.

Your tasks (think before checking notes):

  1. In Scenario A (distance-vector), what might R1 “hear” from R2 after the failure? How could a routing loop form temporarily?
  2. In Scenario B (OSPFv2), what information does R1 receive, and why does it avoid the same kind of loop?
  3. Which approach converges faster in this simple case, and why?

Hints to guide your thinking:

  • Distance-vector routers advertise routes with metrics, but they do not share the full topology.
  • Link-state routers flood LSAs that describe which links are up or down.
  • With OSPF, when the R2–R3 link fails, an updated LSA is flooded, and SPF recalculates paths.

Take 1–2 minutes to write a short explanation in your own words. This kind of narrative reasoning helps for scenario-based CCNA questions, not just multiple choice.

Concept Check: Link-State vs Distance-Vector

Answer this to confirm you can distinguish link-state from distance-vector behavior.

Which statement best describes a key difference between link-state and distance-vector routing protocols?

  1. Link-state protocols periodically send their entire routing table to neighbors, while distance-vector protocols only send LSAs when the topology changes.
  2. Link-state protocols build a complete map of the network topology and run a shortest path algorithm, while distance-vector protocols only know distances and next-hops learned from neighbors.
  3. Distance-vector protocols require areas and a backbone, while link-state protocols cannot be divided into areas.
  4. Distance-vector protocols can perform equal-cost load balancing, while link-state protocols cannot.
Show Answer

Answer: B) Link-state protocols build a complete map of the network topology and run a shortest path algorithm, while distance-vector protocols only know distances and next-hops learned from neighbors.

Link-state protocols like OSPFv2 flood LSAs so every router in an area has a full link-state database, then run SPF to compute best paths. Distance-vector protocols know only distances and next-hops learned from neighbors and do not maintain a full topology map. Option 1 reverses behaviors, option 3 is incorrect about areas, and option 4 is wrong because link-state protocols can do equal-cost load balancing.

Concept Check: OSPFv2 Areas and Cost

Test your understanding of OSPFv2 areas and metrics.

In an OSPFv2 network, a router has two possible paths to a destination network in the same area. Path 1 has a total cost of 20. Path 2 has a total cost of 30 but uses fewer hops. Which path will OSPFv2 install as the best route, and why?

  1. Path 1, because OSPFv2 always prefers the path with the lowest total cost, regardless of hop count.
  2. Path 2, because OSPFv2 always prefers the path with fewer hops.
  3. Both paths, because OSPFv2 always installs all discovered paths to a destination.
  4. Neither path, because OSPFv2 only supports equal-cost paths.
Show Answer

Answer: A) Path 1, because OSPFv2 always prefers the path with the lowest total cost, regardless of hop count.

OSPFv2 uses cost as its metric. It sums interface costs along each path and chooses the path with the lowest total cost, independent of hop count. Here, Path 1 (cost 20) is preferred over Path 2 (cost 30), even though Path 2 has fewer hops.

Key OSPFv2 Terms Review

Flip through these cards to reinforce core OSPFv2 vocabulary before moving on.

OSPFv2 (full definition)
Open Shortest Path First version 2 (OSPFv2) is a link-state interior gateway protocol used to exchange IPv4 routing information within a single autonomous system.
Link-state routing (concept)
A routing approach where routers describe their directly connected links and flood this information as LSAs. Every router builds an identical link-state database and runs a shortest path algorithm to compute routes.
Distance-vector routing (concept)
A routing approach where routers share information about destination networks and their distance (metric) and next-hop. Routers do not maintain a full topology map; they rely on information learned from neighbors.
OSPF area
A logical grouping of routers and networks that share the same link-state database. Areas allow OSPF to scale by limiting the scope of LSAs. Area 0 is the backbone area.
Area Border Router (ABR)
A router that has interfaces in more than one OSPF area. It maintains a separate LSDB for each area and advertises summary routes between areas.
Link-State Advertisement (LSA)
An OSPF message type that describes part of the network topology, such as a router’s links or a network segment. LSAs are flooded within areas and stored in the LSDB.
Link-State Database (LSDB)
The collection of all LSAs received by a router for a given OSPF area. All routers in the same area should have an identical LSDB, which represents the network topology.
Shortest Path First (SPF) algorithm
The Dijkstra algorithm used by OSPF to compute the lowest-cost paths from the local router to all known destinations based on the LSDB.
OSPF cost
The metric used by OSPFv2 to evaluate paths. Lower cost is better. Total path cost is the sum of interface costs along the path, often derived from interface bandwidth.
OSPF neighbor vs adjacency
Neighbors are routers that have exchanged Hellos and recognized each other. An adjacency is a full OSPF relationship where routers have synchronized LSDBs and can exchange routing information.
Designated Router (DR)
An OSPF router elected on multi-access networks (like Ethernet) to act as a central point for exchanging LSAs, reducing flooding. A Backup DR (BDR) is also elected for redundancy.

Putting It Together and Next Steps in Your Path

OSPFv2 Story Recap

OSPFv2 is a link-state IGP for IPv4 inside one autonomous system. Routers discover neighbors, flood LSAs, build an LSDB per area, and run SPF to compute routes based on cost.

Scaling with Areas

Areas and the backbone (Area 0) let OSPF scale. ABRs connect areas and summarize routes. All routers in an area share the same LSDB and topology view.

Exam Focus Points

Expect CCNA questions on link-state vs distance-vector, identifying areas and ABRs, predicting best paths from costs, and troubleshooting why OSPF neighbors do not form adjacencies.

Your Next Steps

Use Skarp’s diagnostic to test your OSPF understanding, then tackle the next mock exam. Weak areas will appear in your spaced review, and the next module will move into OSPFv2 configuration and verification.

Key Terms

OSPFv2
Open Shortest Path First version 2 (OSPFv2) is a link-state interior gateway protocol used to exchange IPv4 routing information within a single autonomous system.
OSPF area
A logical grouping of routers and networks that share the same link-state database. Areas allow OSPF to scale by limiting the scope of LSAs. Area 0 is the backbone area.
OSPF cost
The metric used by OSPFv2 to evaluate paths. Lower cost is better. Total path cost is the sum of interface costs along the path, often derived from interface bandwidth.
link-state routing
A routing approach where routers describe their directly connected links and flood this information as LSAs. Every router builds an identical link-state database and runs a shortest path algorithm to compute routes.
Designated Router (DR)
An OSPF router elected on multi-access networks (like Ethernet) to act as a central point for exchanging LSAs, reducing flooding. A Backup DR (BDR) provides redundancy.
autonomous system (AS)
A collection of IP networks and routers under a single administrative control, presenting a common routing policy to the internet.
distance-vector routing
A routing approach where routers share information about destination networks and their distance (metric) and next-hop. Routers do not maintain a full topology map; they rely on information learned from neighbors.
Area Border Router (ABR)
A router that has interfaces in more than one OSPF area. It maintains a separate LSDB for each area and advertises summary routes between areas.
Link-State Database (LSDB)
The collection of all LSAs received by a router for a given OSPF area. All routers in the same area should have an identical LSDB, which represents the network topology.
Link-State Advertisement (LSA)
An OSPF message type that describes part of the network topology, such as a router’s links or a network segment. LSAs are flooded within areas and stored in the LSDB.
Shortest Path First (SPF) algorithm
The Dijkstra algorithm used by OSPF to compute the lowest-cost paths from the local router to all known destinations based on the LSDB.

Finished reading?

Test your understanding with a custom practice exam on this chapter.

Test yourself