Program: - 1
1) Write a program for distance vector algorithm to find suitable
path for transmission.
Distance Vector Algorithm is a decentralize Rou ng algorithm that requires that each router
simply inform its neighbor of its rou ng table. For each network path, the receiving router pick the
neighbor adver sing the lowest cost, then add this entry into its rou ng table for re adver sement.
To find the shortest path, Distance vector algorithm is based on one of two basic algorithms: the
Bellman-Ford and the Dijkstra algorithms.
Reuters that use this algorithms have to maintain the distance table (Which is a one
dimension array—“a vector”), Which tells the distance and shortest path to sending packets to each
node in the network. The informa on in the distance table is always upd by exchanging informa on
with the neighboring nodes. The number of data in the table equals to that of all nodes in network
(excluded itself). The column of table represent the directly a ached neighbor whereas the rows
represent all the des na ons in the network. Each data contains the path for sending packet to
each des na on in the network and distance/or me to transmit on the path (we call this as
“cost”). The measurement in this algorithm are number of hopes latency, the number of outgoing
packets etc.
#include <stdio.h>
#define INFINITY 9999
#define MAX 10
struct node {
int dist[MAX];
int from[MAX];
} rou ngTable[MAX];
int main() {
int cost[MAX][MAX];
int nodes, i, j, k;