Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
zperf.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Intel Corporation
3 * Copyright (c) 2022 Nordic Semiconductor ASA
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
18
19#ifndef ZEPHYR_INCLUDE_NET_ZPERF_H_
20#define ZEPHYR_INCLUDE_NET_ZPERF_H_
21
22#include <zephyr/net/net_ip.h>
23#include <zephyr/net/socket.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
30
31enum zperf_status {
32 ZPERF_SESSION_STARTED,
33 ZPERF_SESSION_PERIODIC_RESULT,
34 ZPERF_SESSION_FINISHED,
35 ZPERF_SESSION_ERROR
36} __packed;
37
49typedef int (*zperf_data_load_custom)(void *user_ctx, uint64_t offset,
50 uint8_t *data, uint32_t len);
51
52struct zperf_upload_params {
53 uint64_t unix_offset_us;
54 zperf_data_load_custom data_loader;
55 void *data_loader_ctx;
57 union {
59 struct net_sockaddr_storage peer_addr_storage;
61 /* Use the peer_addr_storage instead of this one. */
62 struct net_sockaddr peer_addr;
64 };
65 uint32_t duration_ms;
66 uint32_t rate_kbps;
67 uint16_t packet_size;
68 char if_name[NET_IFNAMSIZ];
69 struct {
70 uint8_t tos;
71 int tcp_nodelay;
72 int priority;
73#ifdef CONFIG_ZPERF_SESSION_PER_THREAD
74 int thread_priority;
75 bool wait_for_start;
76#endif
77 uint32_t report_interval_ms;
78 } options;
79};
80
81struct zperf_download_params {
82 uint16_t port;
84 union {
86 struct net_sockaddr_storage addr_storage;
88 /* Use the addr_storage instead of this one. */
89 struct net_sockaddr addr;
91 };
92 char if_name[NET_IFNAMSIZ];
93};
94
95#ifdef CONFIG_NET_ZPERF_RAW_TX
111struct zperf_raw_upload_params {
112 uint32_t duration_ms;
113 uint32_t rate_kbps;
114 uint16_t packet_size;
115 uint8_t *hdr;
116 uint16_t hdr_len;
117 int if_index;
118};
119#endif /* CONFIG_NET_ZPERF_RAW_TX */
120
122
137
145typedef void (*zperf_callback)(enum zperf_status status,
146 struct zperf_results *result,
147 void *user_data);
148
158int zperf_udp_upload(const struct zperf_upload_params *param,
159 struct zperf_results *result);
160
170int zperf_tcp_upload(const struct zperf_upload_params *param,
171 struct zperf_results *result);
172
185int zperf_udp_upload_async(const struct zperf_upload_params *param,
186 zperf_callback callback, void *user_data);
187
200int zperf_tcp_upload_async(const struct zperf_upload_params *param,
201 zperf_callback callback, void *user_data);
202
214int zperf_udp_download(const struct zperf_download_params *param,
215 zperf_callback callback, void *user_data);
216
228int zperf_tcp_download(const struct zperf_download_params *param,
229 zperf_callback callback, void *user_data);
230
237
244
245#ifdef CONFIG_NET_ZPERF_RAW_TX
255int zperf_raw_upload(const struct zperf_raw_upload_params *param,
256 struct zperf_results *result);
257
270int zperf_raw_upload_async(const struct zperf_raw_upload_params *param,
271 zperf_callback callback, void *user_data);
272#endif /* CONFIG_NET_ZPERF_RAW_TX */
273
274#ifdef __cplusplus
275}
276#endif
277
281
282#endif /* ZEPHYR_INCLUDE_NET_ZPERF_H_ */
int zperf_tcp_upload_async(const struct zperf_upload_params *param, zperf_callback callback, void *user_data)
Asynchronous TCP upload operation.
int zperf_tcp_upload(const struct zperf_upload_params *param, struct zperf_results *result)
Synchronous TCP upload operation.
int zperf_udp_download_stop(void)
Stop UDP server.
int zperf_udp_upload(const struct zperf_upload_params *param, struct zperf_results *result)
Synchronous UDP upload operation.
int zperf_tcp_download(const struct zperf_download_params *param, zperf_callback callback, void *user_data)
Start TCP server.
int zperf_udp_download(const struct zperf_download_params *param, zperf_callback callback, void *user_data)
Start UDP server.
int zperf_tcp_download_stop(void)
Stop TCP server.
int zperf_udp_upload_async(const struct zperf_upload_params *param, zperf_callback callback, void *user_data)
Asynchronous UDP upload operation.
void(* zperf_callback)(enum zperf_status status, struct zperf_results *result, void *user_data)
Zperf callback function used for asynchronous operations.
Definition zperf.h:145
BSD Sockets compatible API definitions.
IPv6 and IPv4 definitions.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Performance results.
Definition zperf.h:124
uint64_t total_len
Total length of the transferred data.
Definition zperf.h:129
uint64_t client_time_in_us
Client connection time in microseconds.
Definition zperf.h:132
uint32_t nb_packets_errors
Number of packet errors.
Definition zperf.h:134
uint32_t packet_size
Packet size.
Definition zperf.h:133
bool is_multicast
True if this session used IP multicast.
Definition zperf.h:135
uint32_t nb_packets_outorder
Number of packets out of order.
Definition zperf.h:128
uint64_t time_in_us
Total time of the transfer in microseconds.
Definition zperf.h:130
uint32_t nb_packets_lost
Number of packets lost.
Definition zperf.h:127
uint32_t nb_packets_rcvd
Number of packets received.
Definition zperf.h:126
uint32_t nb_packets_sent
Number of packets sent.
Definition zperf.h:125
uint32_t jitter_in_us
Jitter in microseconds.
Definition zperf.h:131