Skip to main content

Distance-vector routing algorithm simulator

The distance-vector routing algorithm is used in computer networking to determine the best path for data to take through the network. It can be tricky to understand, and working out examples by hand is cumbersome, so I built a basic simulator to use as a teaching aid with my undergraduate networking students.

Distance-vector routing uses a decentralized algorithm in which nodes (routers) share distance estimates with each other to eventually find the minimal-distance route between all pairs of nodes in the system. This simulator shows the steps that the algorithm takes, assuming all nodes send and receive messages at the same time on each iteration. It’s a bit ugly, but it works.

If you find bugs or have questions, you can email me. The source code is available in this site’s Git repository.


  1. Enter a network graph definition. Each line represents an edge (link) and is of the format n1,n2,d1,d2, where n1 and n2 are the names of the start and end nodes (routers), respectively, and d1 and d2 are the distances from n1 to n2 and from n2 to n1, respectively. If the edge only goes in one direction, the trailing ,d2 may be omitted. Note that this syntax allows specifying two separate edges with different distances and directions on the same line. (A sample definition is pre-populated.)
  2. Click the Start button. Starting will show the initial distance vectors for each node, formatted as a table. The entries show the current estimated distance from the row node to the column node for each node. The first hop node is also shown in parentheses. (For example, if row a, column c had the entry 7 (b), that would mean that node a estimates that it can get to node c with distance 7 by first going to node b.) Starting also renders a preview of the graph with Mermaid, which you can hide by clicking on the Graph preview text.
  3. Use the Next button to step through the iterations of the algorithm, or use the Finish button to run the algorithm until it converges. Entries that change from one step to the next are shown in purple, italic text.
  4. At any point after starting, you can tweak the graph definition and click the Update button to simulate link changes.
  5. To start over, simply enter a new graph definition and press Start again.
Illustrative examples

Graph preview


Click the Start button above to get started.

[This page was last updated on June 30, 2023.]