diff options
author | Sander Vrijders <[email protected]> | 2016-08-04 18:08:32 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2016-08-04 18:08:32 +0200 |
commit | d5b71449bc18116444720257ba640e3c597ff6e9 (patch) | |
tree | e2fca06805ca406607402c7206ea14ae17611d82 /src/tools/oping | |
parent | 51bb7c6f315dba4044eb2ece5c1312362674d7fb (diff) | |
parent | 25c356b9ba9d91b4a291e3adad050d8ea85eb3e2 (diff) | |
download | ouroboros-d5b71449bc18116444720257ba640e3c597ff6e9.tar.gz ouroboros-d5b71449bc18116444720257ba640e3c597ff6e9.zip |
Merged in dstaesse/ouroboros/be-bugfixing (pull request #186)
Be bugfixing
Diffstat (limited to 'src/tools/oping')
-rw-r--r-- | src/tools/oping/oping_client.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c index 23a57549..7693ce41 100644 --- a/src/tools/oping/oping_client.c +++ b/src/tools/oping/oping_client.c @@ -212,16 +212,21 @@ int client_main() printf("--- %s ping statistics ---\n", client.s_apn); printf("%d SDU's transmitted, ", client.sent); printf("%d received, ", client.rcvd); - printf("%d%% packet loss, ", 100 - ((100 * client.rcvd) / client.sent)); + printf("%d%% packet loss, ", client.sent == 0 ? 0 : + 100 - ((100 * client.rcvd) / client.sent)); printf("time: %.3f ms\n", ts_diff_us(&tic, &toc) / 1000.0); - printf("rtt min/avg/max/mdev = %.3f/%.3f/%.3f/", - client.rtt_min, - client.rtt_avg, - client.rtt_max); - client.rcvd > 1 ? - printf("%.3f ms\n", - sqrt(client.rtt_m2 / (float) (client.rcvd - 1))) : - printf("Nan ms\n"); + + if (client.rcvd > 0) { + printf("rtt min/avg/max/mdev = %.3f/%.3f/%.3f/", + client.rtt_min, + client.rtt_avg, + client.rtt_max); + if (client.rcvd > 1) + printf("%.3f ms\n", + sqrt(client.rtt_m2 / (float) (client.rcvd - 1))); + else + printf("NaN ms\n"); + } pthread_mutex_lock(&client.lock); free(client.times); |