1 /*--------------------------------------------------------------- 2 * iperf, Copyright (c) 2014-2021, 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 " -I, --pidfile file write PID file\n" 104 " -F, --file name xmit/recv the specified file\n" 105 #if defined(HAVE_CPU_AFFINITY) 106 " -A, --affinity n/n,m set CPU affinity\n" 107 #endif /* HAVE_CPU_AFFINITY */ 108 " -B, --bind <host> bind to the interface associated with the address <host>\n" 109 #if defined(HAVE_SO_BINDTODEVICE) 110 " --bind-dev <dev> bind to the network interface with SO_BINDTODEVICE\n" 111 #endif /* HAVE_SO_BINDTODEVICE */ 112 " -V, --verbose more detailed output\n" 113 " -J, --json output in JSON format\n" 114 " --logfile f send output to a log file\n" 115 " --forceflush force flushing output at every interval\n" 116 " --timestamps<=format> emit a timestamp at the start of each output line\n" 117 " (optional \"=\" and format string as per strftime(3))\n" 118 119 " --rcv-timeout # idle timeout for receiving data\n" 120 " (default %d ms)\n" 121 " -d, --debug emit debugging output\n" 122 " -v, --version show version information and quit\n" 123 " -h, --help show this message and quit\n" 124 "Server specific:\n" 125 " -s, --server run in server mode\n" 126 " -D, --daemon run the server as a daemon\n" 127 " -1, --one-off handle one client connection then exit\n" 128 " --server-bitrate-limit #[KMG][/#] server's total bit rate limit (default 0 = no limit)\n" 129 " (optional slash and number of secs interval for averaging\n" 130 " total data rate. Default is 5 seconds)\n" 131 " --idle-timeout # restart idle server after # seconds in case it\n" 132 " got stuck (default - no timeout)\n" 133 #if defined(HAVE_SSL) 134 " --rsa-private-key-path path to the RSA private key used to decrypt\n" 135 " authentication credentials\n" 136 " --authorized-users-path path to the configuration file containing user\n" 137 " credentials\n" 138 " --time-skew-threshold time skew threshold (in seconds) between the server\n" 139 " and client during the authentication process\n" 140 #endif //HAVE_SSL 141 "Client specific:\n" 142 " -c, --client <host> run in client mode, connecting to <host>\n" 143 #if defined(HAVE_SCTP_H) 144 " --sctp use SCTP rather than TCP\n" 145 " -X, --xbind <name> bind SCTP association to links\n" 146 " --nstreams # number of SCTP streams\n" 147 #endif /* HAVE_SCTP_H */ 148 " -u, --udp use UDP rather than TCP\n" 149 " --connect-timeout # timeout for control connection setup (ms)\n" 150 " -b, --bitrate #[KMG][/#] target bitrate in bits/sec (0 for unlimited)\n" 151 " (default %d Mbit/sec for UDP, unlimited for TCP)\n" 152 " (optional slash and packet count for burst mode)\n" 153 " --pacing-timer #[KMG] set the timing for pacing, in microseconds (default %d)\n" 154 #if defined(HAVE_SO_MAX_PACING_RATE) 155 " --fq-rate #[KMG] enable fair-queuing based socket pacing in\n" 156 " bits/sec (Linux only)\n" 157 #endif 158 " -t, --time # time in seconds to transmit for (default %d secs)\n" 159 " -n, --bytes #[KMG] number of bytes to transmit (instead of -t)\n" 160 " -k, --blockcount #[KMG] number of blocks (packets) to transmit (instead of -t or -n)\n" 161 " -l, --length #[KMG] length of buffer to read or write\n" 162 " (default %d KB for TCP, dynamic or %d for UDP)\n" 163 " --cport <port> bind to a specific client port (TCP and UDP, default: ephemeral port)\n" 164 " -P, --parallel # number of parallel client streams to run\n" 165 " -R, --reverse run in reverse mode (server sends, client receives)\n" 166 " --bidir run in bidirectional mode.\n" 167 " Client and server send and receive data.\n" 168 " -w, --window #[KMG] set window size / socket buffer size\n" 169 #if defined(HAVE_TCP_CONGESTION) 170 " -C, --congestion <algo> set TCP congestion control algorithm (Linux and FreeBSD only)\n" 171 #endif /* HAVE_TCP_CONGESTION */ 172 " -M, --set-mss # set TCP/SCTP maximum segment size (MTU - 40 bytes)\n" 173 " -N, --no-delay set TCP/SCTP no delay, disabling Nagle's Algorithm\n" 174 " -4, --version4 only use IPv4\n" 175 " -6, --version6 only use IPv6\n" 176 " -S, --tos N set the IP type of service, 0-255.\n" 177 " The usual prefixes for octal and hex can be used,\n" 178 " i.e. 52, 064 and 0x34 all specify the same value.\n" 179 180 " --dscp N or --dscp val set the IP dscp value, either 0-63 or symbolic.\n" 181 " Numeric values can be specified in decimal,\n" 182 " octal and hex (see --tos above).\n" 183 #if defined(HAVE_FLOWLABEL) 184 " -L, --flowlabel N set the IPv6 flow label (only supported on Linux)\n" 185 #endif /* HAVE_FLOWLABEL */ 186 " -Z, --zerocopy use a 'zero copy' method of sending data\n" 187 " -O, --omit N omit the first n seconds\n" 188 " -T, --title str prefix every output line with this string\n" 189 " --extra-data str data string to include in client and server JSON\n" 190 " --get-server-output get results from server\n" 191 " --udp-counters-64bit use 64-bit counters in UDP test packets\n" 192 " --repeating-payload use repeating pattern in payload, instead of\n" 193 " randomized payload (like in iperf2)\n" 194 #if defined(HAVE_DONT_FRAGMENT) 195 " --dont-fragment set IPv4 Don't Fragment flag\n" 196 #endif /* HAVE_DONT_FRAGMENT */ 197 #if defined(HAVE_SSL) 198 " --username username for authentication\n" 199 " --rsa-public-key-path path to the RSA public key used to encrypt\n" 200 " authentication credentials\n" 201 #endif //HAVESSL 202 203 #ifdef NOT_YET_SUPPORTED /* still working on these */ 204 #endif 205 206 "\n" 207 "[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-\n" 208 "\n" 209 #ifdef PACKAGE_URL 210 "iperf3 homepage at: " PACKAGE_URL "\n" 211 #endif /* PACKAGE_URL */ 212 #ifdef PACKAGE_BUGREPORT 213 "Report bugs to: " PACKAGE_BUGREPORT "\n" 214 #endif /* PACKAGE_BUGREPORT */ 215 ; 216 217 #ifdef OBSOLETE /* from old iperf: no longer supported. Add some of these back someday */ 218 "-d, --dualtest Do a bidirectional test simultaneously\n" 219 "-L, --listenport # port to recieve bidirectional tests back on\n" 220 "-I, --stdin input the data to be transmitted from stdin\n" 221 "-F, --fileinput <name> input the data to be transmitted from a file\n" 222 "-r, --tradeoff Do a bidirectional test individually\n" 223 "-T, --ttl # time-to-live, for multicast (default 1)\n" 224 "-x, --reportexclude [CDMSV] exclude C(connection) D(data) M(multicast) S(settings) V(server) reports\n" 225 "-y, --reportstyle C report as a Comma-Separated Values\n" 226 #endif 227 228 const char version[] = PACKAGE_STRING; 229 230 /* ------------------------------------------------------------------- 231 * settings 232 * ------------------------------------------------------------------- */ 233 234 const char seperator_line[] = 235 "------------------------------------------------------------\n"; 236 237 const char server_port[] = 238 "Server listening on %s port %d\n"; 239 240 const char client_port[] = 241 "Client connecting to %s, %s port %d\n"; 242 243 const char bind_address[] = 244 "Binding to local address %s\n"; 245 246 const char bind_dev[] = 247 "Binding to local network device %s\n"; 248 249 const char bind_port[] = 250 "Binding to local port %s\n"; 251 252 const char multicast_ttl[] = 253 "Setting multicast TTL to %d\n"; 254 255 const char join_multicast[] = 256 "Joining multicast group %s\n"; 257 258 const char client_datagram_size[] = 259 "Sending %d byte datagrams\n"; 260 261 const char server_datagram_size[] = 262 "Receiving %d byte datagrams\n"; 263 264 const char tcp_window_size[] = 265 "TCP window size"; 266 267 const char udp_buffer_size[] = 268 "UDP buffer size"; 269 270 const char window_default[] = 271 "(default)"; 272 273 const char wait_server_threads[] = 274 "Waiting for server threads to complete. Interrupt again to force quit.\n"; 275 276 const char test_start_time[] = 277 "Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %d second test, tos %d\n"; 278 279 const char test_start_bytes[] = 280 "Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %llu bytes to send, tos %d\n"; 281 282 const char test_start_blocks[] = 283 "Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %d blocks to send, tos %d\n"; 284 285 286 /* ------------------------------------------------------------------- 287 * reports 288 * ------------------------------------------------------------------- */ 289 290 const char report_time[] = 291 "Time: %s\n"; 292 293 const char report_connecting[] = 294 "Connecting to host %s, port %d\n"; 295 296 const char report_authentication_succeeded[] = 297 "Authentication succeeded for user '%s' ts %ld\n"; 298 299 const char report_authentication_failed[] = 300 "Authentication failed for user '%s' ts %ld\n"; 301 302 const char report_reverse[] = 303 "Reverse mode, remote host %s is sending\n"; 304 305 const char report_accepted[] = 306 "Accepted connection from %s, port %d\n"; 307 308 const char report_cookie[] = 309 " Cookie: %s\n"; 310 311 const char report_connected[] = 312 "[%3d] local %s port %d connected to %s port %d\n"; 313 314 const char report_window[] = 315 "TCP window size: %s\n"; 316 317 const char report_autotune[] = 318 "Using TCP Autotuning\n"; 319 320 const char report_omit_done[] = 321 "Finished omit period, starting real test\n"; 322 323 const char report_diskfile[] = 324 " Sent %s / %s (%d%%) of %s\n"; 325 326 const char report_done[] = 327 "iperf Done.\n"; 328 329 const char report_read_lengths[] = 330 "[%3d] Read lengths occurring in more than 5%% of reads:\n"; 331 332 const char report_read_length_times[] = 333 "[%3d] %5d bytes read %5d times (%.3g%%)\n"; 334 335 const char report_bw_header[] = 336 "[ ID] Interval Transfer Bitrate\n"; 337 338 const char report_bw_header_bidir[] = 339 "[ ID][Role] Interval Transfer Bitrate\n"; 340 341 const char report_bw_retrans_header[] = 342 "[ ID] Interval Transfer Bitrate Retr\n"; 343 344 const char report_bw_retrans_header_bidir[] = 345 "[ ID][Role] Interval Transfer Bitrate Retr\n"; 346 347 const char report_bw_retrans_cwnd_header[] = 348 "[ ID] Interval Transfer Bitrate Retr Cwnd\n"; 349 350 const char report_bw_retrans_cwnd_header_bidir[] = 351 "[ ID][Role] Interval Transfer Bitrate Retr Cwnd\n"; 352 353 const char report_bw_udp_header[] = 354 "[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams\n"; 355 356 const char report_bw_udp_header_bidir[] = 357 "[ ID][Role] Interval Transfer Bitrate Jitter Lost/Total Datagrams\n"; 358 359 const char report_bw_udp_sender_header[] = 360 "[ ID] Interval Transfer Bitrate Total Datagrams\n"; 361 362 const char report_bw_udp_sender_header_bidir[] = 363 "[ ID][Role] Interval Transfer Bitrate Total Datagrams\n"; 364 365 const char report_bw_format[] = 366 "[%3d]%s %6.2f-%-6.2f sec %ss %ss/sec %s\n"; 367 368 const char report_bw_retrans_format[] = 369 "[%3d]%s %6.2f-%-6.2f sec %ss %ss/sec %3u %s\n"; 370 371 const char report_bw_retrans_cwnd_format[] = 372 "[%3d]%s %6.2f-%-6.2f sec %ss %ss/sec %3u %ss %s\n"; 373 374 const char report_bw_udp_format[] = 375 "[%3d]%s %6.2f-%-6.2f sec %ss %ss/sec %5.3f ms %d/%d (%.2g%%) %s\n"; 376 377 const char report_bw_udp_sender_format[] = 378 "[%3d]%s %6.2f-%-6.2f sec %ss %ss/sec %s %d %s\n"; 379 380 const char report_summary[] = 381 "Test Complete. Summary Results:\n"; 382 383 const char report_sum_bw_format[] = 384 "[SUM]%s %6.2f-%-6.2f sec %ss %ss/sec %s\n"; 385 386 const char report_sum_bw_retrans_format[] = 387 "[SUM]%s %6.2f-%-6.2f sec %ss %ss/sec %3d %s\n"; 388 389 const char report_sum_bw_udp_format[] = 390 "[SUM]%s %6.2f-%-6.2f sec %ss %ss/sec %5.3f ms %d/%d (%.2g%%) %s\n"; 391 392 const char report_sum_bw_udp_sender_format[] = 393 "[SUM]%s %6.2f-%-6.2f sec %ss %ss/sec %s %d %s\n"; 394 395 const char report_omitted[] = "(omitted)"; 396 397 const char report_bw_separator[] = 398 "- - - - - - - - - - - - - - - - - - - - - - - - -\n"; 399 400 const char report_outoforder[] = 401 "[%3d]%s %4.1f-%4.1f sec %d datagrams received out-of-order\n"; 402 403 const char report_sum_outoforder[] = 404 "[SUM]%s %4.1f-%4.1f sec %d datagrams received out-of-order\n"; 405 406 const char report_peer[] = 407 "[%3d] local %s port %u connected with %s port %u\n"; 408 409 const char report_mss_unsupported[] = 410 "[%3d] MSS and MTU size unknown (TCP_MAXSEG not supported by OS?)\n"; 411 412 const char report_mss[] = 413 "[%3d] MSS size %d bytes (MTU %d bytes, %s)\n"; 414 415 const char report_datagrams[] = 416 "[%3d] Sent %d datagrams\n"; 417 418 const char report_sum_datagrams[] = 419 "[SUM] Sent %d datagrams\n"; 420 421 const char server_reporting[] = 422 "[%3d] Server Report:\n"; 423 424 const char reportCSV_peer[] = 425 "%s,%u,%s,%u"; 426 427 const char report_cpu[] = 428 "CPU Utilization: %s/%s %.1f%% (%.1f%%u/%.1f%%s), %s/%s %.1f%% (%.1f%%u/%.1f%%s)\n"; 429 430 const char report_local[] = "local"; 431 const char report_remote[] = "remote"; 432 const char report_sender[] = "sender"; 433 const char report_receiver[] = "receiver"; 434 const char report_sender_not_available_format[] = "[%3d] (sender statistics not available)\n"; 435 const char report_sender_not_available_summary_format[] = "[%3s] (sender statistics not available)\n"; 436 const char report_receiver_not_available_format[] = "[%3d] (receiver statistics not available)\n"; 437 const char report_receiver_not_available_summary_format[] = "[%3s] (receiver statistics not available)\n"; 438 439 #if defined(linux) 440 const char report_tcpInfo[] = 441 "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"; 442 #endif 443 #if defined(__FreeBSD__) 444 const char report_tcpInfo[] = 445 "event=TCP_Info CWND=%u RCV_WIND=%u SND_SSTHRESH=%u RTT=%u\n"; 446 #endif 447 #if defined(__NetBSD__) 448 const char report_tcpInfo[] = 449 "event=TCP_Info CWND=%u RCV_WIND=%u SND_SSTHRESH=%u RTT=%u\n"; 450 #endif 451 452 453 #ifdef HAVE_QUAD_SUPPORT 454 #ifdef HAVE_PRINTF_QD 455 const char reportCSV_bw_format[] = 456 "%s,%s,%d,%.1f-%.1f,%qd,%qd\n"; 457 458 const char reportCSV_bw_udp_format[] = 459 "%s,%s,%d,%.1f-%.1f,%qd,%qd,%.3f,%d,%d,%.3f,%d\n"; 460 #else // HAVE_PRINTF_QD 461 const char reportCSV_bw_format[] = 462 "%s,%s,%d,%.1f-%.1f,%lld,%lld\n"; 463 464 const char reportCSV_bw_udp_format[] = 465 "%s,%s,%d,%.1f-%.1f,%lld,%lld,%.3f,%d,%d,%.3f,%d\n"; 466 #endif // HAVE_PRINTF_QD 467 #else // HAVE_QUAD_SUPPORT 468 #ifdef WIN32 469 const char reportCSV_bw_format[] = 470 "%s,%s,%d,%.1f-%.1f,%I64d,%I64d\n"; 471 472 const char reportCSV_bw_udp_format[] = 473 "%s,%s,%d,%.1f-%.1f,%I64d,%I64d,%.3f,%d,%d,%.3f,%d\n"; 474 #else 475 const char reportCSV_bw_format[] = 476 "%s,%s,%d,%.1f-%.1f,%d,%d\n"; 477 478 const char reportCSV_bw_udp_format[] = 479 "%s,%s,%d,%.1f-%.1f,%d,%d,%.3f,%d,%d,%.3f,%d\n"; 480 #endif //WIN32 481 #endif //HAVE_QUAD_SUPPORT 482 /* ------------------------------------------------------------------- 483 * warnings 484 * ------------------------------------------------------------------- */ 485 486 const char warn_window_requested[] = 487 " (WARNING: requested %s)"; 488 489 const char warn_window_small[] = 490 "WARNING: TCP window size set to %d bytes. A small window size\n\ 491 will give poor performance. See the Iperf documentation.\n"; 492 493 const char warn_delay_large[] = 494 "WARNING: delay too large, reducing from %.1f to 1.0 seconds.\n"; 495 496 const char warn_no_pathmtu[] = 497 "WARNING: Path MTU Discovery may not be enabled.\n"; 498 499 const char warn_no_ack[]= 500 "[%3d] WARNING: did not receive ack of last datagram after %d tries.\n"; 501 502 const char warn_ack_failed[]= 503 "[%3d] WARNING: ack of last datagram failed after %d tries.\n"; 504 505 const char warn_fileopen_failed[]= 506 "WARNING: Unable to open file stream for transfer\n\ 507 Using default data stream. \n"; 508 509 const char unable_to_change_win[]= 510 "WARNING: Unable to change the window size\n"; 511 512 const char opt_estimate[]= 513 "Optimal Estimate\n"; 514 515 const char report_interval_small[] = 516 "WARNING: interval too small, increasing from %3.2f to 0.5 seconds.\n"; 517 518 const char warn_invalid_server_option[] = 519 "WARNING: option -%c is not valid for server mode\n"; 520 521 const char warn_invalid_client_option[] = 522 "WARNING: option -%c is not valid for client mode\n"; 523 524 const char warn_invalid_compatibility_option[] = 525 "WARNING: option -%c is not valid in compatibility mode\n"; 526 527 const char warn_implied_udp[] = 528 "WARNING: option -%c implies udp testing\n"; 529 530 const char warn_implied_compatibility[] = 531 "WARNING: option -%c has implied compatibility mode\n"; 532 533 const char warn_buffer_too_small[] = 534 "WARNING: the UDP buffer was increased to %d for proper operation\n"; 535 536 const char warn_invalid_single_threaded[] = 537 "WARNING: option -%c is not valid in single threaded versions\n"; 538 539 const char warn_invalid_report_style[] = 540 "WARNING: unknown reporting style \"%s\", switching to default\n"; 541 542 const char warn_invalid_report[] = 543 "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"; 544 545 #ifdef __cplusplus 546 } /* end extern "C" */ 547 #endif 548