Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/iperf.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ struct iperf_settings
int domain; /* AF_INET or AF_INET6 */
int socket_bufsize; /* window size for TCP */
int blksize; /* size of read/writes (-l) */
int blksize_set; /* nonzero iff user explicitly set blksize (-l or API) */
iperf_size_t rate; /* target data rate for application pacing*/
iperf_size_t bitrate_limit; /* server's maximum allowed total data rate for all streams*/
double bitrate_limit_interval; /* interval for averaging total data rate */
Expand Down
8 changes: 7 additions & 1 deletion src/iperf3.1
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,13 @@ options are mutually exclusive.
.TP
.BR -l ", " --length " \fIn\fR[KMGT]"
Set the length of the buffer to read or write. For TCP tests, the
default value is 128KB.
default value is 128KB; when
.B -l
is not specified, iperf3 rounds this default down to the largest
multiple of the MSS (taken from
.B -M
if given, otherwise from the control connection) so that each write
produces an integer number of full-sized segments.
In the case of UDP, iperf3 tries to dynamically determine a reasonable
sending size based on the path MTU; if that cannot be determined it
uses 1460 bytes as a sending size.
Expand Down
3 changes: 3 additions & 0 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ void
iperf_set_test_blksize(struct iperf_test *ipt, int blksize)
{
ipt->settings->blksize = blksize;
ipt->settings->blksize_set = 1;
}

void
Expand Down Expand Up @@ -1414,6 +1415,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
return -1;
}
// NOTE: blksize is unsigned, can't be less than 0
test->settings->blksize_set = 1;
client_flag = 1;
break;
case 'P':
Expand Down Expand Up @@ -3768,6 +3770,7 @@ iperf_reset_test(struct iperf_test *test)
test->num_streams = 1;
test->settings->socket_bufsize = 0;
test->settings->blksize = DEFAULT_TCP_BLKSIZE;
test->settings->blksize_set = 0;
test->settings->rate = 0;
test->settings->fqrate = 0;
test->settings->burst = 0;
Expand Down
21 changes: 21 additions & 0 deletions src/iperf_client_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,27 @@ iperf_connect(struct iperf_test *test)
}
}

/*
* For TCP, when the user did not pass -l, round the default block size
* down to the largest multiple of the MSS so that each write decomposes
* into integer-many full-sized wire segments after TSO/GSO splits it.
* Prefer a user-specified -M value (settings->mss); otherwise fall back
* to the kernel-reported control-socket MSS.
*/
if (test->protocol->id == Ptcp && !test->settings->blksize_set) {
int mss = test->settings->mss ? test->settings->mss : test->ctrl_sck_mss;
if (mss > 0) {
int aligned = (DEFAULT_TCP_BLKSIZE / mss) * mss;
if (aligned < mss)
aligned = mss;
test->settings->blksize = aligned;
if (test->verbose) {
printf("Setting TCP block size to %d (MSS %d)\n",
test->settings->blksize, mss);
}
}
}

return 0;
}

Expand Down