Compare commits

...

9 Commits

2 changed files with 34 additions and 13 deletions

View File

@ -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,30 @@ 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) { /* CC testing hack: 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;
}
}
#ifdef ADD_SLEEP /* did not seem to really matter, so removing for now */
else {
/* for CC hack: sleep N seconds to give even numbered streams (eg: cubic) a head start */
int sleep_time = 1;
/*
printf("default cong cntrl on stream %d \n",sender_id);
printf("sleeping for %d seconds to let stream %d have a head start \n",sleep_time, sender_id-1);
*/
sleep(sleep_time);
}
#endif
sender_id++;
}
{
socklen_t len = TCP_CA_NAME_MAX;
@ -348,13 +367,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;

View File

@ -375,6 +375,7 @@ iperf_tcp_connect(struct iperf_test *test)
socklen_t optlen;
int saved_errno;
int rcvbuf_actual, sndbuf_actual;
useconds_t sleepTime;
if (test->bind_address) {
memset(&hints, 0, sizeof(hints));
@ -397,6 +398,14 @@ iperf_tcp_connect(struct iperf_test *test)
return -1;
}
/* for CC hack, sleep for a random number of usec between 0 and 500 ms */
/*
srand(time(0));
sleepTime = (useconds_t)(((rand() % 5) + 1) * 1000);
printf("DEBUG: sleeping for %d us \n", sleepTime);
usleep(sleepTime);
*/
if ((s = socket(server_res->ai_family, SOCK_STREAM, 0)) < 0) {
if (test->bind_address)
freeaddrinfo(local_res);