diff options
| author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2026-05-10 17:29:59 +0200 |
|---|---|---|
| committer | Sander Vrijders <sander@ouroboros.rocks> | 2026-05-20 08:17:06 +0200 |
| commit | 3f962298bfcf2fb0c6a30b4f1d9e1423321409cb (patch) | |
| tree | 5a6f00d996edfc3dc127c3abcc139f582d780cef /src/tools/oping | |
| parent | 9b1e5b3ac032449deb47357784b108551702e748 (diff) | |
| download | ouroboros-3f962298bfcf2fb0c6a30b4f1d9e1423321409cb.tar.gz ouroboros-3f962298bfcf2fb0c6a30b4f1d9e1423321409cb.zip | |
tools: Add timeout option to oping
Add a -W/--timeout option to override the per-packet recv timeout.
The default is 2000 ms. Raises the receive buffer to 16 KiB so larger
SDUs aren't truncated (useful for fragmentation tests later on).
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/tools/oping')
| -rw-r--r-- | src/tools/oping/oping.c | 11 | ||||
| -rw-r--r-- | src/tools/oping/oping_client.c | 5 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c index 16d36c51..5c9d35a5 100644 --- a/src/tools/oping/oping.c +++ b/src/tools/oping/oping.c @@ -60,7 +60,7 @@ #include <errno.h> #include <float.h> -#define OPING_BUF_SIZE 1500 +#define OPING_BUF_SIZE 16384 #define ECHO_REQUEST 0 #define ECHO_REPLY 1 #define OPING_MAX_FLOWS 256 @@ -83,6 +83,7 @@ " -n, --server-name Name of the oping server\n" \ " -q, --qos QoS (raw, best, video, voice, data)\n" \ " -s, --size Payload size (B, default 64)\n" \ +" -W, --timeout Per-packet recv timeout, ms (default 2000)\n" \ " -Q, --quiet Only print final statistics\n" \ " -D, --timeofday Print time of day before each line\n" \ "\n" \ @@ -93,6 +94,7 @@ struct { int interval; uint32_t count; int size; + int timeout; /* per-packet recv timeout, ms */ bool timestamp; bool flood; bool flood_busy; @@ -180,6 +182,7 @@ int main(int argc, client.interval = 1000; client.size = 64; client.count = INT_MAX; + client.timeout = 2000; client.timestamp = false; client.flood = false; client.flood_busy = false; @@ -218,6 +221,12 @@ int main(int argc, argc > 1) { client.size = strtol(*(++argv), &rem, 10); --argc; + } else if ((strcmp(*argv, "-W") == 0 || + strcmp(*argv, "--timeout") == 0) && + argc > 1) { + client.timeout = strtol(*(++argv), &rem, 10); + client.timeout *= time_mul(rem); + --argc; } else if ((strcmp(*argv, "-q") == 0 || strcmp(*argv, "--qos") == 0) && argc > 1) { diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c index 62b94e67..4b01315d 100644 --- a/src/tools/oping/oping_client.c +++ b/src/tools/oping/oping_client.c @@ -90,7 +90,7 @@ static void print_rtt(int len, int seq, void * reader(void * o) { - struct timespec timeout = {client.interval / 1000 + 2, 0}; + struct timespec timeout; struct timespec now = {0, 0}; struct timespec sent; @@ -101,6 +101,9 @@ void * reader(void * o) double ms = 0; uint32_t exp_id = 0; + timeout.tv_sec = client.timeout / 1000; + timeout.tv_nsec = (client.timeout % 1000) * MILLION; + fccntl(fd, FLOWSRCVTIMEO, &timeout); while (!stop && client.rcvd != client.count) { |
