--- embedaddon/iperf/src/iperf.h 2016/10/18 13:28:18 1.1.1.1 +++ embedaddon/iperf/src/iperf.h 2021/03/17 00:36:46 1.1.1.2 @@ -1,5 +1,5 @@ /* - * iperf, Copyright (c) 2014, 2015, 2016, The Regents of the University of + * iperf, Copyright (c) 2014-2020, The Regents of the University of * California, through Lawrence Berkeley National Laboratory (subject * to receipt of any required approvals from the U.S. Dept. of * Energy). All rights reserved. @@ -36,6 +36,9 @@ #endif #include #include +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif #include #if defined(HAVE_CPUSET_SETAFFINITY) @@ -43,17 +46,37 @@ #include #endif /* HAVE_CPUSET_SETAFFINITY */ +#if defined(HAVE_INTTYPES_H) +# include +#else +# ifndef PRIu64 +# if sizeof(long) == 8 +# define PRIu64 "lu" +# else +# define PRIu64 "llu" +# endif +# endif +#endif + #include "timer.h" #include "queue.h" #include "cjson.h" +#include "iperf_time.h" +#if defined(HAVE_SSL) +#include +#include +#endif // HAVE_SSL + +#if !defined(__IPERF_API_H) typedef uint64_t iperf_size_t; +#endif // __IPERF_API_H struct iperf_interval_results { iperf_size_t bytes_transferred; /* bytes transfered in this interval */ - struct timeval interval_start_time; - struct timeval interval_end_time; + struct iperf_time interval_start_time; + struct iperf_time interval_end_time; float interval_duration; /* for UDP */ @@ -79,6 +102,8 @@ struct iperf_interval_results TAILQ_ENTRY(iperf_interval_results) irlistentries; void *custom_data; int rtt; + int rttvar; + int pmtu; }; struct iperf_stream_result @@ -97,9 +122,11 @@ struct iperf_stream_result int stream_sum_rtt; int stream_count_rtt; int stream_max_snd_cwnd; - struct timeval start_time; - struct timeval end_time; - struct timeval start_time_fixed; + struct iperf_time start_time; + struct iperf_time end_time; + struct iperf_time start_time_fixed; + double sender_time; + double receiver_time; TAILQ_HEAD(irlisthead, iperf_interval_results) interval_results; void *data; }; @@ -110,7 +137,12 @@ struct iperf_settings int domain; /* AF_INET or AF_INET6 */ int socket_bufsize; /* window size for TCP */ int blksize; /* size of read/writes (-l) */ - uint64_t rate; /* target data rate */ + iperf_size_t rate; /* target data rate for application pacing*/ + iperf_size_t bitrate_limit; /* server's maximum allowed total data rate for all streams*/ + double bitrate_limit_interval; /* interval for avaraging total data rate */ + int bitrate_limit_stats_per_interval; /* calculated number of stats periods for averaging total data rate */ + uint64_t fqrate; /* target data rate for FQ pacing*/ + int pacing_timer; /* pacing timer in microseconds */ int burst; /* packets per burst */ int mss; /* for TCP MSS */ int ttl; /* IP TTL option */ @@ -120,6 +152,13 @@ struct iperf_settings iperf_size_t blocks; /* number of blocks (packets) to send */ char unit_format; /* -f */ int num_ostreams; /* SCTP initmsg settings */ +#if defined(HAVE_SSL) + char *authtoken; /* Authentication token */ + char *client_username; + char *client_password; + EVP_PKEY *client_rsa_pubkey; +#endif // HAVE_SSL + int connect_timeout; /* socket connection timeout, in ms */ }; struct iperf_test; @@ -133,6 +172,7 @@ struct iperf_stream int remote_port; int socket; int id; + int sender; /* XXX: is settings just a pointer to the same struct in iperf_test? if not, should it be? */ struct iperf_settings *settings; /* pointer to structure settings */ @@ -144,12 +184,14 @@ struct iperf_stream int buffer_fd; /* data to send, file descriptor */ char *buffer; /* data to send, mmapped */ int diskfile_fd; /* file to send, file descriptor */ + int diskfile_left; /* remaining file data on disk */ /* * for udp measurements - This can be a structure outside stream, and * stream can have a pointer to this */ int packet_count; + int peer_packet_count; int omitted_packet_count; double jitter; double prev_transit; @@ -198,11 +240,18 @@ struct xbind_entry { TAILQ_ENTRY(xbind_entry) link; }; +enum iperf_mode { + SENDER = 1, + RECEIVER = 0, + BIDIRECTIONAL = -1 +}; + struct iperf_test { char role; /* 'c' lient or 's' erver */ - int sender; /* client & !reverse or server & reverse */ + enum iperf_mode mode; int sender_has_retransmits; + int other_side_has_retransmits; /* used if mode == BIDIRECTIONAL */ struct protocol *protocol; signed char state; char *server_hostname; /* -c option */ @@ -219,7 +268,10 @@ struct iperf_test cpuset_t cpumask; #endif /* HAVE_CPUSET_SETAFFINITY */ char *title; /* -T option */ + char *extra_data; /* --extra-data */ char *congestion; /* -C option */ + char *congestion_used; /* what was actually used */ + char *remote_congestion_used; /* what the other side used */ char *pidfile; /* -P option */ char *logfile; /* --logfile option */ @@ -229,19 +281,30 @@ struct iperf_test int listener; int prot_listener; + int ctrl_sck_mss; /* MSS for the control channel */ + +#if defined(HAVE_SSL) + char *server_authorized_users; + EVP_PKEY *server_rsa_private_key; +#endif // HAVE_SSL + /* boolean variables for Options */ int daemon; /* -D option */ int one_off; /* -1 option */ int no_delay; /* -N option */ int reverse; /* -R option */ + int bidirectional; /* --bidirectional */ int verbose; /* -V option - verbose mode */ int json_output; /* -J option - JSON output */ int zerocopy; /* -Z option - use sendfile */ int debug; /* -d option - enable debug */ int get_server_output; /* --get-server-output */ int udp_counters_64bit; /* --use-64-bit-udp-counters */ - int no_fq_socket_pacing; /* --no-fq-socket-pacing */ + int forceflush; /* --forceflush - flushing output at every interval */ int multisend; + int repeating_payload; /* --repeating-payload */ + int timestamps; /* --timestamps */ + char *timestamp_format; char *json_output_string; /* rendered JSON output if json_output is set */ /* Select related parameters */ @@ -268,6 +331,15 @@ struct iperf_test iperf_size_t bytes_sent; iperf_size_t blocks_sent; + + iperf_size_t bytes_received; + iperf_size_t blocks_received; + + iperf_size_t bitrate_limit_stats_count; /* Number of stats periods accumulated for server's total bitrate average */ + iperf_size_t *bitrate_limit_intervals_traffic_bytes; /* Pointer to a cyclic array that includes the last interval's bytes transferred */ + iperf_size_t bitrate_limit_last_interval_index; /* Index of the last interval traffic insrted into the cyclic array */ + int bitrate_limit_exceeded; /* Set by callback routine when average data rate exceeded the server's bitrate limit */ + char cookie[COOKIE_SIZE]; // struct iperf_stream *streams; /* pointer to list of struct stream */ SLIST_HEAD(slisthead, iperf_stream) streams; @@ -308,10 +380,14 @@ struct iperf_test #define SEC_TO_NS 1000000000LL /* too big for enum/const on some platforms */ #define MAX_RESULT_STRING 4096 +#define UDP_BUFFER_EXTRA 1024 + /* constants for command line arg sanity checks */ #define MB (1024 * 1024) #define MAX_TCP_BUFFER (512 * MB) #define MAX_BLOCKSIZE MB +/* Minimum size UDP send is the size of two 32-bit ints followed by a 64-bit int */ +#define MIN_UDP_BLOCKSIZE (4 + 4 + 8) /* Maximum size UDP send is (64K - 1) - IP and UDP header sizes */ #define MAX_UDP_BLOCKSIZE (65535 - 8 - 20) #define MIN_INTERVAL 0.1 @@ -320,5 +396,9 @@ struct iperf_test #define MAX_BURST 1000 #define MAX_MSS (9 * 1024) #define MAX_STREAMS 128 + +#define TIMESTAMP_FORMAT "%c " + +extern int gerror; /* error value from getaddrinfo(3), for use in internal error handling */ #endif /* !__IPERF_H */