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 27
|
Line 27
|
#ifndef __IPERF_API_H |
#ifndef __IPERF_API_H |
#define __IPERF_API_H |
#define __IPERF_API_H |
|
|
|
#include <sys/socket.h> |
#include <sys/time.h> |
#include <sys/time.h> |
#include <setjmp.h> |
#include <setjmp.h> |
|
#include <stdio.h> |
|
#ifdef HAVE_STDINT_H |
|
#include <stdint.h> |
|
#endif |
|
#ifdef __cplusplus |
|
extern "C" { /* open extern "C" */ |
|
#endif |
|
|
|
|
struct iperf_test; |
struct iperf_test; |
struct iperf_stream_result; |
struct iperf_stream_result; |
struct iperf_interval_results; |
struct iperf_interval_results; |
struct iperf_stream; |
struct iperf_stream; |
|
struct iperf_time; |
|
|
|
#if !defined(__IPERF_H) |
|
typedef uint64_t iperf_size_t; |
|
#endif // __IPERF_H |
|
|
/* default settings */ |
/* default settings */ |
#define Ptcp SOCK_STREAM |
#define Ptcp SOCK_STREAM |
#define Pudp SOCK_DGRAM |
#define Pudp SOCK_DGRAM |
#define Psctp 12 |
#define Psctp 12 |
#define DEFAULT_UDP_BLKSIZE 8192 | #define DEFAULT_UDP_BLKSIZE 1460 /* default is dynamically set, else this */ |
#define DEFAULT_TCP_BLKSIZE (128 * 1024) /* default read/write block size */ |
#define DEFAULT_TCP_BLKSIZE (128 * 1024) /* default read/write block size */ |
#define DEFAULT_SCTP_BLKSIZE (64 * 1024) |
#define DEFAULT_SCTP_BLKSIZE (64 * 1024) |
|
|
Line 50 struct iperf_stream;
|
Line 64 struct iperf_stream;
|
#define OPT_UDP_COUNTERS_64BIT 4 |
#define OPT_UDP_COUNTERS_64BIT 4 |
#define OPT_CLIENT_PORT 5 |
#define OPT_CLIENT_PORT 5 |
#define OPT_NUMSTREAMS 6 |
#define OPT_NUMSTREAMS 6 |
#define OPT_NO_FQ_SOCKET_PACING 9 | #define OPT_FORCEFLUSH 7 |
| #define OPT_NO_FQ_SOCKET_PACING 9 /* UNUSED */ |
| #define OPT_FQ_RATE 10 |
| #define OPT_DSCP 11 |
| #define OPT_CLIENT_USERNAME 12 |
| #define OPT_CLIENT_RSA_PUBLIC_KEY 13 |
| #define OPT_SERVER_RSA_PRIVATE_KEY 14 |
| #define OPT_SERVER_AUTHORIZED_USERS 15 |
| #define OPT_PACING_TIMER 16 |
| #define OPT_CONNECT_TIMEOUT 17 |
| #define OPT_REPEATING_PAYLOAD 18 |
| #define OPT_EXTRA_DATA 19 |
| #define OPT_BIDIRECTIONAL 20 |
| #define OPT_SERVER_BITRATE_LIMIT 21 |
| #define OPT_TIMESTAMPS 22 |
|
|
/* states */ |
/* states */ |
#define TEST_START 1 |
#define TEST_START 1 |
#define TEST_RUNNING 2 |
#define TEST_RUNNING 2 |
#define RESULT_REQUEST 3 | #define RESULT_REQUEST 3 /* not used */ |
#define TEST_END 4 |
#define TEST_END 4 |
#define STREAM_BEGIN 5 | #define STREAM_BEGIN 5 /* not used */ |
#define STREAM_RUNNING 6 | #define STREAM_RUNNING 6 /* not used */ |
#define STREAM_END 7 | #define STREAM_END 7 /* not used */ |
#define ALL_STREAMS_END 8 | #define ALL_STREAMS_END 8 /* not used */ |
#define PARAM_EXCHANGE 9 |
#define PARAM_EXCHANGE 9 |
#define CREATE_STREAMS 10 |
#define CREATE_STREAMS 10 |
#define SERVER_TERMINATE 11 |
#define SERVER_TERMINATE 11 |
Line 82 int iperf_get_test_reverse( struct iperf_test* ipt );
|
Line 110 int iperf_get_test_reverse( struct iperf_test* ipt );
|
int iperf_get_test_blksize( struct iperf_test* ipt ); |
int iperf_get_test_blksize( struct iperf_test* ipt ); |
FILE* iperf_get_test_outfile( struct iperf_test* ipt ); |
FILE* iperf_get_test_outfile( struct iperf_test* ipt ); |
uint64_t iperf_get_test_rate( struct iperf_test* ipt ); |
uint64_t iperf_get_test_rate( struct iperf_test* ipt ); |
|
int iperf_get_test_pacing_timer( struct iperf_test* ipt ); |
|
uint64_t iperf_get_test_bytes( struct iperf_test* ipt ); |
|
uint64_t iperf_get_test_blocks( struct iperf_test* ipt ); |
int iperf_get_test_burst( struct iperf_test* ipt ); |
int iperf_get_test_burst( struct iperf_test* ipt ); |
int iperf_get_test_socket_bufsize( struct iperf_test* ipt ); |
int iperf_get_test_socket_bufsize( struct iperf_test* ipt ); |
double iperf_get_test_reporter_interval( struct iperf_test* ipt ); |
double iperf_get_test_reporter_interval( struct iperf_test* ipt ); |
double iperf_get_test_stats_interval( struct iperf_test* ipt ); |
double iperf_get_test_stats_interval( struct iperf_test* ipt ); |
int iperf_get_test_num_streams( struct iperf_test* ipt ); |
int iperf_get_test_num_streams( struct iperf_test* ipt ); |
|
int iperf_get_test_repeating_payload( struct iperf_test* ipt ); |
|
int iperf_get_test_timestamps( struct iperf_test* ipt ); |
|
const char* iperf_get_test_timestamp_format( struct iperf_test* ipt ); |
int iperf_get_test_server_port( struct iperf_test* ipt ); |
int iperf_get_test_server_port( struct iperf_test* ipt ); |
char* iperf_get_test_server_hostname( struct iperf_test* ipt ); |
char* iperf_get_test_server_hostname( struct iperf_test* ipt ); |
char* iperf_get_test_template( struct iperf_test* ipt ); |
char* iperf_get_test_template( struct iperf_test* ipt ); |
Line 98 int iperf_get_test_get_server_output( struct iperf_tes
|
Line 132 int iperf_get_test_get_server_output( struct iperf_tes
|
char* iperf_get_test_bind_address ( struct iperf_test* ipt ); |
char* iperf_get_test_bind_address ( struct iperf_test* ipt ); |
int iperf_get_test_udp_counters_64bit( struct iperf_test* ipt ); |
int iperf_get_test_udp_counters_64bit( struct iperf_test* ipt ); |
int iperf_get_test_one_off( struct iperf_test* ipt ); |
int iperf_get_test_one_off( struct iperf_test* ipt ); |
|
int iperf_get_test_tos( struct iperf_test* ipt ); |
|
char* iperf_get_extra_data( struct iperf_test* ipt ); |
|
char* iperf_get_iperf_version(void); |
|
int iperf_get_test_no_delay( struct iperf_test* ipt ); |
|
int iperf_get_test_connect_timeout( struct iperf_test* ipt ); |
|
|
/* Setter routines for some fields inside iperf_test. */ |
/* Setter routines for some fields inside iperf_test. */ |
void iperf_set_verbose( struct iperf_test* ipt, int verbose ); |
void iperf_set_verbose( struct iperf_test* ipt, int verbose ); |
Line 108 void iperf_set_test_reporter_interval( struct iperf_te
|
Line 147 void iperf_set_test_reporter_interval( struct iperf_te
|
void iperf_set_test_stats_interval( struct iperf_test* ipt, double stats_interval ); |
void iperf_set_test_stats_interval( struct iperf_test* ipt, double stats_interval ); |
void iperf_set_test_state( struct iperf_test* ipt, signed char state ); |
void iperf_set_test_state( struct iperf_test* ipt, signed char state ); |
void iperf_set_test_blksize( struct iperf_test* ipt, int blksize ); |
void iperf_set_test_blksize( struct iperf_test* ipt, int blksize ); |
|
void iperf_set_test_logfile( struct iperf_test* ipt, const char *logfile ); |
void iperf_set_test_rate( struct iperf_test* ipt, uint64_t rate ); |
void iperf_set_test_rate( struct iperf_test* ipt, uint64_t rate ); |
|
void iperf_set_test_pacing_timer( struct iperf_test* ipt, int pacing_timer ); |
|
void iperf_set_test_bytes( struct iperf_test* ipt, uint64_t bytes ); |
|
void iperf_set_test_blocks( struct iperf_test* ipt, uint64_t blocks ); |
void iperf_set_test_burst( struct iperf_test* ipt, int burst ); |
void iperf_set_test_burst( struct iperf_test* ipt, int burst ); |
void iperf_set_test_server_port( struct iperf_test* ipt, int server_port ); |
void iperf_set_test_server_port( struct iperf_test* ipt, int server_port ); |
void iperf_set_test_socket_bufsize( struct iperf_test* ipt, int socket_bufsize ); |
void iperf_set_test_socket_bufsize( struct iperf_test* ipt, int socket_bufsize ); |
void iperf_set_test_num_streams( struct iperf_test* ipt, int num_streams ); |
void iperf_set_test_num_streams( struct iperf_test* ipt, int num_streams ); |
|
void iperf_set_test_repeating_payload( struct iperf_test* ipt, int repeating_payload ); |
|
void iperf_set_test_timestamps( struct iperf_test* ipt, int timestamps ); |
|
void iperf_set_test_timestamp_format( struct iperf_test*, const char *tf ); |
void iperf_set_test_role( struct iperf_test* ipt, char role ); |
void iperf_set_test_role( struct iperf_test* ipt, char role ); |
void iperf_set_test_server_hostname( struct iperf_test* ipt, char* server_hostname ); | void iperf_set_test_server_hostname( struct iperf_test* ipt, const char* server_hostname ); |
void iperf_set_test_template( struct iperf_test *ipt, char *tmp_template ); | void iperf_set_test_template( struct iperf_test *ipt, const char *tmp_template ); |
void iperf_set_test_reverse( struct iperf_test* ipt, int reverse ); |
void iperf_set_test_reverse( struct iperf_test* ipt, int reverse ); |
void iperf_set_test_json_output( struct iperf_test* ipt, int json_output ); |
void iperf_set_test_json_output( struct iperf_test* ipt, int json_output ); |
int iperf_has_zerocopy( void ); |
int iperf_has_zerocopy( void ); |
void iperf_set_test_zerocopy( struct iperf_test* ipt, int zerocopy ); |
void iperf_set_test_zerocopy( struct iperf_test* ipt, int zerocopy ); |
void iperf_set_test_get_server_output( struct iperf_test* ipt, int get_server_output ); |
void iperf_set_test_get_server_output( struct iperf_test* ipt, int get_server_output ); |
void iperf_set_test_bind_address( struct iperf_test* ipt, char *bind_address ); | void iperf_set_test_bind_address( struct iperf_test* ipt, const char *bind_address ); |
void iperf_set_test_udp_counters_64bit( struct iperf_test* ipt, int udp_counters_64bit ); |
void iperf_set_test_udp_counters_64bit( struct iperf_test* ipt, int udp_counters_64bit ); |
void iperf_set_test_one_off( struct iperf_test* ipt, int one_off ); |
void iperf_set_test_one_off( struct iperf_test* ipt, int one_off ); |
|
void iperf_set_test_tos( struct iperf_test* ipt, int tos ); |
|
void iperf_set_test_extra_data( struct iperf_test* ipt, const char *dat ); |
|
void iperf_set_test_bidirectional( struct iperf_test* ipt, int bidirectional); |
|
void iperf_set_test_no_delay( struct iperf_test* ipt, int no_delay); |
|
|
|
#if defined(HAVE_SSL) |
|
void iperf_set_test_client_username(struct iperf_test *ipt, const char *client_username); |
|
void iperf_set_test_client_password(struct iperf_test *ipt, const char *client_password); |
|
void iperf_set_test_client_rsa_pubkey(struct iperf_test *ipt, const char *client_rsa_pubkey_base64); |
|
void iperf_set_test_server_authorized_users(struct iperf_test *ipt, const char *server_authorized_users); |
|
void iperf_set_test_server_rsa_privkey(struct iperf_test *ipt, const char *server_rsa_privkey_base64); |
|
#endif // HAVE_SSL |
|
|
|
void iperf_set_test_connect_timeout(struct iperf_test *ipt, int ct); |
|
|
/** |
/** |
* exchange_parameters - handles the param_Exchange part for client |
* exchange_parameters - handles the param_Exchange part for client |
* |
* |
Line 162 void iperf_reporter_callback(struct iperf_test * t
|
Line 222 void iperf_reporter_callback(struct iperf_test * t
|
* returns NULL on failure |
* returns NULL on failure |
* |
* |
*/ |
*/ |
struct iperf_test *iperf_new_test(); | struct iperf_test *iperf_new_test(void); |
|
|
int iperf_defaults(struct iperf_test * testp); |
int iperf_defaults(struct iperf_test * testp); |
|
|
Line 179 void iperf_free_test(struct iperf_test * testp);
|
Line 239 void iperf_free_test(struct iperf_test * testp);
|
* returns NULL on failure |
* returns NULL on failure |
* |
* |
*/ |
*/ |
struct iperf_stream *iperf_new_stream(struct iperf_test *, int); | struct iperf_stream *iperf_new_stream(struct iperf_test *, int, int); |
|
|
/** |
/** |
* iperf_add_stream -- add a stream to a test |
* iperf_add_stream -- add a stream to a test |
Line 205 void save_tcpinfo(struct iperf_stream *sp, struct iper
|
Line 265 void save_tcpinfo(struct iperf_stream *sp, struct iper
|
long get_total_retransmits(struct iperf_interval_results *irp); |
long get_total_retransmits(struct iperf_interval_results *irp); |
long get_snd_cwnd(struct iperf_interval_results *irp); |
long get_snd_cwnd(struct iperf_interval_results *irp); |
long get_rtt(struct iperf_interval_results *irp); |
long get_rtt(struct iperf_interval_results *irp); |
|
long get_rttvar(struct iperf_interval_results *irp); |
|
long get_pmtu(struct iperf_interval_results *irp); |
void print_tcpinfo(struct iperf_test *test); |
void print_tcpinfo(struct iperf_test *test); |
void build_tcpinfo_message(struct iperf_interval_results *r, char *message); |
void build_tcpinfo_message(struct iperf_interval_results *r, char *message); |
|
|
int iperf_set_send_state(struct iperf_test *test, signed char state); |
int iperf_set_send_state(struct iperf_test *test, signed char state); |
void iperf_check_throttle(struct iperf_stream *sp, struct timeval *nowP); | void iperf_check_throttle(struct iperf_stream *sp, struct iperf_time *nowP); |
int iperf_send(struct iperf_test *, fd_set *) /* __attribute__((hot)) */; |
int iperf_send(struct iperf_test *, fd_set *) /* __attribute__((hot)) */; |
int iperf_recv(struct iperf_test *, fd_set *); |
int iperf_recv(struct iperf_test *, fd_set *); |
void iperf_catch_sigend(void (*handler)(int)); |
void iperf_catch_sigend(void (*handler)(int)); |
void iperf_got_sigend(struct iperf_test *test) __attribute__ ((noreturn)); |
void iperf_got_sigend(struct iperf_test *test) __attribute__ ((noreturn)); |
void usage(); | void usage(void); |
void usage_long(); | void usage_long(FILE * f); |
void warning(char *); | void warning(const char *); |
int iperf_exchange_results(struct iperf_test *); |
int iperf_exchange_results(struct iperf_test *); |
int iperf_init_test(struct iperf_test *); |
int iperf_init_test(struct iperf_test *); |
int iperf_create_send_timers(struct iperf_test *); |
int iperf_create_send_timers(struct iperf_test *); |
int iperf_parse_arguments(struct iperf_test *, int, char **); |
int iperf_parse_arguments(struct iperf_test *, int, char **); |
|
int iperf_open_logfile(struct iperf_test *); |
void iperf_reset_test(struct iperf_test *); |
void iperf_reset_test(struct iperf_test *); |
void iperf_reset_stats(struct iperf_test * test); |
void iperf_reset_stats(struct iperf_test * test); |
|
|
Line 237 extern jmp_buf env;
|
Line 300 extern jmp_buf env;
|
/* Client routines. */ |
/* Client routines. */ |
int iperf_run_client(struct iperf_test *); |
int iperf_run_client(struct iperf_test *); |
int iperf_connect(struct iperf_test *); |
int iperf_connect(struct iperf_test *); |
int iperf_create_streams(struct iperf_test *); | int iperf_create_streams(struct iperf_test *, int sender); |
int iperf_handle_message_client(struct iperf_test *); |
int iperf_handle_message_client(struct iperf_test *); |
int iperf_client_end(struct iperf_test *); |
int iperf_client_end(struct iperf_test *); |
|
|
Line 246 int iperf_run_server(struct iperf_test *);
|
Line 309 int iperf_run_server(struct iperf_test *);
|
int iperf_server_listen(struct iperf_test *); |
int iperf_server_listen(struct iperf_test *); |
int iperf_accept(struct iperf_test *); |
int iperf_accept(struct iperf_test *); |
int iperf_handle_message_server(struct iperf_test *); |
int iperf_handle_message_server(struct iperf_test *); |
void iperf_test_reset(struct iperf_test *); |
|
int iperf_create_pidfile(struct iperf_test *); |
int iperf_create_pidfile(struct iperf_test *); |
int iperf_delete_pidfile(struct iperf_test *); |
int iperf_delete_pidfile(struct iperf_test *); |
|
void iperf_check_total_rate(struct iperf_test *, iperf_size_t); |
|
|
/* JSON output routines. */ |
/* JSON output routines. */ |
int iperf_json_start(struct iperf_test *); |
int iperf_json_start(struct iperf_test *); |
Line 259 int iperf_setaffinity(struct iperf_test *, int affinit
|
Line 322 int iperf_setaffinity(struct iperf_test *, int affinit
|
int iperf_clearaffinity(struct iperf_test *); |
int iperf_clearaffinity(struct iperf_test *); |
|
|
/* Custom printf routine. */ |
/* Custom printf routine. */ |
int iprintf(struct iperf_test *test, const char *format, ...) __attribute__ ((format(printf,2,3))); | int iperf_printf(struct iperf_test *test, const char *format, ...) __attribute__ ((format(printf,2,3))); |
int iflush(struct iperf_test *test); |
int iflush(struct iperf_test *test); |
|
|
/* Error routines. */ |
/* Error routines. */ |
Line 288 enum {
|
Line 351 enum {
|
IEENDCONDITIONS = 16, // Only one test end condition (-t, -n, -k) may be specified |
IEENDCONDITIONS = 16, // Only one test end condition (-t, -n, -k) may be specified |
IELOGFILE = 17, // Can't open log file |
IELOGFILE = 17, // Can't open log file |
IENOSCTP = 18, // No SCTP support available |
IENOSCTP = 18, // No SCTP support available |
IEBIND = 19, // Local port specified with no local bind option | IEBIND = 19, // UNUSED: Local port specified with no local bind option |
IEUDPBLOCKSIZE = 20, // Block size too large. Maximum value = %dMAX_UDP_BLOCKSIZE | IEUDPBLOCKSIZE = 20, // Block size invalid |
IEBADTOS = 21, // Bad TOS value |
IEBADTOS = 21, // Bad TOS value |
|
IESETCLIENTAUTH = 22, // Bad configuration of client authentication |
|
IESETSERVERAUTH = 23, // Bad configuration of server authentication |
|
IEBADFORMAT = 24, // Bad format argument to -f |
|
IEREVERSEBIDIR = 25, // Iperf cannot be both reverse and bidirectional |
|
IEBADPORT = 26, // Bad port number |
|
IETOTALRATE = 27, // Total required bandwidth is larger than server's limit |
|
IETOTALINTERVAL = 28, // Invalid time interval for calculating average data rate |
/* Test errors */ |
/* Test errors */ |
IENEWTEST = 100, // Unable to create a new test (check perror) |
IENEWTEST = 100, // Unable to create a new test (check perror) |
IEINITTEST = 101, // Test initialization failed (check perror) |
IEINITTEST = 101, // Test initialization failed (check perror) |
Line 333 enum {
|
Line 403 enum {
|
IESETSCTPNSTREAM= 138, // Unable to set SCTP number of streams (check perror) |
IESETSCTPNSTREAM= 138, // Unable to set SCTP number of streams (check perror) |
IESETSCTPBINDX= 139, // Unable to process sctp_bindx() parameters |
IESETSCTPBINDX= 139, // Unable to process sctp_bindx() parameters |
IESETPACING= 140, // Unable to set socket pacing rate |
IESETPACING= 140, // Unable to set socket pacing rate |
|
IESETBUF2= 141, // Socket buffer size incorrect (written value != read value) |
|
IEAUTHTEST = 142, // Test authorization failed |
/* Stream errors */ |
/* Stream errors */ |
IECREATESTREAM = 200, // Unable to create a new stream (check herror/perror) |
IECREATESTREAM = 200, // Unable to create a new stream (check herror/perror) |
IEINITSTREAM = 201, // Unable to initialize stream (check herror/perror) |
IEINITSTREAM = 201, // Unable to initialize stream (check herror/perror) |
Line 347 enum {
|
Line 419 enum {
|
IENEWTIMER = 300, // Unable to create new timer (check perror) |
IENEWTIMER = 300, // Unable to create new timer (check perror) |
IEUPDATETIMER = 301, // Unable to update timer (check perror) |
IEUPDATETIMER = 301, // Unable to update timer (check perror) |
}; |
}; |
|
|
|
|
|
#ifdef __cplusplus |
|
} /* close extern "C" */ |
|
#endif |
|
|
|
|
#endif /* !__IPERF_API_H */ |
#endif /* !__IPERF_API_H */ |