diff options
author | Dimitri Staessens <dimitri.staessens@ugent.be> | 2018-03-23 23:51:39 +0100 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2018-03-25 12:15:03 +0200 |
commit | 2975db4c62d9fba5cecc265ce794c7371f835953 (patch) | |
tree | faef3b0607d6fcbebaffae55514fc68c483abf9a /src/tools/ocbr/ocbr.c | |
parent | e78740a4da0feb678f22bbc22b4c14a1f9a7bf7f (diff) | |
download | ouroboros-2975db4c62d9fba5cecc265ce794c7371f835953.tar.gz ouroboros-2975db4c62d9fba5cecc265ce794c7371f835953.zip |
tools: Increase read buffer in ocbr server
The ocbr server had a 1500 byte read buffer, which caused it to
perform partial reads on larger SDUs, slowing it down considerably
when sendin large packets. The buffer has been increased to 512KB,
partial reads disabled, and the client will give an error when larger
frames are sent. It will also warn if the size overflows (avoiding a
SEGV).
Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be>
Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/tools/ocbr/ocbr.c')
-rw-r--r-- | src/tools/ocbr/ocbr.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/tools/ocbr/ocbr.c b/src/tools/ocbr/ocbr.c index 2c22cc3c..e2bd84af 100644 --- a/src/tools/ocbr/ocbr.c +++ b/src/tools/ocbr/ocbr.c @@ -46,7 +46,7 @@ #include <time.h> #include <stdbool.h> -#define BUF_SIZE 1500 +#define BUF_SIZE 524288L #include "ocbr_client.c" @@ -71,11 +71,12 @@ static void usage(void) " -n, --server_apn Specify the name of the server.\n" " -d, --duration Duration for sending (s)\n" " -f, --flood Send SDUs as fast as possible\n" - " -s, --size SDU size (B)\n" + " -s, --size SDU size (B, max %ld B)\n" " -r, --rate Rate (b/s)\n" " --sleep Sleep in between sending SDUs\n" "\n\n" - " --help Display this help text and exit\n"); + " --help Display this help text and exit\n", + BUF_SIZE); } int main(int argc, char ** argv) @@ -152,6 +153,16 @@ int main(int argc, char ** argv) return 0; } + if (size > BUF_SIZE) { + printf("Maximum size: %ld.\n", BUF_SIZE); + return 0; + } + + if (size < 0) { + printf("Size overflow.\n"); + return 0; + } + ret = client_main(s_apn, duration, size, rate, flood, sleep); } |