Skip to content

Commit

Permalink
Add --imix CLI option
Browse files Browse the repository at this point in the history
Will be used to switch on imix traffic pattern.
  • Loading branch information
danobi committed Sep 15, 2023
1 parent 5296121 commit 0e7c2a5
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/iperf.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ struct iperf_settings
int idle_timeout; /* server idle time timeout */
unsigned int snd_timeout; /* Timeout for sending tcp messages in active mode, in us */
struct iperf_time rcv_timeout; /* Timeout for receiving messages in active mode, in us */
int imix; /* Whether to send internet mix traffic */
};

struct iperf_test;
Expand Down
4 changes: 4 additions & 0 deletions src/iperf3.1
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ or high-bitrate UDP tests. Both client and server need to be running
at least version 3.1 for this option to work. It may become the
default behavior at some point in the future.
.TP
.BR --imix
Use internet mix traffic pattern instead of maximum possible payload size.
This is useful for testing middleboxes.
.TP
.BR --repeating-payload
Use repeating pattern in payload, instead of random bytes.
The same payload is used in iperf2 (ASCII '0..9' repeating).
Expand Down
22 changes: 22 additions & 0 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
{"bitrate", required_argument, NULL, 'b'},
{"bandwidth", required_argument, NULL, 'b'},
{"server-bitrate-limit", required_argument, NULL, OPT_SERVER_BITRATE_LIMIT},
{"imix", no_argument, NULL, OPT_IMIX},
{"time", required_argument, NULL, 't'},
{"bytes", required_argument, NULL, 'n'},
{"blockcount", required_argument, NULL, 'k'},
Expand Down Expand Up @@ -1618,6 +1619,9 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
test->settings->connect_timeout = unit_atoi(optarg);
client_flag = 1;
break;
case OPT_IMIX:
test->settings->imix = 1;
break;
case 'h':
usage_long(stdout);
exit(0);
Expand Down Expand Up @@ -1766,6 +1770,24 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
return -1;
}

/* Using 64-bit counters goes over 40 byte (incl. ip and udp hdr) pkt size class */
if (test->udp_counters_64bit && test->settings->imix) {
i_errno = IEUDPCOUNTERIMIX;
return -1;
}

/* IPv6 header is too big to fit into smallest pkt size class */
if (test->settings->imix && test->settings->domain != AF_INET) {
i_errno = IEUDPINET6IMIX;
return -1;
}

/* Cannot easily control packet size on the wire unless it's UDP */
if (test->settings->imix && test->protocol->id != Pudp) {
i_errno = IEIMIXNOTUDP;
return -1;
}

/* For subsequent calls to getopt */
#ifdef __APPLE__
optreset = 1;
Expand Down
4 changes: 4 additions & 0 deletions src/iperf_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ typedef uint64_t iperf_size_t;
#define OPT_DONT_FRAGMENT 26
#define OPT_RCV_TIMEOUT 27
#define OPT_SND_TIMEOUT 28
#define OPT_IMIX 29

/* states */
#define TEST_START 1
Expand Down Expand Up @@ -406,6 +407,9 @@ enum {
IERVRSONLYRCVTIMEOUT = 32, // Client receive timeout is valid only in reverse mode
IESNDTIMEOUT = 33, // Illegal message send timeout
IEUDPFILETRANSFER = 34, // Cannot transfer file using UDP
IEUDPCOUNTERIMIX = 35, // 64 bit counter too big for imix
IEUDPINET6IMIX = 36, // IPv6 header too big for imix
IEIMIXNOTUDP = 37, // IMIX mode cannot be used for non UDP
/* Test errors */
IENEWTEST = 100, // Unable to create a new test (check perror)
IEINITTEST = 101, // Test initialization failed (check perror)
Expand Down
9 changes: 9 additions & 0 deletions src/iperf_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,15 @@ iperf_strerror(int int_errno)
case IEUDPFILETRANSFER:
snprintf(errstr, len, "cannot transfer file using UDP");
break;
case IEUDPCOUNTERIMIX:
snprintf(errstr, len, "64 bit counter makes small imix packet too large");
break;
case IEUDPINET6IMIX:
snprintf(errstr, len, "ipv6 header makes small imix packet too large");
break;
case IEIMIXNOTUDP:
snprintf(errstr, len, "imix can only be used for udp");
break;
case IERVRSONLYRCVTIMEOUT:
snprintf(errstr, len, "client receive timeout is valid only in receiving mode");
perr = 1;
Expand Down
1 change: 1 addition & 0 deletions src/iperf_locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
" --extra-data str data string to include in client and server JSON\n"
" --get-server-output get results from server\n"
" --udp-counters-64bit use 64-bit counters in UDP test packets\n"
" --imix use IMIX traffic pattern\n"
" --repeating-payload use repeating pattern in payload, instead of\n"
" randomized payload (like in iperf2)\n"
#if defined(HAVE_DONT_FRAGMENT)
Expand Down

0 comments on commit 0e7c2a5

Please sign in to comment.