Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Networks use different routing protocols to select the best routing path to reac

ID: 3856667 • Letter: N

Question

Networks use different routing protocols to select the best routing path to reach other networks. A distance-vector routing uses a set of protocols (IPX, SPX, IP, or DECnet) and a distance calculation through an outgoing network interface to select the most efficient path to a network destination.

Link-state routing protocols track the connection status and type to each link that comes from a network. The criteria for selection are links with greater hops and faster mediums. Those are considered the most efficient links that will be used by the routing protocols.

Discuss the following for this assignment:

Do you think that most network administrators understand and use both distance-vector and link-state protocols? Why?

In your opinion, are there other options that can perform the tasks of these protocols? What is the future for routing through these protocols? Explain.

Explanation / Answer

C:


#include<stdio.h>
struct node
{
unsigned dist[20];
unsigned from[20];
}rt[10];
int main()
{
int costmat[20][20];
int nodes,i,j,k,count=0;
printf(" Enter the number of nodes : ");
scanf("%d",&nodes);//Enter the nodes
printf(" Enter the cost matrix : ");
for(i=0;i<nodes;i++)
{
for(j=0;j<nodes;j++)
{
scanf("%d",&costmat[i][j]);
costmat[i][i]=0;
rt[i].dist[j]=costmat[i][j];//initialise the distance equal to cost matrix
rt[i].from[j]=j;
}
}
do
{
count=0;
for(i=0;i<nodes;i++)//We choose arbitary vertex k and we calculate the direct distance from the node i to k using the cost matrix
//and add the distance from k to node j
for(j=0;j<nodes;j++)
for(k=0;k<nodes;k++)
if(rt[i].dist[j]>costmat[i][k]+rt[k].dist[j])
{//We calculate the minimum distance
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];
rt[i].from[j]=k;
count++;
}
}while(count!=0);
for(i=0;i<nodes;i++)
{
printf(" For router %d ",i+1);
for(j=0;j<nodes;j++)
{
printf(" node %d via %d Distance %d ",j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
}
printf(" ");
getch();
}


AND

void main()
{
int graph[50][50];
int i,j,k,t;
int nn;

cout<<" Enter Number of Nodes:";
cin>>nn;

/* Initialize graph*/
for (i=0;i<nn;i++)
{
for(j=0;j<nn;j++)
{
graph[i][j]=-1;
}
}

char ch[7]={'A','B','C','D','E','F','G'};

/* Get input */
for (i=0;i<nn;i++)
{
for(j=0;j<nn;j++)
{
if(i==j)
{
graph[i][j]=0;
}
if(graph[i][j]==-1)
{
cout<<" Enter Distance between "<<ch[i]<<" - "<<ch[j]<<" : ";
cin>>t;
graph[i][j]=graph[j][i]=t;
}
}
}

int via[50][50];
for (i=0;i<nn;i++)
{
for(j=0;j<nn;j++)
{
via[i][j]=-1;
}
}

cout<<" After Initialization";

for (i=0;i<nn;i++)
{
cout<<" "<<ch[i]<<" Table";
cout<<" Node Dist Via";
for(j=0;j<nn;j++)
{
cout<<" "<<ch[j]<<" "<<graph[i][j]<<" "<<via[i][j];
}
}

//sharing table
int sh[50][50][50];
for(i=0;i<nn;i++)
{
for(j=0;j<nn;j++)
{
for (k=0;k<nn;k++)
{
/* Check if edge is present or not*/
if((graph[i][j]>-1)&&(graph[j][k]>-1))
{
sh[i][j][k]=graph[j][k]+graph[i][j];
}
else
{
sh[i][j][k]=-1;
}
}
}
}

/*displaying shared table */
for(i=0;i<nn;i++)
{
cout<<" For "<<ch[i];
for (j=0;j<nn;j++)
{
cout<<" From "<<ch[j];
for(k=0;k<nn;k++)
{
cout<<" "<<ch[k]<<" "<<sh[i][j][k];
}
}
}

  
int final[50][50];
for(i=0;i<nn;i++)
{
for(j=0;j<nn;j++)
{

final[i][j]=graph[i][j];
via[i][j]=i;


/* Check condition a - b - c */
for(k=0;k<nn;k++)
{

if((final[i][j]>sh[i][k][j]) || (final[i][j] == -1))
{
if(sh[i][k][j]>-1)
{
final[i][j]=sh[i][k][j];
via[i][j]=k;
}
}
}
  

if(final[i][j]==-1)
{
for(k=0;k<nn;k++)
{

if((final[i][k]!=-1)&&(final[k][j]!=-1))
{
if((final[i][j]==-1) || ((final[i][j]!=-1) &&(final[i][j]>final[i][k]+final[k][j])))
{
if(final[i][k]+final[k][j]>-1)
{
final[i][j]=final[i][k]+final[k][j];
via[i][j]=k;
}
}
}

}
}
}
}

cout<<" After Update :";

for (i=0;i<nn;i++)
{
cout<<" "<<ch[i]<<" Table";
cout<<" Node Dist Via";
for(j=0;j<nn;j++)
{
cout<<" "<<ch[j]<<" "<<final[i][j]<<" ";
if(i==via[i][j])
cout<<"-";
else
cout<<ch[via[i][j]];
}
}

getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote