iPerf#
The iPerf component offers a solution compatible with iPerf2 for measuring UDP throughput. It provides comprehensive UDP support and implements both server and client modes, enabling the exchange of packets to assess bandwidth performance, inter-arrival jitter, and packet loss. The component relies on various functions, to configure and execute your iPerf test. Parameters such as the server and client ports, preferred bandwidth, packet count, and remote peer address can be customized. Upon completion of each iPerf test, an iPerf report is generated.
To integrate the iPerf component into the application, simply add it to the project and initialize it using sl_iperf_service_init().
The following examples show how you can initialize a iPerf server and then an iPerf client
#include <string.h>
#include "cmsis_os2.h"
#include "sl_iperf.h"
#include "sl_iperf_util.h"
static void exec_iperf_server(void) {
sl_iperf_test_t srv_test = { 0 };
// Initialize Server test
sl_iperf_test_init(&srv_test, SL_IPERF_MODE_SERVER, SL_IPERF_IPROTOV6_UDP);
// Set minimum time duration for the test
srv_test.opt.duration_ms = 10000;
// Add the test to the execution queue
if (sl_iperf_test_add(&srv_test) == false) {
// Error handling
return;
}
// Waiting for the test result
if (sl_iperf_test_get(&srv_test, osWaitForever) == false) {
// Error handling
return;
}
// Print the result in JSON format
sl_iperf_print_test_log_json(&srv_test);
}
static void exec_iperf_client(void)
{
sl_iperf_test_t clnt_test = { 0 };
// Initialize Client test
sl_iperf_test_init(&clnt_test, SL_IPERF_MODE_CLIENT, SL_IPERF_IPROTOV6_UDP);
// Configure test parameters
// Set the remote server address
strncpy(clnt_test.opt.remote_addr, "2001:db8::1", SL_IPERF_IP_STR_BUFF_LEN);
// Set the bandwidth to 10 kBit/s
clnt_test.opt.bandwidth = 10000;
// Add the test to the execution queue
if (sl_iperf_test_add(&clnt_test) == false) {
// Error handling
return;
}
// Waiting for the test result
if (sl_iperf_test_get(&clnt_test, osWaitForever) == false) {
// Error handling
return;
}
// Print the result in JSON format
sl_iperf_print_test_log_json(&clnt_test);
}
Modules#
Functions#
Initialize the iPerf service.
Add the iPerf test to the execution queue.
Get the iPerf test from the result queue.
Initialize the iPerf test.
Set the default internal test buffer.
Set the default internal logger for the test descriptor.
Execute the iPerf UDP client test.
Execute the iPerf UDP server test.
Macros#
iPerf header epoch start mask
iPerf header extended mask
iPerf header seqno 64bit mask
iPerf header time mode mask
iPerf header triptime mask
iPerf header UDP test mask
iPerf header version1 mask
iPerf header version2 mask
iPerf Server TX FINACK max count to retry
iPerf UDP server final ack size
Function Documentation#
sl_iperf_service_init#
void sl_iperf_service_init (void )
Initialize the iPerf service.
N/A |
Init OS objects and default contents
99
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
sl_iperf_test_add#
bool sl_iperf_test_add (sl_iperf_test_t *const test)
Add the iPerf test to the execution queue.
[in] | test | Test descriptor |
Add test to the input messagequeue. Returns
true On Success
false On Failure
134
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
sl_iperf_test_get#
bool sl_iperf_test_get (sl_iperf_test_t *const test, const uint32_t timeout_ms)
Get the iPerf test from the result queue.
[out] | test | Destination test descriptor |
[in] | timeout_ms | Timeout for getting test from messagequeue |
Get the test from the output messagequeue. Returns
true On Success
false On Failure
144
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
sl_iperf_test_init#
void sl_iperf_test_init (sl_iperf_test_t *const test, sl_iperf_mode_t mode, sl_iperf_protocol_t protocol)
Initialize the iPerf test.
[inout] | test | Test descriptor |
[in] | mode | Mode |
[in] | protocol | Protocol |
Initialize a test descriptor with default content
108
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
sl_iperf_test_set_default_buff#
void sl_iperf_test_set_default_buff (sl_iperf_test_t *const test)
Set the default internal test buffer.
[out] | test | Test descriptor |
Helper function
124
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
sl_iperf_test_set_default_logger#
void sl_iperf_test_set_default_logger (sl_iperf_test_t *const test)
Set the default internal logger for the test descriptor.
[out] | test | Test descriptor |
Helper function
117
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
sl_iperf_test_udp_client#
void sl_iperf_test_udp_client (sl_iperf_test_t * test)
Execute the iPerf UDP client test.
[inout] | test | Test descriptor |
iPerf UDP client test.
65
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_udp_clnt.h
sl_iperf_test_udp_server#
void sl_iperf_test_udp_server (sl_iperf_test_t * test)
Execute the iPerf UDP server test.
[inout] | test | Test descriptor |
iPerf UDP server test.
65
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf_udp_srv.h
Macro Definition Documentation#
SL_IPERF_HEADER_EPOCH_START#
#define SL_IPERF_HEADER_EPOCH_STARTValue:
(0x00001000UL)
iPerf header epoch start mask
75
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
SL_IPERF_HEADER_EXTEND#
#define SL_IPERF_HEADER_EXTENDValue:
(0x40000000UL)
iPerf header extended mask
66
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
SL_IPERF_HEADER_SEQNO64B#
#define SL_IPERF_HEADER_SEQNO64BValue:
(0x08000000UL)
iPerf header seqno 64bit mask
69
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
SL_IPERF_HEADER_TIME_MODE#
#define SL_IPERF_HEADER_TIME_MODEValue:
(0x80000000UL)
iPerf header time mode mask
81
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
SL_IPERF_HEADER_TRIPTIME#
#define SL_IPERF_HEADER_TRIPTIMEValue:
(0x00000010UL)
iPerf header triptime mask
78
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
SL_IPERF_HEADER_UDPTEST#
#define SL_IPERF_HEADER_UDPTESTValue:
(0x20000000UL)
iPerf header UDP test mask
72
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
SL_IPERF_HEADER_VERSION1#
#define SL_IPERF_HEADER_VERSION1Value:
(0x80000000UL)
iPerf header version1 mask
60
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
SL_IPERF_HEADER_VERSION2#
#define SL_IPERF_HEADER_VERSION2Value:
(0x04000000UL)
iPerf header version2 mask
63
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
SL_IPERF_SERVER_UDP_TX_FINACK_COUNT#
#define SL_IPERF_SERVER_UDP_TX_FINACK_COUNTValue:
(10U)
iPerf Server TX FINACK max count to retry
84
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h
SL_IPERF_UDP_SERVER_FIN_ACK_SIZE#
#define SL_IPERF_UDP_SERVER_FIN_ACK_SIZEValue:
(128U)
iPerf UDP server final ack size
57
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/iperf/sl_iperf.h