Thursday, April 23, 2009

Timers for Retransmission

Hi,

For those who are interested in using timers for retransmission, here is the stub code.
I am using 'setitimer' . Search on Internet for more information.

//timer structure
struct itimerval tTimer;

//timeout signal handler structure
struct sigaction sTimeout;

//Timeout handler function
void TimeoutHandler();

//Starting the timer
void StartTimer()
{
//Assiging the timeout handler (Signal handler for "SIGALRM")
memset (&sTimeout,0, sizeof (struct sigaction ));
sTimeout.sa_handler = &TimeoutHandler; // timeout handler function
sigaction (SIGALRM, &sTimeout, NULL);

//Setting the timer
tTimer.it_value.tv_sec = REQUIRED_TIME_IN_SEC;
tTimer.it_value.tv_usec = 0; //Required time in milliseconds
setitimer (ITIMER_REAL, &tTimer, NULL);

}
void TimeoutHandler()
{
// do something
}

//stopping the timer.
boolean StopTimer()
{
memset (&sTimeout,0, sizeof (sTimeout));
sTimeout.sa_handler =NULL;
tTimer.it_value.tv_sec = 0; tTimer.it_value.tv_usec = 0;
setitimer (ITIMER_REAL, &tTimer, NULL);
return TRUE;
}

Hope this helps.

Wednesday, April 1, 2009

BUG FIX

If you have errors compiling because of a struct, replace the following line in sr_vns_comm.c.

memcpy(&(sr->sr_addr.sin_addr),hp->h_addr,hp->h_length);

with

memcpy(&(sr->sr_addr.sin_addr),hp->h_addr_list[0],hp->h_length);

Welcome

Welcome to CS425 Router Project discussion blog !!!
Students can post their queries,comments and anything related to Router Project.