aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce A. Mah <bmah@es.net>2014-11-12 13:58:23 -0800
committerBruce A. Mah <bmah@es.net>2014-11-12 13:58:23 -0800
commit72ac83e7f27f5956f1822382a299c0e75a65c9aa (patch)
tree8bcf0f938306cc3fd89ed54206675582531d5539
parentd65986030a0f122623bae1ae197527438b7fbcd1 (diff)
downloadiperf3-72ac83e7f27f5956f1822382a299c0e75a65c9aa.tar.gz
Make UDP tests honor the -w option for setting the socket buffer
size. This appears to be necessary on some long, high-bandwidth paths to get sane results, either by reducing packet loss or by somehow allowing the sending host of a test to go faster. Fixes #219.
-rw-r--r--src/iperf3.12
-rw-r--r--src/iperf_locale.c2
-rw-r--r--src/iperf_udp.c32
3 files changed, 34 insertions, 2 deletions
diff --git a/src/iperf3.1 b/src/iperf3.1
index a9fe8e9..a7e67e6 100644
--- a/src/iperf3.1
+++ b/src/iperf3.1
@@ -124,7 +124,7 @@ number of parallel client streams to run
run in reverse mode (server sends, client receives)
.TP
.BR -w ", " --window " \fIn\fR[KM]"
-TCP window size / socket buffer size (this gets sent to the server and used on that side too)
+window size / socket buffer size (this gets sent to the server and used on that side too)
.TP
.BR -M ", " --set-mss " \fIn\fR"
set TCP maximum segment size (MTU - 40 bytes)
diff --git a/src/iperf_locale.c b/src/iperf_locale.c
index 91bacc4..354906f 100644
--- a/src/iperf_locale.c
+++ b/src/iperf_locale.c
@@ -132,7 +132,7 @@ const char usage_longstr[] = "Usage: iperf [-s|-c host] [options]\n"
" --cport <port> bind to a specific client port (TCP and UDP, default: ephemeral port)\n"
" -P, --parallel # number of parallel client streams to run\n"
" -R, --reverse run in reverse mode (server sends, client receives)\n"
- " -w, --window #[KMG] TCP window size (socket buffer size)\n"
+ " -w, --window #[KMG] set window size / socket buffer size\n"
#if defined(HAVE_TCP_CONGESTION)
" -C, --congestion <algo> set TCP congestion control algorithm (Linux and FreeBSD only)\n"
#endif /* HAVE_TCP_CONGESTION */
diff --git a/src/iperf_udp.c b/src/iperf_udp.c
index 0f55226..8d32dbe 100644
--- a/src/iperf_udp.c
+++ b/src/iperf_udp.c
@@ -229,6 +229,22 @@ iperf_udp_accept(struct iperf_test *test)
}
/*
+ * Set socket buffer size if requested. Do this for both sending and
+ * receiving so that we can cover both normal and --reverse operation.
+ */
+ int opt;
+ if ((opt = test->settings->socket_bufsize)) {
+ if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(opt)) < 0) {
+ i_errno = IESETBUF;
+ return -1;
+ }
+ if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)) < 0) {
+ i_errno = IESETBUF;
+ return -1;
+ }
+ }
+
+ /*
* Create a new "listening" socket to replace the one we were using before.
*/
test->prot_listener = netannounce(test->settings->domain, Pudp, test->bind_address, test->server_port);
@@ -292,6 +308,22 @@ iperf_udp_connect(struct iperf_test *test)
}
/*
+ * Set socket buffer size if requested. Do this for both sending and
+ * receiving so that we can cover both normal and --reverse operation.
+ */
+ int opt;
+ if ((opt = test->settings->socket_bufsize)) {
+ if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(opt)) < 0) {
+ i_errno = IESETBUF;
+ return -1;
+ }
+ if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)) < 0) {
+ i_errno = IESETBUF;
+ return -1;
+ }
+ }
+
+ /*
* Write a datagram to the UDP stream to let the server know we're here.
* The server learns our address by obtaining its peer's address.
*/