Changed the -I / --ignore flag to -O / --omit, so that we can use the

same flag in bwctl.
This commit is contained in:
Jef Poskanzer 2013-07-05 13:52:19 -07:00
parent 26e392e175
commit 5789260432
8 changed files with 69 additions and 69 deletions

View File

@ -94,7 +94,7 @@ struct iperf_stream
* stream can have a pointer to this
*/
int packet_count;
int ignored_packet_count;
int omitted_packet_count;
double jitter;
double prev_transit;
int outoforder_packets;
@ -135,7 +135,7 @@ struct iperf_test
char *server_hostname; /* -c option */
char *bind_address; /* -B option */
int server_port;
int ignore; /* duration of ignore period (-I flag) */
int omit; /* duration of omit period (-O flag) */
int duration; /* total duration of test (-t flag) */
int ctrl_sck;
@ -161,12 +161,12 @@ struct iperf_test
fd_set write_set; /* set of write sockets */
/* Interval related members */
int ignoring;
int omitting;
double stats_interval;
double reporter_interval;
void (*stats_callback) (struct iperf_test *);
void (*reporter_callback) (struct iperf_test *);
Timer *ignore_timer;
Timer *omit_timer;
Timer *timer;
int done;
Timer *stats_timer;
@ -203,7 +203,7 @@ struct iperf_test
#define uS_TO_NS 1000
#define SEC_TO_US 1000000LL
#define UDP_RATE (1024 * 1024) /* 1 Mbps */
#define IGNORE 1 /* seconds */
#define OMIT 1 /* seconds */
#define DURATION 10 /* seconds */
#define SEC_TO_NS 1000000000LL /* too big for enum/const on some platforms */

View File

@ -104,10 +104,10 @@ set the IP 'type of service'
Use a "zero copy" method of sending data, such as sendfile(2),
instead of the usual write(2).
.TP
.BR -I ", " --ignore " \fIn\fR"
Ignore the first n seconds of the test, to skip past the TCP slow-start
.BR -O ", " --omit " \fIn\fR"
Omit the first n seconds of the test, to skip past the TCP slow-start
period.
The default is 1 second; to not ignore anything, use "-I 0".
The default is 1 second; to not omit anything, use "-O 0".
.SH AUTHORS
Iperf was originally written by Mark Gates and Alex Warshavsky.

View File

@ -87,9 +87,9 @@ iperf_get_control_socket(struct iperf_test *ipt)
}
int
iperf_get_test_ignore(struct iperf_test *ipt)
iperf_get_test_omit(struct iperf_test *ipt)
{
return ipt->ignore;
return ipt->omit;
}
int
@ -185,9 +185,9 @@ iperf_set_control_socket(struct iperf_test *ipt, int ctrl_sck)
}
void
iperf_set_test_ignore(struct iperf_test *ipt, int ignore)
iperf_set_test_omit(struct iperf_test *ipt, int omit)
{
ipt->ignore = ignore;
ipt->omit = omit;
}
void
@ -329,15 +329,15 @@ iperf_on_test_start(struct iperf_test *test)
{
if (test->json_output) {
if (test->settings->bytes)
cJSON_AddItemToObject(test->json_start, "test_start", iperf_json_printf("protocol: %s num_streams: %d blksize: %d ignore: %d bytes: %d", test->protocol->name, (int64_t) test->num_streams, (int64_t) test->settings->blksize, (int64_t) test->ignore, (int64_t) test->settings->bytes));
cJSON_AddItemToObject(test->json_start, "test_start", iperf_json_printf("protocol: %s num_streams: %d blksize: %d omit: %d bytes: %d", test->protocol->name, (int64_t) test->num_streams, (int64_t) test->settings->blksize, (int64_t) test->omit, (int64_t) test->settings->bytes));
else
cJSON_AddItemToObject(test->json_start, "test_start", iperf_json_printf("protocol: %s num_streams: %d blksize: %d ignore: %d duration: %d", test->protocol->name, (int64_t) test->num_streams, (int64_t) test->settings->blksize, (int64_t) test->ignore, (int64_t) test->duration));
cJSON_AddItemToObject(test->json_start, "test_start", iperf_json_printf("protocol: %s num_streams: %d blksize: %d omit: %d duration: %d", test->protocol->name, (int64_t) test->num_streams, (int64_t) test->settings->blksize, (int64_t) test->omit, (int64_t) test->duration));
} else {
if (test->verbose) {
if (test->settings->bytes)
printf(test_start_bytes, test->protocol->name, test->num_streams, test->settings->blksize, test->ignore, test->settings->bytes);
printf(test_start_bytes, test->protocol->name, test->num_streams, test->settings->blksize, test->omit, test->settings->bytes);
else
printf(test_start_time, test->protocol->name, test->num_streams, test->settings->blksize, test->ignore, test->duration);
printf(test_start_time, test->protocol->name, test->num_streams, test->settings->blksize, test->omit, test->duration);
}
}
}
@ -463,7 +463,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
{"tos", required_argument, NULL, 'S'},
{"flowlabel", required_argument, NULL, 'L'},
{"zerocopy", no_argument, NULL, 'Z'},
{"ignore", required_argument, NULL, 'I'},
{"omit", required_argument, NULL, 'O'},
{"help", no_argument, NULL, 'h'},
/* XXX: The following ifdef needs to be split up. linux-congestion is not
@ -480,7 +480,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
blksize = 0;
server_flag = client_flag = rate_flag = 0;
while ((flag = getopt_long(argc, argv, "p:f:i:DVJdvsc:ub:t:n:l:P:Rw:B:M:N46S:L:ZI:h", longopts, NULL)) != -1) {
while ((flag = getopt_long(argc, argv, "p:f:i:DVJdvsc:ub:t:n:l:P:Rw:B:M:N46S:L:ZO:h", longopts, NULL)) != -1) {
switch (flag) {
case 'p':
test->server_port = atoi(optarg);
@ -626,10 +626,10 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
test->zerocopy = 1;
client_flag = 1;
break;
case 'I':
test->ignore = atoi(optarg);
if (test->ignore < 0 || test->ignore > 60) {
i_errno = IEIGNORE;
case 'O':
test->omit = atoi(optarg);
if (test->omit < 0 || test->omit > 60) {
i_errno = IEOMIT;
return -1;
}
client_flag = 1;
@ -899,8 +899,8 @@ send_parameters(struct iperf_test *test)
cJSON_AddTrueToObject(j, "tcp");
else if (test->protocol->id == Pudp)
cJSON_AddTrueToObject(j, "udp");
if (test->ignore)
cJSON_AddIntToObject(j, "ignore", test->ignore);
if (test->omit)
cJSON_AddIntToObject(j, "omit", test->omit);
if (test->duration)
cJSON_AddIntToObject(j, "time", test->duration);
if (test->settings->bytes)
@ -949,8 +949,8 @@ get_parameters(struct iperf_test *test)
set_protocol(test, Ptcp);
if ((j_p = cJSON_GetObjectItem(j, "udp")) != NULL)
set_protocol(test, Pudp);
if ((j_p = cJSON_GetObjectItem(j, "ignore")) != NULL)
test->ignore = j_p->valueint;
if ((j_p = cJSON_GetObjectItem(j, "omit")) != NULL)
test->omit = j_p->valueint;
if ((j_p = cJSON_GetObjectItem(j, "time")) != NULL)
test->duration = j_p->valueint;
if ((j_p = cJSON_GetObjectItem(j, "num")) != NULL)
@ -1263,7 +1263,7 @@ iperf_defaults(struct iperf_test *testp)
{
struct protocol *tcp, *udp;
testp->ignore = IGNORE;
testp->omit = OMIT;
testp->duration = DURATION;
testp->server_port = PORT;
testp->ctrl_sck = -1;
@ -1349,8 +1349,8 @@ iperf_free_test(struct iperf_test *test)
free(test->server_hostname);
free(test->bind_address);
free(test->settings);
if (test->ignore_timer != NULL)
tmr_cancel(test->ignore_timer);
if (test->omit_timer != NULL)
tmr_cancel(test->omit_timer);
if (test->timer != NULL)
tmr_cancel(test->timer);
if (test->stats_timer != NULL)
@ -1384,9 +1384,9 @@ iperf_reset_test(struct iperf_test *test)
SLIST_REMOVE_HEAD(&test->streams, streams);
iperf_free_stream(sp);
}
if (test->ignore_timer != NULL) {
tmr_cancel(test->ignore_timer);
test->ignore_timer = NULL;
if (test->omit_timer != NULL) {
tmr_cancel(test->omit_timer);
test->omit_timer = NULL;
}
if (test->timer != NULL) {
tmr_cancel(test->timer);
@ -1407,7 +1407,7 @@ iperf_reset_test(struct iperf_test *test)
test->sender = 0;
test->sender_has_retransmits = 0;
set_protocol(test, Ptcp);
test->ignore = IGNORE;
test->omit = OMIT;
test->duration = DURATION;
test->state = 0;
test->server_hostname = NULL;
@ -1433,7 +1433,7 @@ iperf_reset_test(struct iperf_test *test)
}
/* Reset all of a test's stats back to zero. Called when the ignoring
/* Reset all of a test's stats back to zero. Called when the omitting
** period is over.
*/
void
@ -1446,7 +1446,7 @@ iperf_reset_stats(struct iperf_test *test)
test->bytes_sent = 0;
gettimeofday(&now, NULL);
SLIST_FOREACH(sp, &test->streams, streams) {
sp->ignored_packet_count = sp->packet_count;
sp->omitted_packet_count = sp->packet_count;
sp->jitter = 0;
sp->outoforder_packets = 0;
sp->cnt_error = 0;
@ -1633,7 +1633,7 @@ iperf_print_results(struct iperf_test *test)
if (test->sender_has_retransmits)
total_retransmits += sp->result->retransmits;
} else {
total_packets += (sp->packet_count - sp->ignored_packet_count);
total_packets += (sp->packet_count - sp->omitted_packet_count);
lost_packets += sp->cnt_error;
avg_jitter += sp->jitter;
}
@ -1657,13 +1657,13 @@ iperf_print_results(struct iperf_test *test)
printf(report_bw_format, sp->socket, start_time, end_time, ubuf, nbuf);
}
} else {
out_of_order_percent = 100.0 * sp->cnt_error / (sp->packet_count - sp->ignored_packet_count);
out_of_order_percent = 100.0 * sp->cnt_error / (sp->packet_count - sp->omitted_packet_count);
if (test->json_output)
cJSON_AddItemToObject(json_summary_stream, "udp", iperf_json_printf("socket: %d start: %f end: %f seconds: %f bytes: %d bits_per_second: %f jitter_ms: %f outoforder: %d packets: %d percent: %f", (int64_t) sp->socket, (double) start_time, (double) end_time, (double) end_time, (int64_t) bytes_sent, bandwidth * 8, (double) sp->jitter * 1000.0, (int64_t) sp->cnt_error, (int64_t) (sp->packet_count - sp->ignored_packet_count), out_of_order_percent));
cJSON_AddItemToObject(json_summary_stream, "udp", iperf_json_printf("socket: %d start: %f end: %f seconds: %f bytes: %d bits_per_second: %f jitter_ms: %f outoforder: %d packets: %d percent: %f", (int64_t) sp->socket, (double) start_time, (double) end_time, (double) end_time, (int64_t) bytes_sent, bandwidth * 8, (double) sp->jitter * 1000.0, (int64_t) sp->cnt_error, (int64_t) (sp->packet_count - sp->omitted_packet_count), out_of_order_percent));
else {
printf(report_bw_udp_format, sp->socket, start_time, end_time, ubuf, nbuf, sp->jitter * 1000.0, sp->cnt_error, (sp->packet_count - sp->ignored_packet_count), out_of_order_percent);
printf(report_bw_udp_format, sp->socket, start_time, end_time, ubuf, nbuf, sp->jitter * 1000.0, sp->cnt_error, (sp->packet_count - sp->omitted_packet_count), out_of_order_percent);
if (test->role == 'c')
printf(report_datagrams, sp->socket, (sp->packet_count - sp->ignored_packet_count));
printf(report_datagrams, sp->socket, (sp->packet_count - sp->omitted_packet_count));
if (sp->outoforder_packets > 0)
printf(report_sum_outoforder, start_time, end_time, sp->cnt_error);
}

View File

@ -45,7 +45,7 @@ struct iperf_stream;
/* Getter routines for some fields inside iperf_test. */
int iperf_get_control_socket( struct iperf_test* ipt );
int iperf_get_test_ignore( struct iperf_test* ipt );
int iperf_get_test_omit( struct iperf_test* ipt );
int iperf_get_test_duration( struct iperf_test* ipt );
char iperf_get_test_role( struct iperf_test* ipt );
int iperf_get_test_blksize( struct iperf_test* ipt );
@ -63,7 +63,7 @@ int iperf_get_test_may_use_sigalrm( struct iperf_test* ipt );
/* Setter routines for some fields inside iperf_test. */
void iperf_set_control_socket( struct iperf_test* ipt, int ctrl_sck );
void iperf_set_test_ignore( struct iperf_test* ipt, int ignore );
void iperf_set_test_omit( struct iperf_test* ipt, int omit );
void iperf_set_test_duration( struct iperf_test* ipt, int duration );
void iperf_set_test_reporter_interval( struct iperf_test* ipt, double reporter_interval );
void iperf_set_test_stats_interval( struct iperf_test* ipt, double stats_interval );
@ -223,7 +223,7 @@ enum {
IEINTERVAL = 9, // Report interval too large. Maxumum value = %dMAX_INTERVAL
IEMSS = 10, // MSS too large. Maximum value = %dMAX_MSS
IENOSENDFILE = 11, // This OS does not support sendfile
IEIGNORE = 12, // Bogus value for --ignore
IEOMIT = 12, // Bogus value for --omit
IEUNIMP = 13, // Not implemented yet
/* Test errors */
IENEWTEST = 100, // Unable to create a new test (check perror)

View File

@ -84,16 +84,16 @@ reporter_timer_proc(TimerClientData client_data, struct timeval *nowP)
}
static void
client_ignore_timer_proc(TimerClientData client_data, struct timeval *nowP)
client_omit_timer_proc(TimerClientData client_data, struct timeval *nowP)
{
struct iperf_test *test = client_data.p;
TimerClientData cd;
test->ignore_timer = NULL;
test->ignoring = 0;
test->omit_timer = NULL;
test->omitting = 0;
iperf_reset_stats(test);
if (test->verbose && !test->json_output)
printf("Finished ignore period, starting real test\n");
printf("Finished omit period, starting real test\n");
/* Create timers. */
if (test->settings->bytes == 0) {
@ -124,7 +124,7 @@ client_ignore_timer_proc(TimerClientData client_data, struct timeval *nowP)
}
static int
create_client_ignore_timer(struct iperf_test * test)
create_client_omit_timer(struct iperf_test * test)
{
struct timeval now;
TimerClientData cd;
@ -133,10 +133,10 @@ create_client_ignore_timer(struct iperf_test * test)
i_errno = IEINITTEST;
return -1;
}
test->ignoring = 1;
test->omitting = 1;
cd.p = test;
test->ignore_timer = tmr_create(&now, client_ignore_timer_proc, cd, test->ignore * SEC_TO_US, 0);
if (test->ignore_timer == NULL) {
test->omit_timer = tmr_create(&now, client_omit_timer_proc, cd, test->omit * SEC_TO_US, 0);
if (test->omit_timer == NULL) {
i_errno = IEINITTEST;
return -1;
}
@ -210,7 +210,7 @@ iperf_handle_message_client(struct iperf_test *test)
case TEST_START:
if (iperf_init_test(test) < 0)
return -1;
if (create_client_ignore_timer(test) < 0)
if (create_client_omit_timer(test) < 0)
return -1;
if (create_send_timers(test) < 0)
return -1;
@ -374,7 +374,7 @@ iperf_run_client(struct iperf_test * test)
if (test->state == TEST_RUNNING) {
/* Is this our first time really running? */
if (startup && ! test->ignoring) {
if (startup && ! test->omitting) {
startup = 0;
/* Can we switch to SIGALRM mode? There are a bunch of
** cases where either it won't work or it's ill-advised.
@ -415,7 +415,7 @@ iperf_run_client(struct iperf_test * test)
}
/* Is the test done yet? */
if (test->ignoring)
if (test->omitting)
continue; /* not done */
if (test->settings->bytes == 0) {
if (!test->done)

View File

@ -99,8 +99,8 @@ iperf_strerror(int i_errno)
case IENOSENDFILE:
snprintf(errstr, len, "this OS does not support sendfile");
break;
case IEIGNORE:
snprintf(errstr, len, "bogus value for --ignore");
case IEOMIT:
snprintf(errstr, len, "bogus value for --omit");
break;
case IEUNIMP:
snprintf(errstr, len, "an option you are trying to set is not implemented yet");

View File

@ -242,7 +242,7 @@ iperf_test_reset(struct iperf_test *test)
test->role = 's';
set_protocol(test, Ptcp);
test->ignore = IGNORE;
test->omit = OMIT;
test->duration = DURATION;
test->state = 0;
test->server_hostname = NULL;
@ -271,19 +271,19 @@ iperf_test_reset(struct iperf_test *test)
}
static void
server_ignore_timer_proc(TimerClientData client_data, struct timeval *nowP)
server_omit_timer_proc(TimerClientData client_data, struct timeval *nowP)
{
struct iperf_test *test = client_data.p;
test->ignore_timer = NULL;
test->ignoring = 0;
test->omit_timer = NULL;
test->omitting = 0;
iperf_reset_stats(test);
if (test->verbose && !test->json_output)
printf("Finished ignore period, starting real test\n");
printf("Finished omit period, starting real test\n");
}
static int
create_server_ignore_timer(struct iperf_test * test)
create_server_omit_timer(struct iperf_test * test)
{
struct timeval now;
TimerClientData cd;
@ -292,10 +292,10 @@ create_server_ignore_timer(struct iperf_test * test)
i_errno = IEINITTEST;
return -1;
}
test->ignoring = 1;
test->omitting = 1;
cd.p = test;
test->ignore_timer = tmr_create(&now, server_ignore_timer_proc, cd, test->ignore * SEC_TO_US, 0);
if (test->ignore_timer == NULL) {
test->omit_timer = tmr_create(&now, server_omit_timer_proc, cd, test->omit * SEC_TO_US, 0);
if (test->omit_timer == NULL) {
i_errno = IEINITTEST;
return -1;
}
@ -424,7 +424,7 @@ iperf_run_server(struct iperf_test *test)
cleanup_server(test);
return -1;
}
if (create_server_ignore_timer(test) < 0) {
if (create_server_omit_timer(test) < 0) {
cleanup_server(test);
return -1;
}

View File

@ -99,7 +99,7 @@ const char usage_longstr[] = "Usage: iperf [-s|-c host] [options]\n"
" -S, --tos N set the IP 'type of service'\n"
/* " -L, --flowlabel N set the IPv6 'flow label'\n" */
" -Z, --zerocopy use a 'zero copy' method of sending data\n"
" -I, --ignore N ignore the first n seconds\n"
" -O, --omit N omit the first n seconds\n"
#ifdef NOT_YET_SUPPORTED /* still working on these */
" -D, --daemon run the server as a daemon\n"
@ -164,10 +164,10 @@ const char wait_server_threads[] =
"Waiting for server threads to complete. Interrupt again to force quit.\n";
const char test_start_time[] =
"Starting Test: protocol: %s, %d streams, %d byte blocks, ignoring %d seconds, %d second test\n";
"Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %d second test\n";
const char test_start_bytes[] =
"Starting Test: protocol: %s, %d streams, %d byte blocks, ignoring %d seconds, %llu bytes to send\n";
"Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %llu bytes to send\n";
/* -------------------------------------------------------------------