ELEC3506

RoutingLecture 6 PDF15 min

OSPF

How OSPF turns Dijkstra's algorithm into a working link state protocol, worked through the lecture's own cost-64 configuration exercise.

By the end of this page you should be able to

  • Explain what portion of the routing table an OSPF router actually sends its neighbours
  • Describe the role of hello packets in OSPF
  • State what a shortest-path tree yields once computed
  • Trace the cost-64 exercise to its resulting routing table

The idea

Link state routing says every router needs the full topology, but that does not mean every router floods its entire routing table at every neighbour. OSPF’s trick is that each router only ever describes itself — its own links and their metrics — and lets the flooding process assemble those self-descriptions into a full picture at every router independently.

How it works

OSPF overview

Each router sends only the portion of the routing table that describes the current state of its own links to the internetwork:

  • Information on attached interfaces
  • Metrics used (minimum delay, maximum throughput, etc.)
  • Other variables

Every router collects this from every other router and builds a picture of the entire network in its own routing table. A Shortest Path First (SPF) algorithm — Dijkstra’s algorithm, or link state routing generally — is then used to calculate the shortest path to each node from that assembled picture.

Aside

The lecture points to an external video walkthrough of the OSPF protocol for a further look at the mechanics. That content is not reproduced on this page — the mechanism above and the worked exercise below are what the lecture’s own slides state directly.

How it works

The Shortest Path First algorithm

OSPF sends hello packets to its neighbours and receives their hello packets in return. These also act as a keep-alive, letting routers know that their neighbours are still functional — a failed router can be detected quickly, and the network’s topology altered appropriately once it is.

Each router calculates a shortest-path tree, with itself as the root. That shortest-path tree, in turn, yields a routing table.

Worked example

Configuring routers with cost 64

Every link in this small network is configured with OSPF cost 64. Trace the SPF computation from R0.

  1. Step 1. N' = {R0}. R1 and R2 are direct neighbours of R0, each at cost 64 via R0. R3 is not a direct neighbour, so its cost is inf.

  2. Step 2. R1 joins N' (it is one of the minimum-cost candidates). R2’s cost is unchanged at 64 via R0 — going through R1 would cost 64 + 64 = 128, which is worse. R3’s cost updates to 128 via R1, since R1’s own link to R3 also costs 64.

  3. Step 3. R2 joins N'. R3’s cost stays at 128 via R1 — a path through R2 does not improve on it.

Resulting SPF table:

StepN’D(R1), p(R1)D(R2), p(R2)D(R3), p(R3)
1R064, R064, R0inf
2R0, R164, R0128, R1
3R0, R1, R2128, R1

Resulting routing table, as the lecture states it:

DestinationNext-hopOSPF cost
30.0.0.010.0.0.2128
40.0.0.020.0.0.2128
10.0.0.0Directly connected
20.0.0.0Directly connected

AnswerR1 and R2 are each directly reachable from R0 at cost 64; R3 is reachable at cost 128 via R1

Aside

The lecture does not state explicitly which router in the topology this final IP-addressed table belongs to — it follows straight on from the abstract R0/R1/R2/R3 computation, and the two “directly connected” entries (10.0.0.0 and 20.0.0.0) suggest it is the routing table of one of the interior routers rather than R0 itself. Treat the table as the lecture’s own stated answer to the exercise rather than something derived independently on this page.

How it works

The Packet Tracer exercise

This lecture is accompanied by a Cisco Packet Tracer file, OSPF_lab_Ed_1.pkt. The lecture directs students to download it and complete the accompanying Ed lesson to practise configuring OSPF routes hands-on.

Check yourself

  • OSPF routers advertise only their own link state, not their whole table — the full topology is assembled from everyone’s self-description.
  • Hello packets are the keep-alive; a missing one signals a failed neighbour.
  • Each router computes its own shortest-path tree, rooted at itself, which yields its routing table.
  • In the cost-64 exercise, direct neighbours cost 64; a two-hop path costs 128, and Dijkstra’s minimum rule never lets a worse path overwrite a better one already found.

In the exam

  • Say precisely what an OSPF router sends: the state of its own attached links and their metrics, not the whole routing table. This is a common point of confusion with plain link state flooding described generically.
  • Hello packets are for neighbour liveness, not for carrying routing information itself — do not conflate them with LSPs.
  • Trace the cost-64 exercise the same way as any Dijkstra example: apply the min(D(v), D(w)+c_{w,v}) rule at each step, and note when an update does not change an existing estimate.
  • OSPF cost is just Dijkstra’s algorithm on the assembled topology — if a question asks “what algorithm does OSPF use,” the answer is Dijkstra’s / Shortest Path First, by name.

Check yourself

  1. What exactly does each OSPF router send to its neighbours in an update?
  2. What is the purpose of an OSPF hello packet?
  3. In the lecture's cost-64 exercise, all links cost 64. At step 1 with N' = {R0}, what is D(R3)?
  4. By step 3 of the same exercise, D(R3) = 128 via R1. Why does adding R2 to N' at that step not change this?