0% found this document useful (0 votes)
20 views2 pages

6.Bgp Routing

The document describes a C program that simulates BGP routing between nodes in a network. The program takes the number of nodes as input and stores the distances between each pair of nodes in a 2D array. It then applies the Bellman-Ford algorithm to find the shortest paths between all nodes, storing the results in a second 2D array. Finally, it prints out the final routing table showing the shortest distance from each node to every other node.

Uploaded by

nbranjit
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

6.Bgp Routing

The document describes a C program that simulates BGP routing between nodes in a network. The program takes the number of nodes as input and stores the distances between each pair of nodes in a 2D array. It then applies the Bellman-Ford algorithm to find the shortest paths between all nodes, storing the results in a second 2D array. Finally, it prints out the final routing table showing the shortest distance from each node to every other node.

Uploaded by

nbranjit
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

BGP ROUTING SIMULATION

#include<stdio.h>
int main()
{
int i,j,k,n,a[10][10],b[10][10];
printf("\nEnter the no. of nodes:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("\nEnter the distance between the host [%d][%d]:",i+1,j+1);
scanf("%d",&a[i][j]);
}
}
for(i=0;i<n;i++)
printf("Host %d\t",i+1);
printf("\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
printf("%d\t",a[i][j]);
printf("\n");
}
for(k=0;k<n;k++)
{
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j] > a[i][k] + a[k][j])
a[i][j]=a[i][k] + a[k][j];
}
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
b[i][j]=a[i][j];
if(i==j)
b[i][j]=0;
}
}

printf("\nThe output is:\n");


for(i=0;i<n;i++)
printf("Host %d\t",i+1);
printf("\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
printf("%d\t",b[i][j]);
printf("\n");
}
return 0;
}
Output:

You might also like