Skip to content

Commit 13df8a3

Browse files
committed
Add "-P" flag to support specifying number of receiver ports
-P: Number of ports listening on receiver side
1 parent 5c66a22 commit 13df8a3

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ A multiple-thread based Linux network throughput benchmark tool.
3737
To measure the network performance between two multi-core serves running SLES 12, NODE1 (192.168.4.1) and NODE2 (192.168.4.2), connected via a 40 GigE connection.
3838

3939
On NODE1 (the receiver), run:
40-
40+
```
4141
./ntttcp -r
42-
42+
```
4343
(Translation: Run ntttcp as a receiver with default setting. The default setting includes: with 16 threads created and run across all CPUs, allocating 64K receiver buffer, and run for 60 seconds.)
4444

4545
And on NODE2 (the sender), run:
46-
46+
```
4747
./ntttcp.exe -s192.168.4.1
48-
48+
```
4949
(Translation: Run ntttcp as a sender, with default setting. The default setting includes: with 64 threads created and run across all CPUs, allocating 128KB sender buffer, and run for 60 seconds.)
5050

5151
Using the above parameters, the program returns results on both the sender and receiver nodes, correlating network communication to CPU utilization.

src/util.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void print_flags(struct ntttcp_test *test)
2020
if (test->no_synch )
2121
printf("%s\n", "*** no sender/receiver synch");
2222

23-
printf("%s:\t\t\t %s\n", "mapping", test->mapping);
23+
//printf("%s:\t\t\t %s\n", "mapping", test->mapping);
2424

2525
if (test->client_role)
2626
printf("%s:\t\t\t %d X %d\n", "threads", test->parallel, test->conn_per_thread);
@@ -64,24 +64,28 @@ void print_usage()
6464
printf("\t-D Run as daemon\n");
6565
printf("\t-e [receiver only] use epoll() instead of select()\n");
6666

67-
printf("\t-m <mapping>\n");
68-
printf("\t Where a mapping is a NumberOfThreads,Processor,BindingIPAddress set\n");
69-
printf("\t\t NumberOfThreads:\t[default: %d]\t[max: %d]\n", DEFAULT_NUM_THREADS, MAX_NUM_THREADS);
70-
printf("\t\t Processor:\t\t*, or cpuid such as 0, 1, etc \n");
71-
printf("\t e.g. -m 8,*,192.168.1.1\n \t\t8 threads running on all processors\n\t\tand listening on ports of network on 192.168.1.1\n");
72-
73-
printf("\t-n [sender only] number of connections per server port\n\t\t[default: %d]\n\t\t[max: %d]\n", DEFAULT_CONN_PER_THREAD, MAX_CONNECTIONS_PER_THREAD);
74-
printf("\t-6 IPv6 mode [default: IPv4]\n");
75-
//printf("\t-u UDP mode [default: TCP] NOT SUPPORTED YET\n");
76-
printf("\t-p Port number, or starting port number [default: %d]\n", DEFAULT_BASE_PORT);
77-
printf("\t-b <recv buffer size> [default: %d]\n", DEFAULT_RECV_BUFFER_SIZE);
78-
printf("\t-B <send buffer size> [default: %d]\n", DEFAULT_SEND_BUFFER_SIZE);
79-
printf("\t-t Time of test duration in seconds [default: %d]\n", DEFAULT_TEST_DURATION);
67+
printf("\t-P Number of ports listening on receiver side\n");
68+
printf("\t-n [sender only] number of connections per receiver port [default: %d] [max: %d]\n", DEFAULT_CONN_PER_THREAD, MAX_CONNECTIONS_PER_THREAD);
69+
70+
printf("\t-6 IPv6 mode [default: IPv4]\n");
71+
//printf("\t-u UDP mode [default: TCP] NOT SUPPORTED YET\n");
72+
printf("\t-p Port number, or starting port number [default: %d]\n", DEFAULT_BASE_PORT);
73+
printf("\t-b <recv buffer size> [default: %d]\n", DEFAULT_RECV_BUFFER_SIZE);
74+
printf("\t-B <send buffer size> [default: %d]\n", DEFAULT_SEND_BUFFER_SIZE);
75+
printf("\t-t Time of test duration in seconds [default: %d]\n", DEFAULT_TEST_DURATION);
8076
printf("\t-N No sync, senders will start sending as soon as possible.\n");
8177

8278
printf("\t-V Verbose mode\n");
8379
printf("\t-h Help, tool usage\n");
8480

81+
printf("\t-m <mapping>\tfor the purpose of compatible with Windows ntttcp usage\n");
82+
printf("\t\t Where a mapping is a NumberOfReceiverPorts,Processor,BindingIPAddress set:\n");
83+
printf("\t\t NumberOfReceiverPorts: [default: %d] [max: %d]\n", DEFAULT_NUM_THREADS, MAX_NUM_THREADS);
84+
printf("\t\t Processor:\t\t*, or cpuid such as 0, 1, etc \n");
85+
printf("\t\t e.g. -m 8,*,192.168.1.1\n");
86+
printf("\t\t\t If receiver role: 8 threads running on all processors;\n\t\t\tand listening on 8 ports of network on 192.168.1.1.\n");
87+
printf("\t\t\t If sender role: receiver has 8 threads running and listening on 8 ports of network on 192.168.1.1;\n\t\t\tand all sender threads will run on all processors.\n");
88+
8589
printf("Example:\n");
8690
printf("\treceiver:\n");
8791
printf("\t1) ./ntttcp -r\n");
@@ -218,6 +222,7 @@ int parse_arguments(struct ntttcp_test *test, int argc, char **argv)
218222
{"daemon", no_argument, NULL, 'D'},
219223
{"epoll", no_argument, NULL, 'e'},
220224
{"mapping", required_argument, NULL, 'm'},
225+
{"nports", required_argument, NULL, 'P'},
221226
{"nconn", required_argument, NULL, 'n'},
222227
{"ipv6", no_argument, NULL, '6'},
223228
{"udp", no_argument, NULL, 'u'},
@@ -233,7 +238,7 @@ int parse_arguments(struct ntttcp_test *test, int argc, char **argv)
233238

234239
int flag;
235240

236-
while ((flag = getopt_long(argc, argv, "r::s::Dem:n:6up:b:B:t:NVh", longopts, NULL)) != -1) {
241+
while ((flag = getopt_long(argc, argv, "r::s::Dem:P:n:6up:b:B:t:NVh", longopts, NULL)) != -1) {
237242
switch (flag) {
238243
case 'r':
239244
test->server_role = true;
@@ -260,6 +265,10 @@ int parse_arguments(struct ntttcp_test *test, int argc, char **argv)
260265
process_mappings(test);
261266
break;
262267

268+
case 'P':
269+
test->parallel = atoi(optarg);
270+
break;
271+
263272
case 'n':
264273
test->conn_per_thread = atoi(optarg);
265274
break;
@@ -354,7 +363,7 @@ void print_total_result(long total_bytes,
354363
if (test_duration == 0)
355364
return;
356365

357-
printf("---------------------------------------------------------\n");
366+
PRINT_INFO("##### Totals: #####");
358367
asprintf(&log, "test duration\t:%.2f seconds", test_duration);
359368
PRINT_INFO_FREE(log);
360369
asprintf(&log, "total bytes\t:%ld", total_bytes);

0 commit comments

Comments
 (0)