Important: Use custom search function to get better results from our thousands of pages

Use " " for compulsory search eg:"electronics seminar" , use -" " for filter something eg: "electronics seminar" -"/tag/" (used for exclude results from tag pages)


 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
code for distance vector routing protocol in vhdl
Post: #1
Heart 

I need distance vector routing algorithm in VHDL language
please help me
Post: #2

/*
Distance Vector Routing in this program is implemented using Bellman Ford Algorithm:-
*/
#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("\nEnter the number of nodes : ");
scanf("%d",&nodes);//Enter the nodes
printf("\nEnter the cost matrix :\n");
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("\n\n For router %d\n",i+1);
for(j=0;j<nodes;j++)
{
printf("\t\nnode %d via %d Distance %d ",j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
}
printf("\n\n");
getch();
}
/*
A sample run of the program works as:-
Enter the number of nodes :
3
Enter the cost matrix :
0 2 7
2 0 1
7 1 0
For router 1
node 1 via 1 Distance 0
node 2 via 2 Distance 2
node 3 via 3 Distance 3
For router 2
node 1 via 1 Distance 2
node 2 via 2 Distance 0
node 3 via 3 Distance 1
For router 3
node 1 via 1 Distance 3
node 2 via 2 Distance 1
node 3 via 3 Distance 0
*/
 


[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Image Verification
(case insensitive)
Please enter the text within the image on the left in to the text box below. This process is used to prevent automated posts.

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  matlab code for speech compression using dwt Guest 0 0 26-06-2017 06:14 PM
Last Post: Guest
  steganography using dwt matlab code Guest 0 0 25-06-2017 03:49 PM
Last Post: Guest
  vhdl code for diffie hellman algorithm Guest 0 0 23-06-2017 10:00 AM
Last Post: Guest
  online auction java source code mychoose.com 0 0 22-06-2017 08:45 PM
Last Post: mychoose.com
  online auction java source code mychoose.com 0 0 22-06-2017 08:43 PM
Last Post: mychoose.com
  8051 projects with source code for automatic street light controller Guest 0 0 16-06-2017 05:47 PM
Last Post: Guest
  Matlab code for GPS localization siham31 0 0 14-06-2017 06:50 PM
Last Post: siham31
  genetic algorithm matlab code for steiner tree Guest 1 0 12-06-2017 02:55 PM
Last Post: jaseela123
  ecg matlab code free download Guest 1 0 01-06-2017 10:48 AM
Last Post: jaseela123
  tetris source code Guest 1 0 01-06-2017 10:29 AM
Last Post: jaseela123
This Page May Contain What is code for distance vector routing protocol in vhdl And Latest Information/News About code for distance vector routing protocol in vhdl,If Not ...Use Search to get more info about code for distance vector routing protocol in vhdl Or Ask Here

Options: