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);
}