1
1

Add --repeating-payload option to the client side (#726)

This option simulates payload in iperf2, which is just repetitive pattern
(ASCII '0..9' repeating), as opposed to iperf3 where payload is random.
It might help in testing and reveal problems in networking gear with hardware
compression (including WiFi access points), where iperf2 and iperf3 perform
differently, just based on payload entropy.
Этот коммит содержится в:
Phil Levchenko 2018-04-20 17:25:24 +03:00 коммит произвёл Bruce A. Mah
родитель 6332d84016
Коммит cbea72b6ee
7 изменённых файлов: 47 добавлений и 3 удалений

Просмотреть файл

@ -273,6 +273,7 @@ struct iperf_test
int udp_counters_64bit; /* --use-64-bit-udp-counters */ int udp_counters_64bit; /* --use-64-bit-udp-counters */
int forceflush; /* --forceflush - flushing output at every interval */ int forceflush; /* --forceflush - flushing output at every interval */
int multisend; int multisend;
int repeating_payload; /* --repeating-payload */
char *json_output_string; /* rendered JSON output if json_output is set */ char *json_output_string; /* rendered JSON output if json_output is set */
/* Select related parameters */ /* Select related parameters */

Просмотреть файл

@ -350,6 +350,13 @@ If the client is run with \fB--json\fR, the server output is included
in a JSON object; otherwise it is appended at the bottom of the in a JSON object; otherwise it is appended at the bottom of the
human-readable output. human-readable output.
.TP .TP
.BR --repeating-payload
Use repeating pattern in payload, instead of random bytes.
The same payload is used in iperf2 (ASCII '0..9' repeating).
It might help to test and reveal problems in networking gear with hardware
compression (including some WiFi access points), where iperf2 and iperf3
perform differently, just based on payload entropy.
.TP
.BR --username " \fIusername\fR" .BR --username " \fIusername\fR"
username to use for authentication to the iperf server (if built with username to use for authentication to the iperf server (if built with
OpenSSL support). OpenSSL support).

Просмотреть файл

@ -673,6 +673,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
{"zerocopy", no_argument, NULL, 'Z'}, {"zerocopy", no_argument, NULL, 'Z'},
{"omit", required_argument, NULL, 'O'}, {"omit", required_argument, NULL, 'O'},
{"file", required_argument, NULL, 'F'}, {"file", required_argument, NULL, 'F'},
{"repeating-payload", no_argument, NULL, OPT_REPEATING_PAYLOAD},
#if defined(HAVE_CPU_AFFINITY) #if defined(HAVE_CPU_AFFINITY)
{"affinity", required_argument, NULL, 'A'}, {"affinity", required_argument, NULL, 'A'},
#endif /* HAVE_CPU_AFFINITY */ #endif /* HAVE_CPU_AFFINITY */
@ -951,6 +952,10 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
test->zerocopy = 1; test->zerocopy = 1;
client_flag = 1; client_flag = 1;
break; break;
case OPT_REPEATING_PAYLOAD:
test->repeating_payload = 1;
client_flag = 1;
break;
case 'O': case 'O':
test->omit = atoi(optarg); test->omit = atoi(optarg);
if (test->omit < 0 || test->omit > 60) { if (test->omit < 0 || test->omit > 60) {
@ -3175,6 +3180,7 @@ struct iperf_stream *
iperf_new_stream(struct iperf_test *test, int s) iperf_new_stream(struct iperf_test *test, int s)
{ {
struct iperf_stream *sp; struct iperf_stream *sp;
int ret = 0;
char template[1024]; char template[1024];
if (test->tmp_template) { if (test->tmp_template) {
@ -3265,8 +3271,12 @@ iperf_new_stream(struct iperf_test *test, int s)
sp->diskfile_fd = -1; sp->diskfile_fd = -1;
/* Initialize stream */ /* Initialize stream */
if ((readentropy(sp->buffer, test->settings->blksize) < 0) || if (test->repeating_payload)
(iperf_init_stream(sp, test) < 0)) { fill_with_repeating_pattern(sp->buffer, test->settings->blksize);
else
ret = readentropy(sp->buffer, test->settings->blksize);
if ((ret < 0) || (iperf_init_stream(sp, test) < 0)) {
close(sp->buffer_fd); close(sp->buffer_fd);
munmap(sp->buffer, sp->test->settings->blksize); munmap(sp->buffer, sp->test->settings->blksize);
free(sp->result); free(sp->result);

Просмотреть файл

@ -68,6 +68,7 @@ struct iperf_stream;
#define OPT_SERVER_AUTHORIZED_USERS 15 #define OPT_SERVER_AUTHORIZED_USERS 15
#define OPT_PACING_TIMER 16 #define OPT_PACING_TIMER 16
#define OPT_CONNECT_TIMEOUT 17 #define OPT_CONNECT_TIMEOUT 17
#define OPT_REPEATING_PAYLOAD 18
/* states */ /* states */
#define TEST_START 1 #define TEST_START 1

Просмотреть файл

@ -171,6 +171,8 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
" -T, --title str prefix every output line with this string\n" " -T, --title str prefix every output line with this string\n"
" --get-server-output get results from server\n" " --get-server-output get results from server\n"
" --udp-counters-64bit use 64-bit counters in UDP test packets\n" " --udp-counters-64bit use 64-bit counters in UDP test packets\n"
" --repeating-payload use repeating pattern in payload, instead of\n"
" randomized payload (like in iperf2)\n"
#if defined(HAVE_SSL) #if defined(HAVE_SSL)
" --username username for authentication\n" " --username username for authentication\n"
" --rsa-public-key-path path to the RSA public key used to encrypt\n" " --rsa-public-key-path path to the RSA public key used to encrypt\n"

Просмотреть файл

@ -79,6 +79,27 @@ int readentropy(void *out, size_t outsize)
} }
/*
* Fills buffer with repeating pattern (similar to pattern that used in iperf2)
*/
void fill_with_repeating_pattern(void *out, size_t outsize)
{
size_t i;
int counter = 0;
char *buf = (char *)out;
if (!outsize) return;
for (i = 0; i < outsize; i++) {
buf[i] = (char)('0' + counter);
if (counter >= 9)
counter = 0;
else
counter++;
}
}
/* make_cookie /* make_cookie
* *
* Generate and return a cookie string * Generate and return a cookie string

Просмотреть файл

@ -34,6 +34,8 @@
int readentropy(void *out, size_t outsize); int readentropy(void *out, size_t outsize);
void fill_with_repeating_pattern(void *out, size_t outsize);
void make_cookie(char *); void make_cookie(char *);
int is_closed(int); int is_closed(int);