diff --git a/src/iperf.h b/src/iperf.h index 6e05904..f5f33d7 100644 --- a/src/iperf.h +++ b/src/iperf.h @@ -219,7 +219,8 @@ struct iperf_test #define MB (1024 * 1024) #define MAX_TCP_BUFFER (512 * MB) #define MAX_BLOCKSIZE MB -#define MAX_INTERVAL 60 +#define MIN_INTERVAL 0.1 +#define MAX_INTERVAL 60.0 #define MAX_TIME 3600 #define MAX_MSS (9 * 1024) #define MAX_STREAMS 128 diff --git a/src/iperf_api.c b/src/iperf_api.c index 292648f..912ab96 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -551,7 +551,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) /* XXX: could potentially want separate stat collection and reporting intervals, but just set them to be the same for now */ test->stats_interval = test->reporter_interval = atof(optarg); - if (test->stats_interval > MAX_INTERVAL) { + if ((test->stats_interval < MIN_INTERVAL || test->stats_interval > MAX_INTERVAL) && test->stats_interval != 0) { i_errno = IEINTERVAL; return -1; } @@ -1367,8 +1367,7 @@ iperf_defaults(struct iperf_test *testp) testp->stats_callback = iperf_stats_callback; testp->reporter_callback = iperf_reporter_callback; - testp->stats_interval = 0; - testp->reporter_interval = 0; + testp->stats_interval = testp->reporter_interval = 1; testp->num_streams = 1; testp->settings->domain = AF_UNSPEC; diff --git a/src/iperf_api.h b/src/iperf_api.h index 131978f..b45c1e3 100644 --- a/src/iperf_api.h +++ b/src/iperf_api.h @@ -229,7 +229,7 @@ enum { IENUMSTREAMS = 6, // Number of parallel streams too large. Maximum value = %dMAX_STREAMS IEBLOCKSIZE = 7, // Block size too large. Maximum value = %dMAX_BLOCKSIZE IEBUFSIZE = 8, // Socket buffer size too large. Maximum value = %dMAX_TCP_BUFFER - IEINTERVAL = 9, // Report interval too large. Maxumum value = %dMAX_INTERVAL + IEINTERVAL = 9, // Invalid report interval (min = %gMIN_INTERVAL, max = %gMAX_INTERVAL seconds) IEMSS = 10, // MSS too large. Maximum value = %dMAX_MSS IENOSENDFILE = 11, // This OS does not support sendfile IEOMIT = 12, // Bogus value for --omit diff --git a/src/iperf_error.c b/src/iperf_error.c index 5ab3eab..caff3cf 100644 --- a/src/iperf_error.c +++ b/src/iperf_error.c @@ -91,7 +91,7 @@ iperf_strerror(int i_errno) snprintf(errstr, len, "socket buffer size too large (maximum = %d bytes)", MAX_TCP_BUFFER); break; case IEINTERVAL: - snprintf(errstr, len, "report interval too large (maximum = %d seconds)", MAX_INTERVAL); + snprintf(errstr, len, "invalid report interval (min = %g, max = %g seconds)", MIN_INTERVAL, MAX_INTERVAL); break; case IEMSS: snprintf(errstr, len, "TCP MSS too large (maximum = %d bytes)", MAX_MSS);