#include
#define e 1000
#define nodes1 40
int topology [nodes1][nodes1];
static int l,n,neighb,nodes;
static char neigh[nodes1];
struct
{
char name ;
int delay;
}dv[nodes1];
void main()
{
int i,j,k[nodes1*nodes1],add=0,src1;
char src='a';
clrscr();
printf("\t\t\t Distance vector routing \n");
printf("\n *********************************");
printf("\n Enter the no.of nodes ");
scanf("%d",&nodes);
fflush(stdin);
printf("\n Enter the node for which distance vector table is needed :");
scanf("%c",&src);
fflush(stdin);
printf("\n enter the no of neighbours to %c",src);
scanf("%d",&neighb);
fflush(stdin);
printf("\n enter the no of the neighbours in alphabetic order :");
neigh[0]=src;
for(i=1;i
scanf("%c",&neigh[i]);
fflush(stdin);
}
printf("\n enter the distance vector of the source and neighbouring nodes ");
printf("\n\n starting with source ,then with neighbouring nodes in alphabetical order:\n");
printf("\n \n starting with source,then with neighbouring nodes in alphabetical order :\n");
for(i=0;i
scanf("%d",&k[i]);
}
src1=src;
l=nodes;
n=1;
for(i=0;i
if(i==src1-97)
{
for(j=0;j
if(k[j]<0)
topology[i][j]=e;
else
topology[i][j]=k[j];
}
}
else if(i==neigh[n]-97)
{
for(j=0;j
if(k[l]<0)
topology[i][j]=e;
else
topology[i][j]=k[l];
l++;
}
n++;
}
else
{
for(j=0;j
}
}
i=src1-97;
for(j=0;j
dv[j].name=src1;
dv[j].delay=topology[i][j];
}
k[nodes*nodes]=e;
n=1;
for(i=0;i
if(i==neigh[n]-97)
{
add=topology[src1-97][i];
for(j=0;j
k[j]=add+topology[i][j];
}
for(j=0;j
if(k[j]
dv[j].name=i+97;
dv[j].delay=k[j];
}
}
if(i!=src1-97)
n++;
printf("\n %c's distance vector after receiving %c's vector :\n",src1,i+97);
for(j=0;j
getch();
}
}
}
0 comments:
Post a Comment