summaryrefslogtreecommitdiff
path: root/src/tools/oping/oping_client.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2017-02-22 12:50:02 +0100
committerSander Vrijders <sander.vrijders@intec.ugent.be>2017-02-22 12:50:02 +0100
commit16a7f9a9c5ff9da44ecd323244a93f150003c57d (patch)
treef38407a4c45e48951bfb440ac9f01591f0803eeb /src/tools/oping/oping_client.c
parentef0f04e9631947e8419f23743dd20cd538c04473 (diff)
parent63cf8fdb4a79a08572e2488d65a040ba733bdfbc (diff)
downloadouroboros-16a7f9a9c5ff9da44ecd323244a93f150003c57d.tar.gz
ouroboros-16a7f9a9c5ff9da44ecd323244a93f150003c57d.zip
Merge branch 'testing' into be
Diffstat (limited to 'src/tools/oping/oping_client.c')
-rw-r--r--src/tools/oping/oping_client.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c
index ee2d9df6..99c11a68 100644
--- a/src/tools/oping/oping_client.c
+++ b/src/tools/oping/oping_client.c
@@ -86,7 +86,7 @@ void * reader(void * o)
++client.rcvd;
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
pthread_mutex_lock(&client.lock);
ms = ts_diff_us(&client.times[ntohl(msg->id)], &now)
@@ -105,7 +105,7 @@ void * reader(void * o)
client.rtt_max = ms;
d = (ms - client.rtt_avg);
- client.rtt_avg += d / (float) client.rcvd;
+ client.rtt_avg += d / client.rcvd;
client.rtt_m2 += d * (ms - client.rtt_avg);
}
@@ -140,18 +140,19 @@ void * writer(void * o)
nanosleep(&wait, NULL);
msg->type = htonl(ECHO_REQUEST);
msg->id = htonl(client.sent);
+
+ clock_gettime(CLOCK_MONOTONIC, &now);
+
+ pthread_mutex_lock(&client.lock);
+ client.times[client.sent++] = now;
+ pthread_mutex_unlock(&client.lock);
+
if (flow_write(*fdp, buf, client.size) == -1) {
printf("Failed to send SDU.\n");
flow_dealloc(*fdp);
free(buf);
return (void *) -1;
}
-
- clock_gettime(CLOCK_REALTIME, &now);
-
- pthread_mutex_lock(&client.lock);
- client.times[client.sent++] = now;
- pthread_mutex_unlock(&client.lock);
}
pthread_cleanup_pop(true);
@@ -252,7 +253,7 @@ int client_main(void)
client.rtt_max);
if (client.rcvd > 1)
printf("%.3f ms\n",
- sqrt(client.rtt_m2 / (float) (client.rcvd - 1)));
+ sqrt(client.rtt_m2 / (client.rcvd - 1)));
else
printf("NaN ms\n");
}