From c2fcd0a509f2a7c70d0aaf3fa1b0e62a3fe072f9 Mon Sep 17 00:00:00 2001 From: Brian Tierney Date: Wed, 4 Nov 2020 09:01:03 -0800 Subject: [PATCH] version that only applies -C flag to even numbered streams, and leave the others as the system default --- src/iperf_client_api.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/iperf_client_api.c b/src/iperf_client_api.c index 59bebd70a..bce7baa68 100644 --- a/src/iperf_client_api.c +++ b/src/iperf_client_api.c @@ -51,12 +51,14 @@ #endif /* TCP_CA_NAME_MAX */ #endif /* HAVE_TCP_CONGESTION */ + int iperf_create_streams(struct iperf_test *test, int sender) { int i, s; #if defined(HAVE_TCP_CONGESTION) int saved_errno; + static int sender_id = 0; /* use this to set congestion control based on even or odd */ #endif /* HAVE_TCP_CONGESTION */ struct iperf_stream *sp; @@ -72,13 +74,19 @@ iperf_create_streams(struct iperf_test *test, int sender) #if defined(HAVE_TCP_CONGESTION) if (test->protocol->id == Ptcp) { if (test->congestion) { - if (setsockopt(s, IPPROTO_TCP, TCP_CONGESTION, test->congestion, strlen(test->congestion)) < 0) { - saved_errno = errno; - close(s); - errno = saved_errno; - i_errno = IESETCONGESTION; - return -1; + if(sender_id % 2 == 0) { /* only do this for even numbered senders */ + /* + printf("setting cong cntrl on stream %d to %s \n",sender_id,test->congestion); + */ + if (setsockopt(s, IPPROTO_TCP, TCP_CONGESTION, test->congestion, strlen(test->congestion)) < 0) { + saved_errno = errno; + close(s); + errno = saved_errno; + i_errno = IESETCONGESTION; + return -1; + } } + sender_id++; } { socklen_t len = TCP_CA_NAME_MAX; @@ -342,13 +350,6 @@ iperf_connect(struct iperf_test *test) return -1; } - // set TCP_NODELAY for lower latency on control messages - int flag = 1; - if (setsockopt(test->ctrl_sck, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int))) { - i_errno = IESETNODELAY; - return -1; - } - if (Nwrite(test->ctrl_sck, test->cookie, COOKIE_SIZE, Ptcp) < 0) { i_errno = IESENDCOOKIE; return -1;