Skip to content

Commit affde3c

Browse files
committed
Add options to support warm-up and cool-down
1 parent 3676174 commit affde3c

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

src/const.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
#define DEFAULT_BASE_SRC_PORT 25001
4848
#define DEFAULT_RECV_BUFFER_SIZE 64 * 1024
4949
#define DEFAULT_SEND_BUFFER_SIZE 128 * 1024
50+
#define DEFAULT_WARMUP_SEC 0
5051
#define DEFAULT_TEST_DURATION 60
52+
#define DEFAULT_COOLDOWN_SEC 0
5153
#define SOCKET_TIMEOUT_SEC 3
5254
#define THREAD_STACK_SIZE 65536
5355

src/ntttcp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ void default_ntttcp_test(struct ntttcp_test *test)
3939
test->client_base_port = 0; //random/ephemeral port
4040
test->recv_buf_size = DEFAULT_RECV_BUFFER_SIZE; //64K
4141
test->send_buf_size = DEFAULT_SEND_BUFFER_SIZE; //128K
42-
test->duration = DEFAULT_TEST_DURATION;
42+
test->warmup = DEFAULT_WARMUP_SEC; // 0 sec
43+
test->duration = DEFAULT_TEST_DURATION; //60 sec
44+
test->cooldown = DEFAULT_COOLDOWN_SEC; // 0 sec
4345
test->no_synch = false;
4446
test->show_tcp_retransmit = false;
4547
test->save_xml_log = false;

src/ntttcp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ struct ntttcp_test
4141
uint client_base_port; /* '-f' to pin client source port based on this */
4242
ulong recv_buf_size; /* '-b' for receive buffer option */
4343
ulong send_buf_size; /* '-B' for send buffer option */
44+
int warmup; /* '-W' for test warm-up time in sec */
4445
int duration; /* '-t' for total duration in sec of test (0: continuous_mode) */
46+
int cooldown; /* '-C' for test cool-down time in sec */
4547

4648
bool show_tcp_retransmit; /* '-R' to display TCP retransmit counters in log from /proc */
4749
bool save_xml_log; /* '-x' to save output to XML file */

src/util.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,21 @@ void print_flags(struct ntttcp_test *test)
6363
if (test->client_role)
6464
printf("%s:\t %ld\n", "sender socket buffer (bytes)", test->send_buf_size);
6565

66+
if (test->warmup == 0)
67+
printf("%s:\t\t %s\n", "test warm-up (sec)", "no");
68+
else
69+
printf("%s:\t\t %d\n", "test warm-up (sec)", test->warmup);
70+
6671
if (test->duration == 0)
6772
printf("%s:\t\t %s\n", "test duration (sec)", "continuous");
6873
else
6974
printf("%s:\t\t %d\n", "test duration (sec)", test->duration);
7075

76+
if (test->cooldown == 0)
77+
printf("%s:\t\t %s\n", "test cool-down (sec)", "no");
78+
else
79+
printf("%s:\t\t %d\n", "test cool-down (sec)", test->cooldown);
80+
7181
printf("%s:\t %s\n", "show system tcp retransmit", test->show_tcp_retransmit ? "yes" : "no");
7282

7383
if (test->save_xml_log)
@@ -80,7 +90,7 @@ void print_flags(struct ntttcp_test *test)
8090
void print_usage()
8191
{
8292
printf("Author: %s\n", AUTHOR_NAME);
83-
printf("ntttcp: [-r|-s|-D|-M|-L|-e|-H|-P|-n|-l|-6|-u|-p|-f|-b|-t|-N|-R|-x|-V|-h|-m <mapping>\n\n");
93+
printf("ntttcp: [-r|-s|-D|-M|-L|-e|-H|-P|-n|-l|-6|-u|-p|-f|-b|-W|-t|-C|-N|-R|-x|-V|-h|-m <mapping>\n\n");
8494
printf("\t-r Run as a receiver\n");
8595
printf("\t-s Run as a sender\n");
8696
printf("\t-D Run as daemon\n");
@@ -101,7 +111,9 @@ void print_usage()
101111
printf("\t-f Fixed source port number, or starting port number [default: %d]\n", DEFAULT_BASE_SRC_PORT);
102112
printf("\t-b <buffer size> [default: %d (receiver); %d (sender)]\n", DEFAULT_RECV_BUFFER_SIZE, DEFAULT_SEND_BUFFER_SIZE);
103113

104-
printf("\t-t Time of test duration in seconds [default: %d]\n", DEFAULT_TEST_DURATION);
114+
printf("\t-W Warm-up time in seconds [default: %d]\n", DEFAULT_WARMUP_SEC);
115+
printf("\t-t Time of test duration in seconds [default: %d]\n", DEFAULT_TEST_DURATION);
116+
printf("\t-C Cool-down time in seconds [default: %d]\n", DEFAULT_COOLDOWN_SEC);
105117
printf("\t-N No sync, senders will start sending as soon as possible\n");
106118
printf("\t Otherwise, will use 'destination port - 1' as sync port [default: %d]\n", DEFAULT_BASE_DST_PORT - 1);
107119

@@ -299,6 +311,16 @@ int verify_args(struct ntttcp_test *test)
299311
PRINT_INFO("running test in continuous mode. please monitor throughput by other tools");
300312
}
301313

314+
if (test->warmup < 0) {
315+
test->warmup = DEFAULT_WARMUP_SEC;
316+
PRINT_INFO("invalid test warm-up seconds provided. use the default value");
317+
}
318+
319+
if(test->cooldown <0) {
320+
test->cooldown = DEFAULT_COOLDOWN_SEC;
321+
PRINT_INFO("invalid test cool-down seconds provided. use the default value");
322+
}
323+
302324
return NO_ERROR;
303325
}
304326

@@ -324,7 +346,9 @@ int parse_arguments(struct ntttcp_test *test, int argc, char **argv)
324346
{"base-dst-port", required_argument, NULL, 'p'},
325347
{"base-src-port", optional_argument, NULL, 'f'},
326348
{"buffer", required_argument, NULL, 'b'},
349+
{"warmup", required_argument, NULL, 'W'},
327350
{"duration", required_argument, NULL, 't'},
351+
{"cooldown", required_argument, NULL, 'C'},
328352
{"no-synch", no_argument, NULL, 'N'},
329353
{"show-retrans", no_argument, NULL, 'R'},
330354
{"save-xml", optional_argument, NULL, 'x'},
@@ -336,7 +360,7 @@ int parse_arguments(struct ntttcp_test *test, int argc, char **argv)
336360

337361
int opt;
338362

339-
while ((opt = getopt(argc, argv, "r::s::DMLeHm:P:n:l:6up:f::b:t:NRx::Vh")) != -1) {
363+
while ((opt = getopt(argc, argv, "r::s::DMLeHm:P:n:l:6up:f::b:W:t:C:NRx::Vh")) != -1) {
340364
switch (opt) {
341365
case 'r':
342366
case 's':
@@ -420,10 +444,18 @@ int parse_arguments(struct ntttcp_test *test, int argc, char **argv)
420444
test->send_buf_size = unit_atod(optarg);
421445
break;
422446

447+
case 'W':
448+
test->warmup = atoi(optarg);
449+
break;
450+
423451
case 't':
424452
test->duration = atoi(optarg);
425453
break;
426454

455+
case 'C':
456+
test->cooldown = atoi(optarg);
457+
break;
458+
427459
case 'N':
428460
test->no_synch = true;
429461
break;

0 commit comments

Comments
 (0)