From 2975db4c62d9fba5cecc265ce794c7371f835953 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 23 Mar 2018 23:51:39 +0100 Subject: 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 Signed-off-by: Sander Vrijders --- src/tools/ocbr/ocbr.c | 17 ++++++++++++++--- src/tools/ocbr/ocbr_client.c | 2 +- src/tools/ocbr/ocbr_server.c | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') 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 #include -#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); } diff --git a/src/tools/ocbr/ocbr_client.c b/src/tools/ocbr/ocbr_client.c index bf527317..026ab001 100644 --- a/src/tools/ocbr/ocbr_client.c +++ b/src/tools/ocbr/ocbr_client.c @@ -79,7 +79,7 @@ int client_main(char * server, struct sigaction sig_act; int fd = 0; - char buf[size]; + char buf[BUF_SIZE]; long seqnr = 0; long gap = size * 8.0 * (BILLION / (double) rate); diff --git a/src/tools/ocbr/ocbr_server.c b/src/tools/ocbr/ocbr_server.c index 3004d77c..4f080eff 100644 --- a/src/tools/ocbr/ocbr_server.c +++ b/src/tools/ocbr/ocbr_server.c @@ -100,7 +100,7 @@ static void handle_flow(int fd) alive = iv_start; ts_add(&iv_start, &intv, &iv_end); - fccntl(fd, FLOWSFLAGS, FLOWFRNOBLOCK | FLOWFRDWR); + fccntl(fd, FLOWSFLAGS, FLOWFRNOBLOCK | FLOWFRDWR | FLOWFRNOPART); while (!stop) { clock_gettime(CLOCK_REALTIME, &now); -- cgit v1.2.3