Skip to content

Commit

Permalink
Bitrate throttling when burst is specified (#1090)
Browse files Browse the repository at this point in the history
When the -b option specifies a burst value, throttling the bitrate does not work. This is because iperf_check_throttle() does not perform the check when burst value was defined.

This change removes the dependency of iperf_check_throttle() on the burst value and moves that check to the caller of that function. (Except for the call by send_timer_proc() which does not seem to be related to the change.)
  • Loading branch information
davidBar-On authored Dec 4, 2020
1 parent 50315e7 commit 91c33dc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ iperf_check_throttle(struct iperf_stream *sp, struct iperf_time *nowP)
double seconds;
uint64_t bits_per_second;

if (sp->test->done || sp->test->settings->rate == 0 || sp->test->settings->burst != 0)
if (sp->test->done || sp->test->settings->rate == 0)
return;
iperf_time_diff(&sp->result->start_time_fixed, nowP, &temp_time);
seconds = iperf_time_in_secs(&temp_time);
Expand Down Expand Up @@ -1598,6 +1598,7 @@ iperf_send(struct iperf_test *test, fd_set *write_setP)
register int multisend, r, streams_active;
register struct iperf_stream *sp;
struct iperf_time now;
int no_throttle_check;

/* Can we do multisend mode? */
if (test->settings->burst != 0)
Expand All @@ -1607,8 +1608,11 @@ iperf_send(struct iperf_test *test, fd_set *write_setP)
else
multisend = 1; /* nope */

/* Should bitrate throttle be checked for every send */
no_throttle_check = test->settings->rate != 0 && test->settings->burst == 0;

for (; multisend > 0; --multisend) {
if (test->settings->rate != 0 && test->settings->burst == 0)
if (no_throttle_check)
iperf_time_now(&now);
streams_active = 0;
SLIST_FOREACH(sp, &test->streams, streams) {
Expand All @@ -1623,7 +1627,8 @@ iperf_send(struct iperf_test *test, fd_set *write_setP)
streams_active = 1;
test->bytes_sent += r;
++test->blocks_sent;
iperf_check_throttle(sp, &now);
if (no_throttle_check)
iperf_check_throttle(sp, &now);
if (multisend > 1 && test->settings->bytes != 0 && test->bytes_sent >= test->settings->bytes)
break;
if (multisend > 1 && test->settings->blocks != 0 && test->blocks_sent >= test->settings->blocks)
Expand All @@ -1633,7 +1638,7 @@ iperf_send(struct iperf_test *test, fd_set *write_setP)
if (!streams_active)
break;
}
if (test->settings->burst != 0) {
if (!no_throttle_check) { /* Throttle check if was not checked for each send */
iperf_time_now(&now);
SLIST_FOREACH(sp, &test->streams, streams)
if (sp->sender)
Expand Down

0 comments on commit 91c33dc

Please sign in to comment.