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.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Init OS objects and default contents
sl_iperf_test_add#
bool sl_iperf_test_add (sl_iperf_test_t *const test)
Add the iPerf test to the execution queue.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_iperf_test_t *const | [in] | test | Test descriptor |
Add test to the input messagequeue. Returns
true On Success
false On Failure
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.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_iperf_test_t *const | [out] | test | Destination test descriptor |
const uint32_t | [in] | timeout_ms | Timeout for getting test from messagequeue |
Get the test from the output messagequeue. Returns
true On Success
false On Failure
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.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_iperf_test_t *const | [inout] | test | Test descriptor |
sl_iperf_mode_t | [in] | mode | Mode |
sl_iperf_protocol_t | [in] | protocol | Protocol |
Initialize a test descriptor with default content
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.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_iperf_test_t *const | [out] | test | Test descriptor |
Helper function
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.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_iperf_test_t *const | [out] | test | Test descriptor |
Helper function
sl_iperf_test_udp_client#
void sl_iperf_test_udp_client (sl_iperf_test_t * test)
Execute the iPerf UDP client test.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_iperf_test_t * | [inout] | test | Test descriptor |
iPerf UDP client test.
sl_iperf_test_udp_server#
void sl_iperf_test_udp_server (sl_iperf_test_t * test)
Execute the iPerf UDP server test.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_iperf_test_t * | [inout] | test | Test descriptor |
iPerf UDP server test.