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#

Configurations

Type definitions

Portable interface

Functions#

void

Initialize the iPerf service.

bool
sl_iperf_test_add(sl_iperf_test_t *const test)

Add the iPerf test to the execution queue.

bool
sl_iperf_test_get(sl_iperf_test_t *const test, const uint32_t timeout_ms)

Get the iPerf test from the result queue.

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.

void
sl_iperf_test_set_default_buff(sl_iperf_test_t *const test)

Set the default internal test buffer.

void
sl_iperf_test_set_default_logger(sl_iperf_test_t *const test)

Set the default internal logger for the test descriptor.

void
sl_iperf_test_udp_client(sl_iperf_test_t *test)

Execute the iPerf UDP client test.

void
sl_iperf_test_udp_server(sl_iperf_test_t *test)

Execute the iPerf UDP server test.

Macros#

#define
SL_IPERF_HEADER_EPOCH_START (0x00001000UL)

iPerf header epoch start mask

#define
SL_IPERF_HEADER_EXTEND (0x40000000UL)

iPerf header extended mask

#define
SL_IPERF_HEADER_SEQNO64B (0x08000000UL)

iPerf header seqno 64bit mask

#define
SL_IPERF_HEADER_TIME_MODE (0x80000000UL)

iPerf header time mode mask

#define
SL_IPERF_HEADER_TRIPTIME (0x00000010UL)

iPerf header triptime mask

#define
SL_IPERF_HEADER_UDPTEST (0x20000000UL)

iPerf header UDP test mask

#define
SL_IPERF_HEADER_VERSION1 (0x80000000UL)

iPerf header version1 mask

#define
SL_IPERF_HEADER_VERSION2 (0x04000000UL)

iPerf header version2 mask

#define
SL_IPERF_SERVER_UDP_TX_FINACK_COUNT (10U)

iPerf Server TX FINACK max count to retry

#define
SL_IPERF_UDP_SERVER_FIN_ACK_SIZE (128U)

iPerf UDP server final ack size

Function Documentation#

sl_iperf_service_init#

void sl_iperf_service_init (void )

Initialize the iPerf service.

Parameters
TypeDirectionArgument NameDescription
voidN/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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
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.

Parameters
TypeDirectionArgument NameDescription
sl_iperf_test_t *[inout]test

Test descriptor

iPerf UDP server test.