aboutsummaryrefslogtreecommitdiff
path: root/src/iperf_tcp.c
diff options
context:
space:
mode:
authorsethdelliott <devnull@localhost>2010-08-02 22:45:53 +0000
committersethdelliott <devnull@localhost>2010-08-02 22:45:53 +0000
commit0bd8d9da6e9572477e6b8327020dfdd6f6af0d50 (patch)
tree1e60f9b38ad3db8a134bbb93c6da77c455a2e9b6 /src/iperf_tcp.c
parent4559e27a019c117c6c514093ef14c3f2facdf905 (diff)
downloadiperf3-0bd8d9da6e9572477e6b8327020dfdd6f6af0d50.tar.gz
Added ability to set TCP window size (-w). Modified code to keep test structures intact after a test is complete. Improved interval timer granularity. Fixed a bug with timeval_diff.
Diffstat (limited to 'src/iperf_tcp.c')
-rw-r--r--src/iperf_tcp.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c
index 448340f..a71e047 100644
--- a/src/iperf_tcp.c
+++ b/src/iperf_tcp.c
@@ -119,7 +119,7 @@ iperf_tcp_listen(struct iperf_test *test)
char portstr[6];
s = test->listener;
- if (test->no_delay || test->settings->mss) {
+ if (test->no_delay || test->settings->mss || test->settings->socket_bufsize) {
FD_CLR(s, &test->read_set);
close(s);
if ((s = socket(test->settings->domain, SOCK_STREAM, 0)) < 0) {
@@ -142,6 +142,16 @@ iperf_tcp_listen(struct iperf_test *test)
}
printf(" TCP MSS: %d\n", 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);
+ }
+ }
opt = 1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
i_errno = IEREUSEADDR;
@@ -213,7 +223,7 @@ iperf_tcp_connect(struct iperf_test *test)
freeaddrinfo(res);
}
- /* Set TCP options */
+ /* Set socket options */
if (test->no_delay) {
opt = 1;
if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt)) < 0) {
@@ -227,6 +237,16 @@ iperf_tcp_connect(struct iperf_test *test)
return (-1);
}
}
+ 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);
+ }
+ }
memset(&hints, 0, sizeof(hints));
hints.ai_family = test->settings->domain;