version 1.1.1.1, 2016/10/18 13:28:18
|
version 1.1.1.2, 2021/03/17 00:36:46
|
Line 1
|
Line 1
|
/* |
/* |
* 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 |
* California, through Lawrence Berkeley National Laboratory (subject |
* to receipt of any required approvals from the U.S. Dept. of |
* to receipt of any required approvals from the U.S. Dept. of |
* Energy). All rights reserved. |
* Energy). All rights reserved. |
Line 36
|
Line 36
|
#endif |
#endif |
#include <sys/select.h> |
#include <sys/select.h> |
#include <sys/socket.h> |
#include <sys/socket.h> |
|
#ifndef _GNU_SOURCE |
|
# define _GNU_SOURCE |
|
#endif |
#include <netinet/tcp.h> |
#include <netinet/tcp.h> |
|
|
#if defined(HAVE_CPUSET_SETAFFINITY) |
#if defined(HAVE_CPUSET_SETAFFINITY) |
Line 43
|
Line 46
|
#include <sys/cpuset.h> |
#include <sys/cpuset.h> |
#endif /* HAVE_CPUSET_SETAFFINITY */ |
#endif /* HAVE_CPUSET_SETAFFINITY */ |
|
|
|
#if defined(HAVE_INTTYPES_H) |
|
# include <inttypes.h> |
|
#else |
|
# ifndef PRIu64 |
|
# if sizeof(long) == 8 |
|
# define PRIu64 "lu" |
|
# else |
|
# define PRIu64 "llu" |
|
# endif |
|
# endif |
|
#endif |
|
|
#include "timer.h" |
#include "timer.h" |
#include "queue.h" |
#include "queue.h" |
#include "cjson.h" |
#include "cjson.h" |
|
#include "iperf_time.h" |
|
|
|
#if defined(HAVE_SSL) |
|
#include <openssl/bio.h> |
|
#include <openssl/evp.h> |
|
#endif // HAVE_SSL |
|
|
|
#if !defined(__IPERF_API_H) |
typedef uint64_t iperf_size_t; |
typedef uint64_t iperf_size_t; |
|
#endif // __IPERF_API_H |
|
|
struct iperf_interval_results |
struct iperf_interval_results |
{ |
{ |
iperf_size_t bytes_transferred; /* bytes transfered in this interval */ |
iperf_size_t bytes_transferred; /* bytes transfered in this interval */ |
struct timeval interval_start_time; | struct iperf_time interval_start_time; |
struct timeval interval_end_time; | struct iperf_time interval_end_time; |
float interval_duration; |
float interval_duration; |
|
|
/* for UDP */ |
/* for UDP */ |
Line 79 struct iperf_interval_results
|
Line 102 struct iperf_interval_results
|
TAILQ_ENTRY(iperf_interval_results) irlistentries; |
TAILQ_ENTRY(iperf_interval_results) irlistentries; |
void *custom_data; |
void *custom_data; |
int rtt; |
int rtt; |
|
int rttvar; |
|
int pmtu; |
}; |
}; |
|
|
struct iperf_stream_result |
struct iperf_stream_result |
Line 97 struct iperf_stream_result
|
Line 122 struct iperf_stream_result
|
int stream_sum_rtt; |
int stream_sum_rtt; |
int stream_count_rtt; |
int stream_count_rtt; |
int stream_max_snd_cwnd; |
int stream_max_snd_cwnd; |
struct timeval start_time; | struct iperf_time start_time; |
struct timeval end_time; | struct iperf_time end_time; |
struct timeval start_time_fixed; | struct iperf_time start_time_fixed; |
| double sender_time; |
| double receiver_time; |
TAILQ_HEAD(irlisthead, iperf_interval_results) interval_results; |
TAILQ_HEAD(irlisthead, iperf_interval_results) interval_results; |
void *data; |
void *data; |
}; |
}; |
Line 110 struct iperf_settings
|
Line 137 struct iperf_settings
|
int domain; /* AF_INET or AF_INET6 */ |
int domain; /* AF_INET or AF_INET6 */ |
int socket_bufsize; /* window size for TCP */ |
int socket_bufsize; /* window size for TCP */ |
int blksize; /* size of read/writes (-l) */ |
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 burst; /* packets per burst */ |
int mss; /* for TCP MSS */ |
int mss; /* for TCP MSS */ |
int ttl; /* IP TTL option */ |
int ttl; /* IP TTL option */ |
Line 120 struct iperf_settings
|
Line 152 struct iperf_settings
|
iperf_size_t blocks; /* number of blocks (packets) to send */ |
iperf_size_t blocks; /* number of blocks (packets) to send */ |
char unit_format; /* -f */ |
char unit_format; /* -f */ |
int num_ostreams; /* SCTP initmsg settings */ |
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; |
struct iperf_test; |
Line 133 struct iperf_stream
|
Line 172 struct iperf_stream
|
int remote_port; |
int remote_port; |
int socket; |
int socket; |
int id; |
int id; |
|
int sender; |
/* XXX: is settings just a pointer to the same struct in iperf_test? if not, |
/* XXX: is settings just a pointer to the same struct in iperf_test? if not, |
should it be? */ |
should it be? */ |
struct iperf_settings *settings; /* pointer to structure settings */ |
struct iperf_settings *settings; /* pointer to structure settings */ |
Line 144 struct iperf_stream
|
Line 184 struct iperf_stream
|
int buffer_fd; /* data to send, file descriptor */ |
int buffer_fd; /* data to send, file descriptor */ |
char *buffer; /* data to send, mmapped */ |
char *buffer; /* data to send, mmapped */ |
int diskfile_fd; /* file to send, file descriptor */ |
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 |
* for udp measurements - This can be a structure outside stream, and |
* stream can have a pointer to this |
* stream can have a pointer to this |
*/ |
*/ |
int packet_count; |
int packet_count; |
|
int peer_packet_count; |
int omitted_packet_count; |
int omitted_packet_count; |
double jitter; |
double jitter; |
double prev_transit; |
double prev_transit; |
Line 198 struct xbind_entry {
|
Line 240 struct xbind_entry {
|
TAILQ_ENTRY(xbind_entry) link; |
TAILQ_ENTRY(xbind_entry) link; |
}; |
}; |
|
|
|
enum iperf_mode { |
|
SENDER = 1, |
|
RECEIVER = 0, |
|
BIDIRECTIONAL = -1 |
|
}; |
|
|
struct iperf_test |
struct iperf_test |
{ |
{ |
char role; /* 'c' lient or 's' erver */ |
char role; /* 'c' lient or 's' erver */ |
int sender; /* client & !reverse or server & reverse */ | enum iperf_mode mode; |
int sender_has_retransmits; |
int sender_has_retransmits; |
|
int other_side_has_retransmits; /* used if mode == BIDIRECTIONAL */ |
struct protocol *protocol; |
struct protocol *protocol; |
signed char state; |
signed char state; |
char *server_hostname; /* -c option */ |
char *server_hostname; /* -c option */ |
Line 219 struct iperf_test
|
Line 268 struct iperf_test
|
cpuset_t cpumask; |
cpuset_t cpumask; |
#endif /* HAVE_CPUSET_SETAFFINITY */ |
#endif /* HAVE_CPUSET_SETAFFINITY */ |
char *title; /* -T option */ |
char *title; /* -T option */ |
|
char *extra_data; /* --extra-data */ |
char *congestion; /* -C option */ |
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 *pidfile; /* -P option */ |
|
|
char *logfile; /* --logfile option */ |
char *logfile; /* --logfile option */ |
Line 229 struct iperf_test
|
Line 281 struct iperf_test
|
int listener; |
int listener; |
int prot_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 */ |
/* boolean variables for Options */ |
int daemon; /* -D option */ |
int daemon; /* -D option */ |
int one_off; /* -1 option */ |
int one_off; /* -1 option */ |
int no_delay; /* -N option */ |
int no_delay; /* -N option */ |
int reverse; /* -R option */ |
int reverse; /* -R option */ |
|
int bidirectional; /* --bidirectional */ |
int verbose; /* -V option - verbose mode */ |
int verbose; /* -V option - verbose mode */ |
int json_output; /* -J option - JSON output */ |
int json_output; /* -J option - JSON output */ |
int zerocopy; /* -Z option - use sendfile */ |
int zerocopy; /* -Z option - use sendfile */ |
int debug; /* -d option - enable debug */ |
int debug; /* -d option - enable debug */ |
int get_server_output; /* --get-server-output */ |
int get_server_output; /* --get-server-output */ |
int udp_counters_64bit; /* --use-64-bit-udp-counters */ |
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 multisend; |
|
int repeating_payload; /* --repeating-payload */ |
|
int timestamps; /* --timestamps */ |
|
char *timestamp_format; |
|
|
char *json_output_string; /* rendered JSON output if json_output is set */ |
char *json_output_string; /* rendered JSON output if json_output is set */ |
/* Select related parameters */ |
/* Select related parameters */ |
Line 268 struct iperf_test
|
Line 331 struct iperf_test
|
|
|
iperf_size_t bytes_sent; |
iperf_size_t bytes_sent; |
iperf_size_t blocks_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]; |
char cookie[COOKIE_SIZE]; |
// struct iperf_stream *streams; /* pointer to list of struct stream */ |
// struct iperf_stream *streams; /* pointer to list of struct stream */ |
SLIST_HEAD(slisthead, iperf_stream) streams; |
SLIST_HEAD(slisthead, iperf_stream) streams; |
Line 308 struct iperf_test
|
Line 380 struct iperf_test
|
#define SEC_TO_NS 1000000000LL /* too big for enum/const on some platforms */ |
#define SEC_TO_NS 1000000000LL /* too big for enum/const on some platforms */ |
#define MAX_RESULT_STRING 4096 |
#define MAX_RESULT_STRING 4096 |
|
|
|
#define UDP_BUFFER_EXTRA 1024 |
|
|
/* constants for command line arg sanity checks */ |
/* constants for command line arg sanity checks */ |
#define MB (1024 * 1024) |
#define MB (1024 * 1024) |
#define MAX_TCP_BUFFER (512 * MB) |
#define MAX_TCP_BUFFER (512 * MB) |
#define MAX_BLOCKSIZE 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 */ |
/* Maximum size UDP send is (64K - 1) - IP and UDP header sizes */ |
#define MAX_UDP_BLOCKSIZE (65535 - 8 - 20) |
#define MAX_UDP_BLOCKSIZE (65535 - 8 - 20) |
#define MIN_INTERVAL 0.1 |
#define MIN_INTERVAL 0.1 |
Line 320 struct iperf_test
|
Line 396 struct iperf_test
|
#define MAX_BURST 1000 |
#define MAX_BURST 1000 |
#define MAX_MSS (9 * 1024) |
#define MAX_MSS (9 * 1024) |
#define MAX_STREAMS 128 |
#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 */ |
#endif /* !__IPERF_H */ |