PDA

View Full Version : سوال: الگوريتم distance vectore



mortezamsp
چهارشنبه 23 دی 1388, 09:13 صبح
با سلام.

من يه سوال دارم درباره الگوريتم distance vectore دارم ، الگوريتمي براي مسيردهي به روترها در شبكه .
فرض ميكنيم ميخوايم اين الگوريتم رو با گراف پياده سازي كنيم . مساله مهم براي اين الگوريتم ، همزماني اون هست . سع يكردم همزماني رو با لوپ بسازم .بنظرتون اين همزماني رو چطور ميشه پياده كرد ؟


#include <stdlib.h>
#include <conio.h>
#include "newnetwork.cpp"

int main()
{
/* read a graph frome input file */
NewNetwork *net1 = new NewNetwork ("graph.dat") ;
/* print graph */
net1->PrintGraph () ;


/* DISTANCE VECTORE */
clrscr () ;
printf(" starting distance vectore , press anykey ." ) ;
getch () ;
/* first broadcast */
int i ;
net1->ResetMassagesCounter () ;
net1->InitialNodes () ;
/* algorithm , continues untill no changing happen in tabels */
while( ! CHANGEINTABELS )
{
/* first , update main_tabel using recived tabel */
for( i=0 ;i<net1->nodes ;i++ )
net1->node[i] . UpdateTabel() ;
/* then , broadcast main tabel to neighbours */
for( i=0 ;i<net1->nodes ;i++ )
net1->node[i] . SendTabelToNeighbours () ;
/* print tabels */
clrscr () ;
net1->PrintTabels () ;
delay (100) ;
}


/* print final report */
clrscr () ;
printf ("distance vectore completed \nmassages sent : %d " ,MassagesCount ) ;
getch () ;
clrscr () ;
printf ("\nfinal tabel is :\n") ;
net1->PrintTabels () ;
getch () ;


/* exit */
getch () ;
return 0 ;
}

mortezamsp
جمعه 25 دی 1388, 11:00 صبح
از همه دوستانی که کمک کردند ممنون .
این آخرشه :
http://cplusplus.blogsky.com/1388/11/16/post-52/