From 8164383425e333ca92211f19d6002b76d1d920ba Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 28 May 2020 01:14:54 +0300 Subject: [PATCH 1/2] Actually use -m (msg_size) parameter for TCP latency and B/W tests instead of hard-coded defaults (1 byte and 32K) --- src/socket.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/socket.c b/src/socket.c index c97c361..dbe0595 100644 --- a/src/socket.c +++ b/src/socket.c @@ -563,10 +563,15 @@ datagram_server_lat(KIND kind) * Set default IP parameters and ensure that any that are set are being used. */ static void -ip_parameters(long msgSize) +ip_parameters(long defaultSize) { - setp_u32(0, L_MSG_SIZE, msgSize); - setp_u32(0, R_MSG_SIZE, msgSize); + int size = Req.msg_size; + if (!size) + size = defaultSize; + setp_u32(0, L_MSG_SIZE, size); + setp_u32(0, R_MSG_SIZE, size); + par_use(L_MSG_SIZE); + par_use(R_MSG_SIZE); par_use(L_PORT); par_use(R_PORT); par_use(L_SOCK_BUF_SIZE); From 3ed9c07ef9b5329eda68aed6dcbe7dcc32a2c429 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 28 May 2020 01:17:00 +0300 Subject: [PATCH 2/2] Set TCP_NODELAY (disable Nagle) --- src/socket.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/socket.c b/src/socket.c index dbe0595..ea6c84a 100644 --- a/src/socket.c +++ b/src/socket.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "qperf.h" @@ -597,6 +598,10 @@ client_init(int *fd, KIND kind) if (!ai->ai_family) continue; *fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); + { + int one = 1; + setsockopt(*fd, SOL_TCP, TCP_NODELAY, &one, sizeof(one)); + } setsockopt_one(*fd, SO_REUSEADDR); if (connect(*fd, ai->ai_addr, ai->ai_addrlen) == SUCCESS0) break; @@ -630,6 +635,10 @@ stream_server_init(int *fd, KIND kind) listenFD = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (listenFD < 0) continue; + { + int one = 1; + setsockopt(listenFD, SOL_TCP, TCP_NODELAY, &one, sizeof(one)); + } setsockopt_one(listenFD, SO_REUSEADDR); if (bind(listenFD, ai->ai_addr, ai->ai_addrlen) == SUCCESS0) break;