summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2018-06-01 16:56:51 +0200
committerDimitri Staessens <[email protected]>2018-06-01 18:19:57 +0200
commit22b3bdbe0e82b3a58d963a344e9227aa7c35e05a (patch)
tree3255210d367a41c34936f1247d98b0cb231bb087
parent3fe8431c5044e1337be78d82446d107299106919 (diff)
downloadouroboros-22b3bdbe0e82b3a58d963a344e9227aa7c35e05a.tar.gz
ouroboros-22b3bdbe0e82b3a58d963a344e9227aa7c35e05a.zip
tools: Add timestamp option to oping
This adds a timestamp option to oping, similar to the one in regular ping and rinaperf, so that we can more easily correlate time and latency. Signed-off-by: Sander Vrijders <[email protected]> Signed-off-by: Dimitri Staessens <[email protected]>
-rw-r--r--src/tools/oping/oping.c20
-rw-r--r--src/tools/oping/oping_client.c8
2 files changed, 22 insertions, 6 deletions
diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c
index 3c1d4fe9..40578742 100644
--- a/src/tools/oping/oping.c
+++ b/src/tools/oping/oping.c
@@ -70,6 +70,7 @@ struct c {
int interval;
uint32_t count;
int size;
+ bool timestamp;
/* stats */
uint32_t sent;
@@ -115,16 +116,19 @@ static void usage(void)
"\n"
" -c, --count Number of packets (default 1000)\n"
" -i, --interval Interval (ms, default 1000)\n"
- " -n, --server-apn Name of the oping server\n"
+ " -n, --server-name Name of the oping server\n"
" -s, --size Payload size (B, default 64)\n"
+ " -D, --timeofday Print time of day before each line"
+ "\n"
" --help Display this help text and exit\n");
}
-int main(int argc, char ** argv)
+int main(int argc,
+ char ** argv)
{
- int ret = -1;
- char * rem = NULL;
- bool serv = false;
+ int ret = -1;
+ char * rem = NULL;
+ bool serv = false;
argc--;
argv++;
@@ -133,6 +137,7 @@ int main(int argc, char ** argv)
client.interval = 1000;
client.size = 64;
client.count = 1000;
+ client.timestamp = false;
while (argc > 0) {
if (strcmp(*argv, "-i") == 0 ||
@@ -140,7 +145,7 @@ int main(int argc, char ** argv)
client.interval = strtol(*(++argv), &rem, 10);
--argc;
} else if (strcmp(*argv, "-n") == 0 ||
- strcmp(*argv, "--server_apn") == 0) {
+ strcmp(*argv, "--server_name") == 0) {
client.s_apn = *(++argv);
--argc;
} else if (strcmp(*argv, "-c") == 0 ||
@@ -154,6 +159,9 @@ int main(int argc, char ** argv)
} else if (strcmp(*argv, "-l") == 0 ||
strcmp(*argv, "--listen") == 0) {
serv = true;
+ } else if (strcmp(*argv, "-D") == 0 ||
+ strcmp(*argv, "--timeofday") == 0) {
+ client.timestamp = true;
} else {
usage();
exit(EXIT_SUCCESS);
diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c
index 97e9c8d3..e48b01cf 100644
--- a/src/tools/oping/oping_client.c
+++ b/src/tools/oping/oping_client.c
@@ -98,6 +98,14 @@ 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);
+ }
+
printf("%d bytes from %s: seq=%d time=%.3f ms\n",
msg_len,
client.s_apn,