summaryrefslogtreecommitdiff
path: root/src/tools/oping/oping_client.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2018-06-06 10:07:02 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2018-06-06 11:17:42 +0200
commite6ce5160d4de293e69e7d97ddc380ccbc59f16d5 (patch)
treee061c1af79bb7fb88481fcbb8afb11dca2ce15ad /src/tools/oping/oping_client.c
parentee9bfbed3726140d5601521de7ce8d003c453fb5 (diff)
downloadouroboros-e6ce5160d4de293e69e7d97ddc380ccbc59f16d5.tar.gz
ouroboros-e6ce5160d4de293e69e7d97ddc380ccbc59f16d5.zip
tools: Add quiet option to oping
This adds a --quiet -Q option to oping so it will only print the statistics summary. Also fixes a division by 0 if duration is specified with interval 0. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/tools/oping/oping_client.c')
-rw-r--r--src/tools/oping/oping_client.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c
index e777d4cc..0f7695b5 100644
--- a/src/tools/oping/oping_client.c
+++ b/src/tools/oping/oping_client.c
@@ -102,23 +102,25 @@ void * reader(void * o)
ms = ts_diff_us(&sent, &now) / 1000.0;
- if (client.timestamp) {
- struct timespec rtc;
- clock_gettime(CLOCK_REALTIME, &rtc);
- printf("[%zd.%06zu] ",
- (ssize_t) rtc.tv_sec,
- (size_t) rtc.tv_nsec / 1000);
- }
-
if (id < exp_id)
++client.ooo;
- printf("%d bytes from %s: seq=%d time=%.3f ms%s\n",
- msg_len,
- client.s_apn,
- ntohl(msg->id),
- ms,
- id < exp_id ? " [out-of-order]" : "");
+ if (!client.quiet) {
+ if (client.timestamp) {
+ struct timespec rtc;
+ clock_gettime(CLOCK_REALTIME, &rtc);
+ printf("[%zd.%06zu] ",
+ (ssize_t) rtc.tv_sec,
+ (size_t) rtc.tv_nsec / 1000);
+ }
+
+ printf("%d bytes from %s: seq=%d time=%.3f ms%s\n",
+ msg_len,
+ client.s_apn,
+ ntohl(msg->id),
+ ms,
+ id < exp_id ? " [out-of-order]" : "");
+ }
if (ms < client.rtt_min)
client.rtt_min = ms;
@@ -157,8 +159,9 @@ void * writer(void * o)
msg = (struct oping_msg *) buf;
- printf("Pinging %s with %d bytes of data:\n\n",
- client.s_apn, client.size);
+ if (!client.quiet)
+ printf("Pinging %s with %d bytes of data (%u packets):\n\n",
+ client.s_apn, client.size, client.count);
pthread_cleanup_push((void (*) (void *)) free, buf);