With OSPF (Open Shortest Path First) every router knows the whole map of its area: which routers exist and which links with which costs. From this each computes the shortest paths itself with the Dijkstra algorithm. If a line fails, the change spreads immediately and everyone recomputes.
Sequence
Hello: routers regularly send hello packets to 224.0.0.5. Whoever answers and has the same values (area, network, intervals) becomes a neighbour.
Database exchange: neighbours exchange descriptions (DBD), request missing entries (LSR) and send them (LSU), acknowledged with LSAck.
SPF calculation: every router computes its routes from the database; they appear with “O” in the table.
The router ID is the highest loopback address, otherwise the highest interface address. The cost of an interface can be set; the path with the smallest sum wins.
Slow motion OSPF in the simulation: hello packets and exchange of routes
Setting up
Router(config)# router ospf
Router(config-router)# network 10.0.0.0/24 area 0
Router(config-router)# network 192.168.1.0/24 area 0
Router# show ip ospf neighbor
Router# show ip route
OSPFv3 does the same for IPv6: neighbours via link-local addresses, configuration per interface instead of with network.
Cost, hello and dead
Cost is the metric of OSPF: every outgoing interface has a value, the cost of a path is the sum (RFC 2328, Section 16). In leyoNET every interface has a cost of 10; ip ospf cost <1–65535> changes it to prefer or avoid a path. show ip route shows it as the second number, e.g. [110/20]. More on selection: Route selection: prefix, distance and metric.
Hello and dead: neighbours regularly send each other hellos to 224.0.0.5 (IPv6: ff02::5). If they stay away for the dead interval (usually four times the hello interval), the neighbour counts as lost and all routers recalculate. Only routers with the same area, the same network and the same timers become neighbours; show ip ospf neighbor shows whether it worked (state Full).
Areas split large networks into parts; all of them attach to the backbone area 0. For teaching, a single area 0 is usually enough.
OSPF or RIP?
OSPF converges faster, computes with costs instead of hops and scales better. RIP and RIPng is easier to understand and sufficient for small networks.
How to do it in leyoNET
The same text as in the app’s help (F1 key).
OSPF
OSPF is a link-state protocol: each router describes its links (LSA), all collect the map and compute shortest paths with Dijkstra.
Hello finds neighbours (standard every 10 s, shortened to 2 s in the simulator) (multicast 224.0.0.5)
DBD, LSR, LSU, LSAck synchronise the database until the neighbour is Full
Cost per interface (default 10), adjustable with ip ospf cost
CLI: router ospf, network 10.0.0.0/24 area 0 (or with wildcard 0.0.0.255), show ip ospf neighbor.
OSPFv3 (IPv6)
OSPFv3 (RFC 5340) is OSPF for IPv6. The process is the same as for OSPF: hello, DBD, LSR, LSU, LSAck, then full and Dijkstra. Differences:
Routers talk over their link-local addresses; hellos go to ff02::5, IPv6 next header 89.
You add interfaces, not networks (in FRRouting ipv6 ospf6 area 0 on the interface).
The router ID stays a 32-bit number written like an IPv4 address. If a router has no IPv4 address you should set it (otherwise the simulator derives one from the MAC).
Router LSAs only describe the links; the networks are carried in intra-area prefix LSAs.
The next hop in the routing table is the neighbour’s link-local address.
CLI: router ospf6, ospf6 router-id 1.1.1.1, interface eth0 area 0, show ipv6 ospf6 neighbor, show ipv6 ospf6 database, show ipv6 route (code O). Layer 3 switches speak OSPFv3 on their VLAN interfaces.
Simplified like OSPFv2: no DR/BDR election, no network and link LSAs, one area.
See an example
OSPF
Three routers in a triangle learn their networks via OSPF.
Hello, DBD, LSU, LSAck in the packet list; the routing table fills with O routes. Then remove a cable: OSPF recalculates.
The same three routers as for OSPF, but IPv6 only: they learn their prefixes by OSPFv3.
Hellos to ff02::5 from the link-local addresses, then DBD, LSR, LSU, LSAck. The IPv6 routing table fills with O routes; tracert takes the shortest path.
In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.
What leyoNET simplifies
Protocol
Layer
Simplification in the simulation
OSPFv2
3
Router LSAs and external LSAs (redistribution), no summary LSAs between areas, no DR/BDR (neighbours like point-to-point); hello 2 s instead of 10 s; a stuck database exchange (lost DBD/LSR/LSU) is repeated after two hello intervals; hellos from a foreign subnet form no adjacency
OSPFv3
3
Like OSPFv2, but over IPv6 (next header 89, ff02::5, link-local source); links instead of networks, router LSAs plus intra-area prefix LSAs, AS external LSAs; checksum over the IPv6 pseudo header; router ID from the MAC without IPv4; no link LSAs, no DR/BDR
RIP and RIPngDistance vector routing: routers tell their neighbours which networks they reach in how many hops – simple, but with limits.
Static routingEntering routes by hand: destination network, mask and next hop, default route, outbound and return path and the most common mistakes.
How routing worksDefault gateway, routing table, longest prefix and administrative distance – and when to route statically, automatically or dynamically.