diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/oping/oping.c | 15 | ||||
-rw-r--r-- | src/tools/oping/oping_client.c | 35 |
2 files changed, 32 insertions, 18 deletions
diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c index 757bd422..18801c2d 100644 --- a/src/tools/oping/oping.c +++ b/src/tools/oping/oping.c @@ -78,6 +78,7 @@ struct c { uint32_t sent; uint32_t rcvd; size_t ooo; + bool quiet; double rtt_min; double rtt_max; @@ -123,6 +124,7 @@ static void usage(void) " -n, --server-name Name of the oping server\n" " -q, --qos QoS (raw, best, video or voice)\n" " -s, --size Payload size (B, default 64)\n" + " -Q, --quiet Only print final statistics\n" " -D, --timeofday Print time of day before each line" "\n" " --help Display this help text and exit\n"); @@ -166,6 +168,7 @@ int main(int argc, client.count = INT_MAX; client.timestamp = false; client.qs = qos_raw; + client.quiet = false; while (argc > 0) { if (strcmp(*argv, "-i") == 0 || @@ -200,6 +203,10 @@ int main(int argc, } else if (strcmp(*argv, "-D") == 0 || strcmp(*argv, "--timeofday") == 0) { client.timestamp = true; + } else if (strcmp(*argv, "-Q") == 0 || + strcmp(*argv, "--quiet") == 0) { + client.quiet = true; + } else { goto fail; } @@ -207,8 +214,12 @@ int main(int argc, argv++; } - if (duration > 0) - client.count = duration / client.interval; + if (duration > 0) { + if (client.interval == 0) + client.count = duration * 10; + else + client.count = duration / client.interval; + } if (qos != NULL) { if (strcmp(qos, "best") == 0) 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); |