iperf.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Iperf Example - iperf declaration
  2. This example code is in the Public Domain (or CC0 licensed, at your option.)
  3. Unless required by applicable law or agreed to in writing, this
  4. software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  5. CONDITIONS OF ANY KIND, either express or implied.
  6. */
  7. #ifndef __IPERF_H_
  8. #define __IPERF_H_
  9. #include "esp_err.h"
  10. #include "esp_types.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #define IPERF_IP_TYPE_IPV4 0
  15. #define IPERF_IP_TYPE_IPV6 1
  16. #define IPERF_TRANS_TYPE_TCP 0
  17. #define IPERF_TRANS_TYPE_UDP 1
  18. #define IPERF_FLAG_SET(cfg, flag) ((cfg) |= (flag))
  19. #define IPERF_FLAG_CLR(cfg, flag) ((cfg) &= (~(flag)))
  20. #define IPERF_FLAG_CLIENT (1)
  21. #define IPERF_FLAG_SERVER (1 << 1)
  22. #define IPERF_FLAG_TCP (1 << 2)
  23. #define IPERF_FLAG_UDP (1 << 3)
  24. #define IPERF_DEFAULT_PORT 5001
  25. #define IPERF_DEFAULT_INTERVAL 3
  26. #define IPERF_DEFAULT_TIME 30
  27. #define IPERF_DEFAULT_NO_BW_LIMIT -1
  28. #define IPERF_TRAFFIC_TASK_NAME "iperf_traffic"
  29. #define IPERF_TRAFFIC_TASK_PRIORITY 4
  30. #define IPERF_TRAFFIC_TASK_STACK 4096
  31. #define IPERF_REPORT_TASK_NAME "iperf_report"
  32. #define IPERF_REPORT_TASK_PRIORITY 6
  33. #define IPERF_REPORT_TASK_STACK 4096
  34. #define IPERF_UDP_TX_LEN (1470)
  35. #define IPERF_UDP_RX_LEN (16 << 10)
  36. #define IPERF_TCP_TX_LEN (16 << 10)
  37. #define IPERF_TCP_RX_LEN (16 << 10)
  38. #define IPERF_MAX_DELAY 64
  39. #define IPERF_SOCKET_RX_TIMEOUT 10
  40. #define IPERF_SOCKET_ACCEPT_TIMEOUT 5
  41. typedef struct {
  42. uint32_t flag;
  43. union {
  44. uint32_t destination_ip4;
  45. char *destination_ip6;
  46. };
  47. union {
  48. uint32_t source_ip4;
  49. char *source_ip6;
  50. };
  51. uint8_t type;
  52. uint16_t dport;
  53. uint16_t sport;
  54. uint32_t interval;
  55. uint32_t time;
  56. uint16_t len_send_buf;
  57. int32_t bw_lim;
  58. } iperf_cfg_t;
  59. esp_err_t iperf_start(iperf_cfg_t *cfg);
  60. esp_err_t iperf_stop(void);
  61. #ifdef __cplusplus
  62. }
  63. #endif
  64. #endif