Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitrate throttling when burst is specified #1090

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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