1. The Story
Press "Next" to go through it step by step. At each step a character appears and explains what they are doing.
Prologue: A quick recap
Step 1 of 11
The trouble with Static Routes
Last time, the network administrator added a Static Route to my map by hand, so I knew how to get to the studio. But when the cable broke, the Static Route did not update itself, and Pip got sent into a dead end.
Animation text version (all steps)
- Prologue: A quick recap
- The trouble with Static Routes · Rue: Last time, the network administrator added a Static Route to my map by hand, so I knew how to get to the studio. But when the cable broke, the Static Route did not update itself, and Pip got sent into a dead end.
- Act 1: A triangle of three Routers
- Here comes the Shop Router · Rue: The cable is fixed. The shop next door has a Router too, and the three of us are each linked to the other two, making a triangle. Now there are two ways to the studio: go direct, or go round via the shop.
- Every link has a Cost: it represents "distance". Usually, the faster the line, the lower the Cost
- In this story, all three links have a Cost of 10
- Professor Arpa: Two ways to swap notes · Professor Arpa: A long, long time ago... Routers had already learned to swap information automatically. This is called Dynamic Routing. Early RIP only told its neighbours "getting there from me passes through this many Routers". OSPF, which appeared in 1989, is cleverer: it gives every Router the whole map.
- Distance Vector: only listens to neighbours saying "how far is left", e.g. RIP
- Link State: every Router has the complete map and does its own calculation, e.g. OSPF
- OSPF stands for Open Shortest Path First
- Step 1: Hello, neighbour! · Rue: Once we are switched on, each of us Routers regularly sends a Hello message to its neighbours: "I'm here!" When we receive each other's Hellos, we become neighbours. After that we say hello again roughly every 10 seconds to check everyone is still there.
- Dead Interval: if no Hello arrives for 40 seconds, the neighbour is treated as lost
- Step 2: Swap notes with LSAs · Pip: Next, each Router describes its own situation in an LSA (Link State Advertisement): "Which networks and neighbours I connect to, and the Cost of each link." The LSAs travel to every Router.
- The LSA from Rue at home: "I connect to
192.168.1.0/24; neighbours: Studio (Cost 10), Shop (Cost 10)"
- The LSA from Rue at home: "I connect to
- Step 3: The same map · Rue: Put all the LSAs together and you get one complete map, called the LSDB (Link State Database). All three of us Routers hold exactly the same LSDB.
- Step 4: Work out the shortest route · Rue: Each Router runs the SPF (Shortest Path First) algorithm. From me to the studio: going direct costs 10; going via the shop costs 20. Direct is closer, so that goes into my Routing Table.
- Home → Studio: 10 ← lowest
- Home → Shop → Studio: 10 + 10 = 20
- SPF is also called Dijkstra's algorithm, invented by Edsger Dijkstra in 1956
- Act 2: The cable breaks again
- Spotting the problem · Rue: The cable between home and the studio has broken again! The Studio Router and I instantly notice our Ports have lost signal. If the other Router had quietly crashed instead, we would only find out after 40 seconds without a Hello.
- Sending new LSAs · Pip: Rue immediately sends a new LSA: "My link to the studio is gone!" The Studio Router does the same. Once the Shop Router receives them, everyone updates their LSDB and runs SPF again.
- Rerouting automatically · Rue: The new result: to reach the studio, go via the shop, with a Cost of 20. I update my Routing Table automatically, and Pip takes the new route. Nobody had to lift a finger!
- New route: Home → Shop → Studio (Cost 20)
- Once the cable is fixed, it switches back automatically to the direct route with a Cost of 10
- Summary: The Routers' information network · Professor Arpa: OSPF in four steps: Hellos to meet neighbours, LSAs to swap notes, piece together the same LSDB, and SPF for each Router to work out the shortest routes. Company networks mostly use OSPF. Between different ISPs on the Internet, another protocol is used, called BGP (Border Gateway Protocol).
2. Where Is the Problem
In the last story, the network administrator added a Static Route by hand to the Routing Table of Rue the Router. Only then could Pip reach the studio.
But Static Routes have two big problems:
- If a cable breaks, they do not reroute by themselves. Even if another path exists, Rue does not know to switch to it. Pip just gets sent into a dead end.
- When the network grows, there is too much to type by hand. Three Routers are manageable. With a hundred Routers and hundreds of networks, every new network means logging in to many Routers and editing them one by one. Mistakes are easy to make.
3. How the Network Solves It
Instead of drawing every map by hand, let the Routers swap notes with each other and each draw their own map.
When Routers automatically exchange route information and automatically update their Routing Tables, it is called Dynamic Routing.
OSPF (Open Shortest Path First) is the most widely used kind. It works like a team of postmen. First they say hello to each other. Then each one writes "these are the roads around me" as a note and passes it to every teammate. Once a postman has collected all the notes, everyone holds the same complete map, and each one works out the shortest route for themselves.
4. A Closer Look
Two ways to swap notes
| Method | How it works | Example |
|---|---|---|
| Distance Vector | Only listens to neighbours saying "to get there from me takes this many stops, this far". It never sees the whole map | RIP (Routing Information Protocol) |
| Link State | Every Router has the complete map and works out the shortest routes itself | OSPF |
RIP only counts how many Routers a path passes through, up to a maximum of 15, and it is slow to reroute. OSPF appeared in 1989. Its full name is Open Shortest Path First. "Open" means it is a public standard that any vendor can use.
Cost: the "distance" of each road
OSPF gives every link a Cost. Cost represents "distance": usually, the faster the line, the lower the Cost. Some devices calculate it automatically by default using "reference bandwidth ÷ link bandwidth", and network administrators can also set it by hand.
This story has three Routers, each connected to the other two to form a triangle. All three links have a Cost of 10.
OSPF in four steps
Step 1: Hello, meet the neighbours
Every Router regularly sends a Hello message to the Routers directly connected to it: "I'm here!" When two Routers receive each other's Hello and their basic settings match, they become Neighbours.
After that, they say hello roughly every 10 seconds. If no Hello arrives for 40 seconds, the neighbour is treated as lost. This waiting time is called the Dead Interval.
Step 2: Exchange LSAs (Link State Advertisements)
Each Router describes its own situation in an LSA. For example, here is the LSA from Rue at home:
I am: Rue at home
I connect to: 192.168.1.0/24
Neighbours: Studio Router (Cost 10), Shop Router (Cost 10)
LSAs are passed along hop by hop until they reach every Router.
Step 3: Piece together the LSDB (Link State Database)
Put all the LSAs together and you get one complete map, called the LSDB. All three Routers hold exactly the same LSDB.
Step 4: Use SPF (Shortest Path First) to find the shortest routes
Each Router starts from itself and uses the SPF algorithm to work out the total Cost to every network. SPF is also called Dijkstra's algorithm, invented by computer scientist Edsger Dijkstra in 1956.
Here is how Rue at home works out the route to the studio:
| Route | Total Cost |
|---|---|
| Home → Studio | 10 ← lowest, the winner |
| Home → Shop → Studio | 10 + 10 = 20 |
The result is written into the Routing Table. In the Routing Table, routes like this are marked with the code O, meaning they were learned through OSPF.
What happens when a cable breaks?
- Spot the problem: The cable between home and the studio breaks. Both Routers' Ports instantly lose signal, so they know straight away. A Port is a numbered connection point on a device. If the other Router quietly crashes while the Port light stays on, they have to wait for the Dead Interval (40 seconds) to pass before they notice.
- Send new LSAs: Each of the two Routers sends a new LSA: "The link between us is gone!" The Shop Router receives it and passes it on.
- Recalculate: Everyone updates their LSDB and runs SPF again.
- Reroute automatically: The new route from home to the studio goes via the shop, with a Cost of 20. Rue updates the Routing Table automatically, and Pip takes the new route.
The process of all Routers settling on consistent, correct routes again is called Convergence. Once the cable is fixed, the Routers exchange LSAs again and automatically switch back to the direct route with a Cost of 10.
When nothing in the network changes, the Routers only keep in touch with Hellos. New LSAs are sent only when something changes (plus a refresh every 30 minutes), so OSPF does not use much bandwidth.
Where is OSPF used?
The internal networks of companies, schools and ISPs (Internet Service Providers) mostly use OSPF. Between different ISPs and organisations across the Internet, a different protocol is used, called BGP (Border Gateway Protocol).
5. Try It Yourself
Task: Calculate SPF by hand
- On a piece of paper, draw the triangle of three Routers: Home, Studio and Shop.
- Change the Cost of "Home–Studio" to 30. Keep the other two at 10.
- Work out the total Cost of both routes from home to the studio. Which one will Rue choose this time? (Answer: via the shop. The total Cost is 20, lower than 30 for going direct.)
Mini game
The right order for OSPF
Three Routers have just been switched on. Put the five OSPF steps in the right order.
- All the LSAs are pieced together into an identical LSDB
- Write the results into the Routing Table
- Send Hellos to meet the neighbours
- Use SPF to find the route with the lowest total Cost
- Exchange LSAs describing your own links and Costs
6. Where the Analogy Breaks
- Routers do not really "write letters". Hellos and LSAs are small packets sent between Routers. Software handles them automatically, in milliseconds.
- The map does not always cover the whole world. Large networks split their Routers into several Areas. Every Router in an Area has the same LSDB, and Areas only exchange summaries, so the map does not grow too big.
- Cost is not real distance. Cost is a number the network administrator can change. It usually reflects line speed and has nothing directly to do with how far apart two Routers are.
- Automatic does not mean no setup. The network administrator still has to decide which Ports run OSPF, the Cost of each link, and so on. Only the changes after that are handled automatically by the Routers.
- Rerouting is not instant. It takes a little time from spotting a problem until all Routers converge. During that time, a few Pips may still be sent the wrong way or lost.
7. Quiz
8. Key Notes
- Dynamic Routing lets Routers swap information and update their Routing Tables automatically, and reroute by themselves when a cable breaks.
- OSPF is a Link State protocol: every Router holds the same complete map, then does its own calculations.
- OSPF in four steps: Hello to meet neighbours → exchange LSAs → piece together the same LSDB → use SPF to find the route with the lowest total Cost.
- Hellos are sent roughly every 10 seconds. If none arrives for 40 seconds (the Dead Interval), the neighbour is treated as lost.
- Company networks mostly use OSPF. Different ISPs on the Internet use BGP (Border Gateway Protocol) between them.
Further reading
Now the Rues know how to find routes automatically, and home, the studio and the shop are all connected. But the devices at home use Private IPs, which nobody recognises once they leave for the Internet. In the next story, Rue becomes the building office and introduces NAT (Network Address Translation) and Port Forwarding.