int retval = -1;
int i;
for( i=1; i<=10; i++)
{
printf("\ti=%d \n", i);
gettimeofday(&time1,NULL);
retval = open_socket();
if ( retval < 0 )
{
return -1;
}
gettimeofday(&time2,NULL);
timediff = (time2.tv_sec-time1.tv_sec)*1000000 + time2.tv_usec-time1.tv_usec;
printf(" the duration of open and bind SOCK_RAW socket of PF_PACKET:%d us \n", timediff);
if ( retval > 0)
{
gettimeofday(&time1,NULL);
close(retval);
gettimeofday(&time2,NULL);
timediff = (time2.tv_sec-time1.tv_sec)*1000000 + time2.tv_usec-time1.tv_usec;
printf(" the duration of close SOCK_RAW socket of PF_PACKET:%d us\n", timediff);
}