60 lines
1.2 KiB
C
60 lines
1.2 KiB
C
#ifndef IPERF_H
|
|
#define IPERF_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#define IPERF_FLAG_CLIENT (1 << 0)
|
|
#define IPERF_FLAG_SERVER (1 << 1)
|
|
#define IPERF_FLAG_TCP (1 << 2)
|
|
#define IPERF_FLAG_UDP (1 << 3)
|
|
|
|
#define IPERF_DEFAULT_PORT 5001
|
|
#define IPERF_DEFAULT_INTERVAL 3
|
|
#define IPERF_DEFAULT_TIME 30
|
|
#define IPERF_TRAFFIC_TASK_PRIORITY 4
|
|
#define IPERF_REPORT_TASK_PRIORITY 5
|
|
|
|
#define IPERF_SOCKET_RX_TIMEOUT 10
|
|
#define IPERF_SOCKET_ACCEPT_TIMEOUT 5
|
|
|
|
#define IPERF_UDP_TX_LEN (1470)
|
|
#define IPERF_UDP_RX_LEN (16 << 10)
|
|
#define IPERF_TCP_TX_LEN (16 << 10)
|
|
#define IPERF_TCP_RX_LEN (16 << 10)
|
|
|
|
typedef struct {
|
|
uint32_t flag;
|
|
uint8_t type;
|
|
uint16_t dip;
|
|
uint16_t dport;
|
|
uint16_t sport;
|
|
uint32_t interval;
|
|
uint32_t time;
|
|
uint16_t bw_lim;
|
|
uint32_t buffer_len;
|
|
} iperf_cfg_t;
|
|
|
|
typedef struct {
|
|
uint64_t total_len;
|
|
uint32_t buffer_len;
|
|
uint32_t sockfd;
|
|
uint32_t actual_len;
|
|
uint32_t packet_count;
|
|
uint8_t *buffer;
|
|
uint32_t udp_lost_counter;
|
|
uint32_t udp_packet_counter;
|
|
} iperf_traffic_t;
|
|
|
|
// UDP header for iperf
|
|
typedef struct {
|
|
int32_t id;
|
|
uint32_t tv_sec;
|
|
uint32_t tv_usec;
|
|
} udp_datagram;
|
|
|
|
void iperf_start(iperf_cfg_t *cfg);
|
|
void iperf_stop(void);
|
|
|
|
#endif // IPERF_H
|