- 2069 Bhadra (old course) · 15 marks
OSPF working with routing tables
Short answer
OSPF is a link-state protocol using Hello packets for neighbour discovery, LSA flooding to build identical link-state databases, and Dijkstra SPF to compute shortest paths. In the example, R1 reaches PC2's LAN 192.168.3.0/24 via next hop 10.0.12.2 with cost 21.
Describe the working process of OSPF with example. Illustrate your answer with routing tables between source and destination machine. (Assume IP address, cost and network diagram by yourself).
OSPF
Open Shortest Path First (OSPF) is a link-state interior gateway protocol (OSPFv2 in RFC 2328) that runs inside an autonomous system. Each router learns the whole topology and computes the shortest path to each network using Dijkstra's SPF algorithm. It is classless, supports VLSM, converges quickly, uses multicast 224.0.0.5/224.0.0.6, runs directly over IP (protocol 89) and uses cost as metric (cost = reference bandwidth / link bandwidth).
Working process
- Neighbour discovery: routers send Hello packets on each interface (every 10 s). Neighbours with matching area, timers and authentication reach the 2-Way state. On multi-access LANs a Designated Router (DR) and Backup DR are elected.
- Database exchange: neighbours exchange Database Descriptions (ExStart/Exchange), request missing records (Loading) and reach the Full state.
- LSA flooding: each router describes its links and costs in Link State Advertisements, flooded to all routers in the area, so every router has an identical Link State Database (LSDB).
- SPF calculation: each router runs Dijkstra with itself as the root and builds a shortest path tree.
- Routing table: best routes are installed. Equal-cost paths can be load-balanced.
- Maintenance: Hellos continue; if a link changes, a new LSA is flooded and SPF is re-run.
Example (assumed)
PC1--LAN1--[R1]---cost 10---[R2]--LAN2
.1.10 | 10.0.12.0/30 | 192.168.2.0/24
| |
cost 30 cost 10
10.0.13.0/30 10.0.23.0/30
| |
+------[R3]--------+
|
LAN3 --- PC2
192.168.3.0/24 (.3.10)
Interfaces: R1: 192.168.1.1/24, 10.0.12.1, 10.0.13.1. R2: 10.0.12.2, 10.0.23.1, 192.168.2.1/24. R3: 10.0.23.2, 10.0.13.2, 192.168.3.1/24. LAN costs = 1.
SPF from R1: to R2 = 10; to R3 via R2 = 10 + 10 = 20 (direct link costs 30, so rejected); to LAN3 = 20 + 1 = 21 via R2.
Routing table of R1
| Destination | Type | Next hop | Cost |
|---|---|---|---|
| 192.168.1.0/24 | Connected | - | 1 |
| 10.0.12.0/30 | Connected | - | 10 |
| 10.0.13.0/30 | Connected | - | 30 |
| 192.168.2.0/24 | OSPF | 10.0.12.2 | 11 |
| 10.0.23.0/30 | OSPF | 10.0.12.2 | 20 |
| 192.168.3.0/24 | OSPF | 10.0.12.2 | 21 |
Routing table of R2
| Destination | Type | Next hop | Cost |
|---|---|---|---|
| 192.168.2.0/24 | Connected | - | 1 |
| 10.0.12.0/30 | Connected | - | 10 |
| 10.0.23.0/30 | Connected | - | 10 |
| 192.168.1.0/24 | OSPF | 10.0.12.1 | 11 |
| 192.168.3.0/24 | OSPF | 10.0.23.2 | 11 |
| 10.0.13.0/30 | OSPF | 10.0.12.1 or 10.0.23.2 (equal) | 40 |
Routing table of R3
| Destination | Type | Next hop | Cost |
|---|---|---|---|
| 192.168.3.0/24 | Connected | - | 1 |
| 10.0.23.0/30 | Connected | - | 10 |
| 10.0.13.0/30 | Connected | - | 30 |
| 192.168.2.0/24 | OSPF | 10.0.23.1 | 11 |
| 10.0.12.0/30 | OSPF | 10.0.23.1 | 20 |
| 192.168.1.0/24 | OSPF | 10.0.23.1 | 21 |
(R3 reaches LAN1 via R2: 10 + 10 + 1 = 21, better than direct 30 + 1 = 31.)
Packet walk, PC1 (192.168.1.10) to PC2 (192.168.3.10):
- PC2 is outside PC1's subnet, so PC1 sends to its gateway 192.168.1.1 (R1).
- R1 matches 192.168.3.0/24 (cost 21), forwards to next hop 10.0.12.2 (R2).
- R2 matches 192.168.3.0/24 (cost 11), forwards to 10.0.23.2 (R3).
- R3 has 192.168.3.0/24 connected and delivers directly to PC2 (ARP, then frame). The reply follows R3 to R2 to R1 using the tables above.
Configuration on R1 (Cisco style)
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
network 10.0.12.0 0.0.0.3 area 0
network 10.0.13.0 0.0.0.3 area 0
interface s0/0
ip ospf cost 10
interface s0/1
ip ospf cost 30
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- VLSM preventing IP address loss · Internet and Intranet, chapter 2
- TCP/IP applications; IPv4 vs IPv6 routing · Internet and Intranet, chapter 2
- IANA, ICANN functions and IP address role · Internet and Intranet, chapter 1
- Routing criteria; RIP, OSPF, BGP, IGRP, EIGRP · Computer Networks and Security, chapter 4
- Why IP address when MAC exists · Computer Networks and Security, chapter 4
- Coffee vending machine use case diagram · Object Oriented Analysis and Design, chapter 2
- Bottle recycling machine state diagram · Object Oriented Analysis and Design, chapter 2