int exit_flag = 0;
int node_id = 0;
+/** statistics */
+long int max = 0; /* maximum delay */
+long int min = 0; /* minimum delay */
+long int avg = 0; /* average delay */
+
+
inline void timespec_sub(struct timespec *diff, const struct timespec *left,
const struct timespec *right)
{
struct timespec recvtime;
struct timespec sendtime;
struct timespec difftime;
+ long int tmp;
recv_pinfo.body = NULL;
/* local_addr should be handled when creating socket */
}
printf("Receive endpoint created\n");
- count = 1;
+ count = 0;
while (count != num_msg){
count++;
if ((frsh_receive_sync(repoint, msg, msg_size, &len,
sscanf(msg,"msg%d-%ld-%ld", &count,
&sendtime.tv_sec, &sendtime.tv_nsec);
clock_gettime(CLOCK_MONOTONIC, &recvtime);
- timespec_sub(&difftime, &recvtime, &sendtime);
- printf("Ping: Received - %s\n time= %ld us\n", msg,
- difftime.tv_nsec / 1000);
+ timespec_sub(&difftime, &recvtime, &sendtime);
+ tmp = difftime.tv_sec * 1000 +
+ difftime.tv_nsec / 1000000;
+ if (tmp > max)
+ max = tmp;
+ if (tmp < min)
+ min = tmp;
+ avg += tmp;
+
+ printf("Ping: Received - %s\n", msg);
}
-
+
+ printf("Min= %ld ms Max = %ld ms Avg = %ld ms\n", min, max, avg/count);
/* TODO: destroy vres and send enpoint */
return NULL;