HomeNetworks & Graph TheoryInternet Routing

🌐 Internet Routing

Interactive Canvas simulation of internet routing: watch Distance-Vector (Bellman-Ford) and Link-State (Dijkstra) converge, route packets and recover from link failures.

Networks & Graph Theory3DAdvanced60 FPS💧 Water
internet-routing ↗ Open standalone

About this simulation

This simulation lets you compare the two families of algorithms that decide how packets actually travel across a network of routers: Distance-Vector, based on the Bellman-Ford algorithm and used historically by protocols like RIP, and Link-State, based on Dijkstra's shortest-path algorithm and used by protocols like OSPF. Each router only knows its own directly connected links and their costs; the two approaches differ in how that local information spreads until every router agrees on the best route to every destination.

🔬 What it shows

Distance-Vector routers exchange their full distance tables with neighbours each round, gradually converging via Bellman-Ford — and if you cut a link, stale routes can bounce upward toward an artificial "infinity" cap of 16 hops, reproducing the classic count-to-infinity problem. Link-State routers instead flood the entire topology to everyone, then each independently runs Dijkstra's algorithm to compute the shortest-path tree in a single pass.

🎮 How to use

Pick Distance-Vector or Link-State with the algorithm radio buttons, choose a Source and Destination router from the dropdowns, and load a Ring, Mesh, Star or Random topology preset. Use Step round to advance one exchange at a time or Auto-run to let it converge on its own, then press Send packet to animate a packet following the current best path. Switch to Add node, Add link or Cut link edit mode to reshape the network directly on the canvas and watch the routing recover.

💡 Did you know?

RIP's original design capped "infinity" at just 16 hops specifically to make the count-to-infinity problem resolve quickly rather than looping for a long time, at the cost of limiting RIP networks to 15 usable hops. Real-world link-state protocols like OSPF avoid this entirely by having every router build an identical map of the whole network before computing anything, which is also why OSPF converges in seconds while BGP-style routing across the wider internet can take minutes.

Frequently asked questions

What's the actual difference between Distance-Vector and Link-State routing in this simulation?

Distance-Vector routers only ever exchange summarised distance tables with their direct neighbours and run Bellman-Ford round by round, so convergence takes several rounds and depends on how the network is connected. Link-State routers first flood complete topology information to every other router, so each one ends up with an identical map and can compute the shortest-path tree with Dijkstra's algorithm in a single pass, without needing further rounds of exchange.

What is the "count-to-infinity" problem shown when I cut a link?

When a link that was part of a route fails, a Distance-Vector router that hasn't yet heard the bad news may still advertise a route through the broken path to its neighbours, who add their own cost and advertise it onward, slowly inflating the apparent distance instead of immediately recognising the destination is unreachable. The simulation caps this rising number at an "infinity" value of 16, matching how RIP historically limited networks to 15 usable hops specifically to bound how long this problem can drag on.

How do the Ring, Mesh, Star and Random topology presets change routing behaviour?

Ring and Star topologies have few alternate paths, so cutting a link can leave some nodes briefly unreachable until the remaining path is found. Mesh and Random topologies have more redundant links, so Distance-Vector and Link-State usually converge faster after a failure because there are more alternative routes available for the algorithms to fall back on.

What happens when I use the Add node, Add link or Cut link edit modes?

Add node places a new router wherever you click; Add link lets you click two existing routers to connect them with a randomly weighted link; Cut link toggles a clicked link between working and broken. Any of these changes forces both routing algorithms to reconverge from scratch, so you can watch Distance-Vector re-run Bellman-Ford or Link-State reflood and rerun Dijkstra on the new topology.

How does "Send packet" show the routed path?

It takes whatever path the currently selected algorithm has computed as the best route from Source to Destination and animates a small blue marker travelling along it, edge by edge, at the current animation speed. If no valid path exists — for example if a cut link has left the destination unreachable — the status readout shows "Unreachable" instead of routing a packet.

Frequently Asked Questions

What is an autonomous system (AS) and why does it matter?

An autonomous system is a network or group of networks under a single administrative authority, identified by an ASN (Autonomous System Number). The internet's routing is hierarchical: within an AS, interior protocols handle routing; between ASes, BGP handles inter-domain routing. This division allows the internet to scale to billions of devices.

How does BGP select the best route to a destination?

BGP applies a deterministic sequence of tie-breaking rules: highest local preference wins first; then fewest AS-path hops; then lowest MED (multi-exit discriminator); then prefer eBGP over iBGP routes; then lowest IGP metric to next hop; and finally various tie-breakers. Network operators configure local preference and route policies to reflect commercial and performance objectives.

What is a BGP route leak or BGP hijack?

A BGP route leak occurs when an AS accidentally or maliciously advertises routes it should not, redirecting traffic through unintended paths. A BGP hijack is the deliberate announcement of more specific prefixes to attract traffic destined for another network. High-profile hijacks have redirected internet traffic through Russia, China, and other countries, exposing security vulnerabilities in BGP's trust model.

What is OSPF and how does it differ from BGP?

OSPF is a link-state IGP used within a single autonomous system. Each router floods link-state advertisements to all others, builds a complete topology map, and runs Dijkstra's algorithm to compute shortest paths. BGP is a path-vector EGP used between ASes, with policy-based selection rather than pure shortest-path. OSPF converges in seconds; BGP can take minutes.

What is MPLS and what advantages does it provide?

MPLS adds short fixed-length labels to packets at the network edge. Core routers forward packets based on labels (simple table lookups) rather than longest-prefix IP matches, enabling faster forwarding, traffic engineering (directing traffic along specific paths), virtual private networks (MPLS VPNs), and quality-of-service guarantees. It decouples the forwarding plane from the IP routing plane.

⚙ Under the hood

Distance-vector routing (Bellman–Ford/RIP) can count to infinity; link-state (Dijkstra/OSPF) floods the map instead. Cut a link and watch reconvergence.

Canvas 2DRoutingBellman-FordDijkstraGraph Theory

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)