I'm trying to code a program for a class that simulates a router and so far I have the basics set up ("router" can send and receive packets through an emulated server to other "routers" connected to the server). Each packet contains only the distance vector for that router. When a router receives a packet it is supposed to update it's own distance vector accordingly using the Bellman-Ford algorithm. The problem I'm having is that I am finding myself unable to implement the actual algorithm without cheating and using an adjacency matrix.
For example, say I have 3 routers connected as follows:
A ---1--- B ---2--- C
That is, A and B are connected with a link cost of 1, and B and C are connected with a link cost of 2. So when the routers are all started, they will send a packet to each of their directly connected neighbors containing their distance vector info. So A would send router B (0, 1, INF), B would send A and C (1, 0, 2) and C would send B (INF, 2, 0) where INF means the 2 routers are not directly connected.
So let's look at router A receiving a packet from router B. To calculate the minimum costs to each other router using the Bellman-Ford algorithm is as follows.
Mincost(a,b) = min((cost(a,b) + distance(b,b)),(cost(a,c) + distance(c,b))
Mincost(a,c) = min((cost(a,b) + distance(b,c)),(cost(a,c) + distance(c,c))
So the problem I am running into is that I cannot for the life of me figure out how to implement an algorithm that will calculate the minimum path for a router to every other router. It's easy enough to make one if you know exactly how many routers there are going to be but how would you do it when the number of routers can be arbitrarily big?
You never can make sure of the shortest paths with DVMRP. You dont have the global view of the network for one thing. Each router is operating on as much as it sees and what it sees is restricted-- can be misleading. Look up the looping problem of DVMRP. DVMRP can never have the full network info to process on.
It isn`t scalable either. Its performance is increasingly lower as the number or routers increase. This is because of the distance-vector update message flooded around and current accuracy of these messages.
It is one of the earliest multicast protocols. Its performance matches that of RIP of the unicast scale.