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