October, 2008

Distance Vector Algorithm

Many routers these days still use this algorithm to work out the shortest path to other computers/routers in the network. Crucial aspect of any network discovery.


knownTable = table[j];
/* if the destination address is the same then we found that node in our table */
if(knownTable.address == newTable.address)
{
found = 1;
/* update the table with the cost */
/* to get to itself + the cost to get to that node */
int ab = 99999;
int newHop;
int k;
for(k=1;k (ab + bc) )
{
table[j].nexthop = newHop;
table[j].cost = ab + bc;
tablechanged = 1;
printf("\nLowest cost found %d - Updating Table\n", bc);
}
break;
}