I want to calculate the total some of delay pf receiving Side Packet .
Code is as Follow ..
What is weired that even if i invoke a sleep of 2 sec ,than its show delay alwts zero. Delay will be in microsec ..Is there any problem with logic or anyhting else..
Code:
do
{
#pragma omp parallel private(nthreads, tid)
{
/* Obtain thread number */
tid = omp_get_thread_num();
if (tid == 0)
{
nthreads = omp_get_num_threads();
printf("Number of threads = %d\n", nthreads);
}
#pragma omp critical
{
gettimeofday(&tv3,NULL);
if(flag==0)
Cur_Pkt_Time=tv3.tv_sec+tv3.tv_usec;
else
{
Las_Pkt_Time= Cur_Pkt_Time ;
Cur_Pkt_Time=tv3.tv_sec+tv3.tv_usec;
sleep(2);
Delay=Delay+(Cur_Pkt_Time-Las_Pkt_Time);
}
flag=1;
n = write(sockfd,buffer,packet_size);
num_pkt_send++;
TotalSend=TotalSend+n;
}
if (n < 0)
{
error("ERROR writing to socket");
exit(1);
}
printf("%d Bytes Send: %d\n",num_pkt_send,n);
}
gettimeofday(&tv2, NULL);
} while((tv2.tv_sec-tv1.tv_sec)<=Sen_Loop_time);