Link state protocols take a different approach from distance vector ones. Instead of sharing a list of distances, each router describes its own links. Everyone collects these descriptions and builds the same map.
Four steps
- Meet neighbours. Routers send small hello messages on their links.
- Describe links. Each router creates an advertisement listing its links and their costs.
- Flood. The advertisements are passed to every router in the area, which stores them in a link state database.
- Calculate. Each router runs the shortest path first (SPF) algorithm, due to Dijkstra, with itself as the starting point.
Cost and shortest paths
Each link has a cost, and the path with the lowest total wins. From router A to router C:
A ---10--- C
A ---3--- B ---3--- CThe direct link costs 10. The route through B costs 6, so A chooses B, even though it has more hops. In many OSPF implementations the default cost comes from link bandwidth, so faster links are cheaper. Defaults vary, and you can set costs by hand.
OSPF and IS-IS
OSPF is widely used inside organisations. OSPFv2 carries IPv4, and OSPFv3 was created for IPv6. Large networks are divided into areas to keep each database and calculation small. Area 0 is the backbone, and other areas connect to it.
IS-IS is the other major link state protocol, common in provider networks.
Reacting to change
When a link fails, the routers next to it send new advertisements. These flood through the area and everyone recalculates. Updates are sent when something changes, with an occasional refresh, so convergence is usually fast. The price is more memory and processor work than RIP.
On Linux
A daemon such as FRR provides OSPF. After enabling ospfd, a minimal configuration in vtysh is:
configure terminal
router ospf
network 192.0.2.0/24 area 0You can then check who the router is talking to with show ip ospf neighbor, and inspect the database with show ip ospf database. A neighbour in the Full state has finished exchanging databases. On a shared Ethernet segment, some neighbour pairs stay in 2-Way, which is also normal.
If neighbours do not appear, check that both sides use the same area and timers, are in the same subnet, and that no firewall blocks OSPF (IP protocol 89).
Try it
Sketch five routers with a cost on each link. Starting at one router, find the cheapest total to every other one, and write down the first hop for each. Then delete one link and calculate again. The subnetting guide is useful for choosing link addresses.
Check your understanding
Link State Protocols
All 4 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.