Shortest Path Algorithm (Networking), RIP

Some general routing issues to consider:

Here in this possible path between two devices (in red), we may want to optimize:

A routing decision is made on every single packet, so each IP Addressing (IP Protocol) datagram is processed, and we search for an existing destination IP in the Routing Table. Where is this done? On every router.

The routing goal is to find the least cost route from the source to the destination. In effect, it creates a logical shortest path tree Network Topologies over the physical topology (ie: it's a minimum cost spanning tree). We'll look at Dijkstra's and Bellman-Ford.

Process to Develop the Routing Table

We'll make an Adjacency Matrix that describes the number of edges between two points on the graph. For now, assume we only care about hop count (so no weights on the edges yet):

Then for this example network we have:

[0110010110110100110100010]

Then you can run Dijkstra's algorithm, taking powers of this adjacency matrix to get the cost of taking a path from any vertex to another.

If you wanted to add in the weights you could:

[0510050320130100210200020]

You can also add make the graph directed. You just consider the in-degree using those weights (using the in-vertex on the rows, out-vertex on the columns; really the order doesn't matter as you'll get the transpose if you do it the other way).

Distance Vector Routing

The distance vector routing protocol only considers hop count, and nothing else. It generates a next hop count table:

  1. Collect the Hop Count Data
  2. Process
  3. Generate Hop Count Table AND the Routing Table.

Consider the example from before again. The routers that are neighbors will only share their hop count table with each other. So A will only share with B,C, and vice versa.

Hop count table for A:

Dest. Subnet Hop Count Next Hop
B 1 B
C 1 C
Note that these are shared initially (with the neighbors). For B:
Dest. Subnet Hop Count Next Hop
A 1 A
C 1 C
D 1 D
For C:
Dest. Subnet Hop Count Next Hop
B 1 B
A 1 A
D 1 D

Next is the traffic for these requests get forwarded, so for the example below A shares the B traffic to it's neighbor C:

GIving the following tables:

A:

Dest. Subnet Hop Count Next Hop
B 1 B
C 1 C
D 2 C
B:
Dest. Subnet Hop Count Next Hop
A 1 A
C 1 C
D 1 D
E 2 D
C:
Dest. Subnet Hop Count Next Hop
B 1 B
A 1 A
D 1 D
E 2 D
D:
Dest. Subnet Hop Count Next Hop
B 1 B
C 1 C
E 1 E
A 2 B
We continue. At the end we need to update the 3 hop in A:
Dest. Subnet Hop Count Next Hop
B 1 B
C 1 C
D 2 C
E 3 B
##### Info on the Distance Vector Routing Algorithm

Note that:

To fix this we have different methods:

Distant Vector Routing (ex: RIP)

So this uses "Bellman-Ford's" shortest path algorithm, where each router will only have a local view of the network. We have two sample implementations:

Some issues include: