Skip to content

Commit

Permalink
version that only applies -C flag to even numbered streams, and leave…
Browse files Browse the repository at this point in the history
… the others as the system default
  • Loading branch information
bltierney committed Nov 4, 2020
1 parent 97a1d11 commit c2fcd0a
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/iperf_client_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c2fcd0a

Please sign in to comment.