summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2018-03-23 23:51:39 +0100
committerSander Vrijders <[email protected]>2018-03-25 12:15:03 +0200
commit2975db4c62d9fba5cecc265ce794c7371f835953 (patch)
treefaef3b0607d6fcbebaffae55514fc68c483abf9a /src
parente78740a4da0feb678f22bbc22b4c14a1f9a7bf7f (diff)
downloadouroboros-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 <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/tools/ocbr/ocbr.c17
-rw-r--r--src/tools/ocbr/ocbr_client.c2
-rw-r--r--src/tools/ocbr/ocbr_server.c2
3 files changed, 16 insertions, 5 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);
}
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);