• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------
2  * iperf, Copyright (c) 2014-2018, The Regents of the University of
3  * California, through Lawrence Berkeley National Laboratory (subject
4  * to receipt of any required approvals from the U.S. Dept. of
5  * Energy).  All rights reserved.
6  *
7  * If you have questions about your rights to use or distribute this
8  * software, please contact Berkeley Lab's Technology Transfer
9  * Department at TTD@lbl.gov.
10  *
11  * NOTICE.  This software is owned by the U.S. Department of Energy.
12  * As such, the U.S. Government has been granted for itself and others
13  * acting on its behalf a paid-up, nonexclusive, irrevocable,
14  * worldwide license in the Software to reproduce, prepare derivative
15  * works, and perform publicly and display publicly.  Beginning five
16  * (5) years after the date permission to assert copyright is obtained
17  * from the U.S. Department of Energy, and subject to any subsequent
18  * five (5) year renewals, the U.S. Government is granted for itself
19  * and others acting on its behalf a paid-up, nonexclusive,
20  * irrevocable, worldwide license in the Software to reproduce,
21  * prepare derivative works, distribute copies to the public, perform
22  * publicly and display publicly, and to permit others to do so.
23  *
24  * This code is distributed under a BSD style license, see the LICENSE
25  * file for complete information.
26  *
27  * Based on code that is:
28  *
29  * Copyright (c) 1999,2000,2001,2002,2003
30  * The Board of Trustees of the University of Illinois
31  * All Rights Reserved.
32  *---------------------------------------------------------------
33  * Permission is hereby granted, free of charge, to any person
34  * obtaining a copy of this software (Iperf) and associated
35  * documentation files (the "Software"), to deal in the Software
36  * without restriction, including without limitation the
37  * rights to use, copy, modify, merge, publish, distribute,
38  * sublicense, and/or sell copies of the Software, and to permit
39  * persons to whom the Software is furnished to do
40  * so, subject to the following conditions:
41  *
42  *
43  * Redistributions of source code must retain the above
44  * copyright notice, this list of conditions and
45  * the following disclaimers.
46  *
47  *
48  * Redistributions in binary form must reproduce the above
49  * copyright notice, this list of conditions and the following
50  * disclaimers in the documentation and/or other materials
51  * provided with the distribution.
52  *
53  *
54  * Neither the names of the University of Illinois, NCSA,
55  * nor the names of its contributors may be used to endorse
56  * or promote products derived from this Software without
57  * specific prior written permission.
58  *
59  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
60  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
61  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
62  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT
63  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
64  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
65  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE
66  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
67  * ________________________________________________________________
68  * National Laboratory for Applied Network Research
69  * National Center for Supercomputing Applications
70  * University of Illinois at Urbana-Champaign
71  * http://www.ncsa.uiuc.edu
72  * ________________________________________________________________
73  *
74  * Locale.c
75  * by Ajay Tirumala <tirumala@ncsa.uiuc.edu>
76  * & Mark Gates <mgates@nlanr.net>
77  * -------------------------------------------------------------------
78  * Strings and other stuff that is locale specific.
79  * ------------------------------------------------------------------- */
80 #include "iperf_config.h"
81 
82 #include "version.h"
83 
84 #ifdef __cplusplus
85 extern    "C"
86 {
87 #endif
88 
89 
90 /* -------------------------------------------------------------------
91  * usage
92  * ------------------------------------------------------------------- */
93 
94 const char usage_shortstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
95                            "Try `iperf3 --help' for more information.\n";
96 
97 const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
98                            "       iperf3 [-h|--help] [-v|--version]\n\n"
99                            "Server or Client:\n"
100                            "  -p, --port      #         server port to listen on/connect to\n"
101                            "  -f, --format   [kmgtKMGT] format to report: Kbits, Mbits, Gbits, Tbits\n"
102                            "  -i, --interval  #         seconds between periodic throughput reports\n"
103                            "  -F, --file name           xmit/recv the specified file\n"
104 #if defined(HAVE_CPU_AFFINITY)
105                            "  -A, --affinity n/n,m      set CPU affinity\n"
106 #endif /* HAVE_CPU_AFFINITY */
107                            "  -B, --bind      <host>    bind to the interface associated with the address <host>\n"
108                            "  -V, --verbose             more detailed output\n"
109                            "  -J, --json                output in JSON format\n"
110                            "  --logfile f               send output to a log file\n"
111                            "  --forceflush              force flushing output at every interval\n"
112                            "  -d, --debug               emit debugging output\n"
113                            "  -v, --version             show version information and quit\n"
114                            "  -h, --help                show this message and quit\n"
115                            "Server specific:\n"
116                            "  -s, --server              run in server mode\n"
117                            "  -D, --daemon              run the server as a daemon\n"
118                            "  -I, --pidfile file        write PID file\n"
119                            "  -1, --one-off             handle one client connection then exit\n"
120 #if defined(HAVE_SSL)
121                            "  --rsa-private-key-path    path to the RSA private key used to decrypt\n"
122 			   "                            authentication credentials\n"
123                            "  --authorized-users-path   path to the configuration file containing user\n"
124                            "                            credentials\n"
125 #endif //HAVE_SSL
126                            "Client specific:\n"
127                            "  -c, --client    <host>    run in client mode, connecting to <host>\n"
128 #if defined(HAVE_SCTP)
129                            "  --sctp                    use SCTP rather than TCP\n"
130                            "  -X, --xbind <name>        bind SCTP association to links\n"
131                            "  --nstreams      #         number of SCTP streams\n"
132 #endif /* HAVE_SCTP */
133                            "  -u, --udp                 use UDP rather than TCP\n"
134                            "  --connect-timeout #       timeout for control connection setup (ms)\n"
135                            "  -b, --bitrate #[KMG][/#]  target bitrate in bits/sec (0 for unlimited)\n"
136                            "                            (default %d Mbit/sec for UDP, unlimited for TCP)\n"
137                            "                            (optional slash and packet count for burst mode)\n"
138 			   "  --pacing-timer #[KMG]     set the timing for pacing, in microseconds (default 1000)\n"
139 #if defined(HAVE_SO_MAX_PACING_RATE)
140                            "  --fq-rate #[KMG]          enable fair-queuing based socket pacing in\n"
141 			   "                            bits/sec (Linux only)\n"
142 #endif
143                            "  -t, --time      #         time in seconds to transmit for (default %d secs)\n"
144                            "  -n, --bytes     #[KMG]    number of bytes to transmit (instead of -t)\n"
145                            "  -k, --blockcount #[KMG]   number of blocks (packets) to transmit (instead of -t or -n)\n"
146                            "  -l, --length    #[KMG]    length of buffer to read or write\n"
147 			   "                            (default %d KB for TCP, dynamic or %d for UDP)\n"
148                            "  --cport         <port>    bind to a specific client port (TCP and UDP, default: ephemeral port)\n"
149                            "  -P, --parallel  #         number of parallel client streams to run\n"
150                            "  -R, --reverse             run in reverse mode (server sends, client receives)\n"
151                            "  --bidir                   run in bidirectional mode.\n"
152                            "                            Client and server send and receive data.\n"
153                            "  -w, --window    #[KMG]    set window size / socket buffer size\n"
154 #if defined(HAVE_TCP_CONGESTION)
155                            "  -C, --congestion <algo>   set TCP congestion control algorithm (Linux and FreeBSD only)\n"
156 #endif /* HAVE_TCP_CONGESTION */
157                            "  -M, --set-mss   #         set TCP/SCTP maximum segment size (MTU - 40 bytes)\n"
158                            "  -N, --no-delay            set TCP/SCTP no delay, disabling Nagle's Algorithm\n"
159                            "  -4, --version4            only use IPv4\n"
160                            "  -6, --version6            only use IPv6\n"
161                            "  -S, --tos N               set the IP type of service, 0-255.\n"
162                            "                            The usual prefixes for octal and hex can be used,\n"
163                            "                            i.e. 52, 064 and 0x34 all specify the same value.\n"
164 
165                            "  --dscp N or --dscp val    set the IP dscp value, either 0-63 or symbolic.\n"
166                            "                            Numeric values can be specified in decimal,\n"
167                            "                            octal and hex (see --tos above).\n"
168 #if defined(HAVE_FLOWLABEL)
169                            "  -L, --flowlabel N         set the IPv6 flow label (only supported on Linux)\n"
170 #endif /* HAVE_FLOWLABEL */
171                            "  -Z, --zerocopy            use a 'zero copy' method of sending data\n"
172                            "  -O, --omit N              omit the first n seconds\n"
173                            "  -T, --title str           prefix every output line with this string\n"
174                            "  --extra-data str          data string to include in client and server JSON\n"
175                            "  --get-server-output       get results from server\n"
176                            "  --udp-counters-64bit      use 64-bit counters in UDP test packets\n"
177                            "  --repeating-payload       use repeating pattern in payload, instead of\n"
178                            "                            randomized payload (like in iperf2)\n"
179 #if defined(HAVE_SSL)
180                            "  --username                username for authentication\n"
181                            "  --rsa-public-key-path     path to the RSA public key used to encrypt\n"
182                            "                            authentication credentials\n"
183 #endif //HAVESSL
184 
185 #ifdef NOT_YET_SUPPORTED /* still working on these */
186 #endif
187 
188 			   "\n"
189                            "[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-\n"
190 			   "\n"
191 #ifdef PACKAGE_URL
192                            "iperf3 homepage at: " PACKAGE_URL "\n"
193 #endif /* PACKAGE_URL */
194 #ifdef PACKAGE_BUGREPORT
195                            "Report bugs to:     " PACKAGE_BUGREPORT "\n"
196 #endif /* PACKAGE_BUGREPORT */
197 			   ;
198 
199 #ifdef OBSOLETE /* from old iperf: no longer supported. Add some of these back someday */
200   "-d, --dualtest           Do a bidirectional test simultaneously\n"
201   "-L, --listenport #       port to recieve bidirectional tests back on\n"
202   "-I, --stdin              input the data to be transmitted from stdin\n"
203   "-F, --fileinput <name>   input the data to be transmitted from a file\n"
204   "-r, --tradeoff           Do a bidirectional test individually\n"
205   "-T, --ttl       #        time-to-live, for multicast (default 1)\n"
206   "-x, --reportexclude [CDMSV]   exclude C(connection) D(data) M(multicast) S(settings) V(server) reports\n"
207   "-y, --reportstyle C      report as a Comma-Separated Values\n"
208 #endif
209 
210 const char version[] = PACKAGE_STRING;
211 
212 /* -------------------------------------------------------------------
213  * settings
214  * ------------------------------------------------------------------- */
215 
216 const char seperator_line[] =
217 "------------------------------------------------------------\n";
218 
219 const char server_port[] =
220 "Server listening on %s port %d\n";
221 
222 const char client_port[] =
223 "Client connecting to %s, %s port %d\n";
224 
225 const char bind_address[] =
226 "Binding to local address %s\n";
227 
228 const char bind_port[] =
229 "Binding to local port %s\n";
230 
231 const char multicast_ttl[] =
232 "Setting multicast TTL to %d\n";
233 
234 const char join_multicast[] =
235 "Joining multicast group  %s\n";
236 
237 const char client_datagram_size[] =
238 "Sending %d byte datagrams\n";
239 
240 const char server_datagram_size[] =
241 "Receiving %d byte datagrams\n";
242 
243 const char tcp_window_size[] =
244 "TCP window size";
245 
246 const char udp_buffer_size[] =
247 "UDP buffer size";
248 
249 const char window_default[] =
250 "(default)";
251 
252 const char wait_server_threads[] =
253 "Waiting for server threads to complete. Interrupt again to force quit.\n";
254 
255 const char test_start_time[] =
256 "Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %d second test, tos %d\n";
257 
258 const char test_start_bytes[] =
259 "Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %llu bytes to send, tos %d\n";
260 
261 const char test_start_blocks[] =
262 "Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %d blocks to send, tos %d\n";
263 
264 
265 /* -------------------------------------------------------------------
266  * reports
267  * ------------------------------------------------------------------- */
268 
269 const char report_time[] =
270 "Time: %s\n";
271 
272 const char report_connecting[] =
273 "Connecting to host %s, port %d\n";
274 
275 const char report_authetication_successed[] =
276 "Authentication successed for user '%s' ts %ld\n";
277 
278 const char report_authetication_failed[] =
279 "Authentication failed for user '%s' ts %ld\n";
280 
281 const char report_reverse[] =
282 "Reverse mode, remote host %s is sending\n";
283 
284 const char report_accepted[] =
285 "Accepted connection from %s, port %d\n";
286 
287 const char report_cookie[] =
288 "      Cookie: %s\n";
289 
290 const char report_connected[] =
291 "[%3d] local %s port %d connected to %s port %d\n";
292 
293 const char report_window[] =
294 "TCP window size: %s\n";
295 
296 const char report_autotune[] =
297 "Using TCP Autotuning\n";
298 
299 const char report_omit_done[] =
300 "Finished omit period, starting real test\n";
301 
302 const char report_diskfile[] =
303 "        Sent %s / %s (%d%%) of %s\n";
304 
305 const char report_done[] =
306 "iperf Done.\n";
307 
308 const char report_read_lengths[] =
309 "[%3d] Read lengths occurring in more than 5%% of reads:\n";
310 
311 const char report_read_length_times[] =
312 "[%3d] %5d bytes read %5d times (%.3g%%)\n";
313 
314 const char report_bw_header[] =
315 "[ ID] Interval           Transfer     Bitrate\n";
316 
317 const char report_bw_header_bidir[] =
318 "[ ID][Role] Interval           Transfer     Bitrate\n";
319 
320 const char report_bw_retrans_header[] =
321 "[ ID] Interval           Transfer     Bitrate         Retr\n";
322 
323 const char report_bw_retrans_header_bidir[] =
324 "[ ID][Role] Interval           Transfer     Bitrate         Retr\n";
325 
326 const char report_bw_retrans_cwnd_header[] =
327 "[ ID] Interval           Transfer     Bitrate         Retr  Cwnd\n";
328 
329 const char report_bw_retrans_cwnd_header_bidir[] =
330 "[ ID][Role] Interval           Transfer     Bitrate         Retr  Cwnd\n";
331 
332 const char report_bw_udp_header[] =
333 "[ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams\n";
334 
335 const char report_bw_udp_header_bidir[] =
336 "[ ID][Role] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams\n";
337 
338 const char report_bw_udp_sender_header[] =
339 "[ ID] Interval           Transfer     Bitrate         Total Datagrams\n";
340 
341 const char report_bw_udp_sender_header_bidir[] =
342 "[ ID][Role] Interval           Transfer     Bitrate         Total Datagrams\n";
343 
344 const char report_bw_format[] =
345 "[%3d]%s %6.2f-%-6.2f sec  %ss  %ss/sec                  %s\n";
346 
347 const char report_bw_retrans_format[] =
348 "[%3d]%s %6.2f-%-6.2f sec  %ss  %ss/sec  %3u             %s\n";
349 
350 const char report_bw_retrans_cwnd_format[] =
351 "[%3d]%s %6.2f-%-6.2f sec  %ss  %ss/sec  %3u   %ss       %s\n";
352 
353 const char report_bw_udp_format[] =
354 "[%3d]%s %6.2f-%-6.2f sec  %ss  %ss/sec  %5.3f ms  %d/%d (%.2g%%)  %s\n";
355 
356 const char report_bw_udp_sender_format[] =
357 "[%3d]%s %6.2f-%-6.2f sec  %ss  %ss/sec %s %d  %s\n";
358 
359 const char report_summary[] =
360 "Test Complete. Summary Results:\n";
361 
362 const char report_sum_bw_format[] =
363 "[SUM]%s %6.2f-%-6.2f sec  %ss  %ss/sec                  %s\n";
364 
365 const char report_sum_bw_retrans_format[] =
366 "[SUM]%s %6.2f-%-6.2f sec  %ss  %ss/sec  %3d             %s\n";
367 
368 const char report_sum_bw_udp_format[] =
369 "[SUM]%s %6.2f-%-6.2f sec  %ss  %ss/sec  %5.3f ms  %d/%d (%.2g%%)  %s\n";
370 
371 const char report_sum_bw_udp_sender_format[] =
372 "[SUM]%s %6.2f-%-6.2f sec  %ss  %ss/sec %s %d  %s\n";
373 
374 const char report_omitted[] = "(omitted)";
375 
376 const char report_bw_separator[] =
377 "- - - - - - - - - - - - - - - - - - - - - - - - -\n";
378 
379 const char report_outoforder[] =
380 "[%3d]%s %4.1f-%4.1f sec  %d datagrams received out-of-order\n";
381 
382 const char report_sum_outoforder[] =
383 "[SUM]%s %4.1f-%4.1f sec  %d datagrams received out-of-order\n";
384 
385 const char report_peer[] =
386 "[%3d] local %s port %u connected with %s port %u\n";
387 
388 const char report_mss_unsupported[] =
389 "[%3d] MSS and MTU size unknown (TCP_MAXSEG not supported by OS?)\n";
390 
391 const char report_mss[] =
392 "[%3d] MSS size %d bytes (MTU %d bytes, %s)\n";
393 
394 const char report_datagrams[] =
395 "[%3d] Sent %d datagrams\n";
396 
397 const char report_sum_datagrams[] =
398 "[SUM] Sent %d datagrams\n";
399 
400 const char server_reporting[] =
401 "[%3d] Server Report:\n";
402 
403 const char reportCSV_peer[] =
404 "%s,%u,%s,%u";
405 
406 const char report_cpu[] =
407 "CPU Utilization: %s/%s %.1f%% (%.1f%%u/%.1f%%s), %s/%s %.1f%% (%.1f%%u/%.1f%%s)\n";
408 
409 const char report_local[] = "local";
410 const char report_remote[] = "remote";
411 const char report_sender[] = "sender";
412 const char report_receiver[] = "receiver";
413 const char report_sender_not_available_format[] = "[%3d] (sender statistics not available)\n";
414 const char report_sender_not_available_summary_format[] = "[%3s] (sender statistics not available)\n";
415 const char report_receiver_not_available_format[] = "[%3d] (receiver statistics not available)\n";
416 const char report_receiver_not_available_summary_format[] = "[%3s] (receiver statistics not available)\n";
417 
418 #if defined(linux)
419 const char report_tcpInfo[] =
420 "event=TCP_Info CWND=%u SND_SSTHRESH=%u RCV_SSTHRESH=%u UNACKED=%u SACK=%u LOST=%u RETRANS=%u FACK=%u RTT=%u REORDERING=%u\n";
421 #endif
422 #if defined(__FreeBSD__)
423 const char report_tcpInfo[] =
424 "event=TCP_Info CWND=%u RCV_WIND=%u SND_SSTHRESH=%u RTT=%u\n";
425 #endif
426 #if defined(__NetBSD__)
427 const char report_tcpInfo[] =
428 "event=TCP_Info CWND=%u RCV_WIND=%u SND_SSTHRESH=%u RTT=%u\n";
429 #endif
430 
431 
432 #ifdef HAVE_QUAD_SUPPORT
433 #ifdef HAVE_PRINTF_QD
434 const char reportCSV_bw_format[] =
435 "%s,%s,%d,%.1f-%.1f,%qd,%qd\n";
436 
437 const char reportCSV_bw_udp_format[] =
438 "%s,%s,%d,%.1f-%.1f,%qd,%qd,%.3f,%d,%d,%.3f,%d\n";
439 #else // HAVE_PRINTF_QD
440 const char reportCSV_bw_format[] =
441 "%s,%s,%d,%.1f-%.1f,%lld,%lld\n";
442 
443 const char reportCSV_bw_udp_format[] =
444 "%s,%s,%d,%.1f-%.1f,%lld,%lld,%.3f,%d,%d,%.3f,%d\n";
445 #endif // HAVE_PRINTF_QD
446 #else // HAVE_QUAD_SUPPORT
447 #ifdef WIN32
448 const char reportCSV_bw_format[] =
449 "%s,%s,%d,%.1f-%.1f,%I64d,%I64d\n";
450 
451 const char reportCSV_bw_udp_format[] =
452 "%s,%s,%d,%.1f-%.1f,%I64d,%I64d,%.3f,%d,%d,%.3f,%d\n";
453 #else
454 const char reportCSV_bw_format[] =
455 "%s,%s,%d,%.1f-%.1f,%d,%d\n";
456 
457 const char reportCSV_bw_udp_format[] =
458 "%s,%s,%d,%.1f-%.1f,%d,%d,%.3f,%d,%d,%.3f,%d\n";
459 #endif //WIN32
460 #endif //HAVE_QUAD_SUPPORT
461 /* -------------------------------------------------------------------
462  * warnings
463  * ------------------------------------------------------------------- */
464 
465 const char warn_window_requested[] =
466 " (WARNING: requested %s)";
467 
468 const char warn_window_small[] =
469 "WARNING: TCP window size set to %d bytes. A small window size\n\
470 will give poor performance. See the Iperf documentation.\n";
471 
472 const char warn_delay_large[] =
473 "WARNING: delay too large, reducing from %.1f to 1.0 seconds.\n";
474 
475 const char warn_no_pathmtu[] =
476 "WARNING: Path MTU Discovery may not be enabled.\n";
477 
478 const char warn_no_ack[]=
479 "[%3d] WARNING: did not receive ack of last datagram after %d tries.\n";
480 
481 const char warn_ack_failed[]=
482 "[%3d] WARNING: ack of last datagram failed after %d tries.\n";
483 
484 const char warn_fileopen_failed[]=
485 "WARNING: Unable to open file stream for transfer\n\
486 Using default data stream. \n";
487 
488 const char unable_to_change_win[]=
489 "WARNING: Unable to change the window size\n";
490 
491 const char opt_estimate[]=
492 "Optimal Estimate\n";
493 
494 const char report_interval_small[] =
495 "WARNING: interval too small, increasing from %3.2f to 0.5 seconds.\n";
496 
497 const char warn_invalid_server_option[] =
498 "WARNING: option -%c is not valid for server mode\n";
499 
500 const char warn_invalid_client_option[] =
501 "WARNING: option -%c is not valid for client mode\n";
502 
503 const char warn_invalid_compatibility_option[] =
504 "WARNING: option -%c is not valid in compatibility mode\n";
505 
506 const char warn_implied_udp[] =
507 "WARNING: option -%c implies udp testing\n";
508 
509 const char warn_implied_compatibility[] =
510 "WARNING: option -%c has implied compatibility mode\n";
511 
512 const char warn_buffer_too_small[] =
513 "WARNING: the UDP buffer was increased to %d for proper operation\n";
514 
515 const char warn_invalid_single_threaded[] =
516 "WARNING: option -%c is not valid in single threaded versions\n";
517 
518 const char warn_invalid_report_style[] =
519 "WARNING: unknown reporting style \"%s\", switching to default\n";
520 
521 const char warn_invalid_report[] =
522 "WARNING: unknown reporting type \"%c\", ignored\n valid options are:\n\t exclude: C(connection) D(data) M(multicast) S(settings) V(server) report\n\n";
523 
524 #ifdef __cplusplus
525 } /* end extern "C" */
526 #endif
527