RA Flexible Software Package Documentation  Release v6.3.0

 
lwIP Iperf

This module provides the lwIP Iperf integration documentation.

Overview

The lwIP Iperf is a simple performance measuring bandwidth using iPerf2. The documentation for the library can be found at the following link: lwIPerf.

Features

Configuration

Build Time Configurations for source

The following build time configurations are defined in lwip/lwip/apps/lwiperf_opts.h:

ConfigurationOptionsDefaultDescription
Idle TimeoutValue must be a positive integer value and less than or equal to 255.10 Specify the idle timeout (in seconds) after that the test fails.
lwIPerf IP version
  • IPv4
  • IPv6
  • IPv4+IPv6(Dual-stack)
IPv4+IPv6(Dual-stack) Configure whether lwIPerf listens on all IP versions.
Check format of received data
  • Enabled
  • Disabled
Disabled Enabled to verify the format of received data.

Usage Notes

Limitations

Examples

Basic Example

This is a basic example of minimal use of the lwIP Iperf APIs in an application.

Note
When using printf with e² studio, build errors may occur. Please refer to https://en-support.renesas.com/knowledgeBase/16979385 and follow Method 2, which is recommended for smooth integration and to avoid build errors.
#include "lwip/timeouts.h"
#include "lwip/init.h"
#include "lwip/netif.h"
#include "lwip/apps/lwiperf.h"
/* LwIP Iperf example */
static void lwiperf_report_example(void * arg,
enum lwiperf_report_type report_type,
const ip_addr_t * local_addr,
uint16_t local_port,
const ip_addr_t * remote_addr,
uint16_t remote_port,
uint32_t bytes_transferred,
uint32_t ms_duration,
uint32_t bandwidth_kbitpsec);
/* Define a report callback function */
static void lwiperf_report_example (void * arg,
enum lwiperf_report_type report_type,
const ip_addr_t * local_addr,
uint16_t local_port,
const ip_addr_t * remote_addr,
uint16_t remote_port,
uint32_t bytes_transferred,
uint32_t ms_duration,
uint32_t bandwidth_kbitpsec)
{
printf(
"IPERF report: type=%d, remote: %s:%u, total bytes: %" PRIu32 " bytes, duration in ms: %" PRIu32 " ms, kbits/s: %" PRIu32 " kbit/s\n",
(int) report_type,
ipaddr_ntoa(remote_addr),
(int) remote_port,
bytes_transferred,
ms_duration,
bandwidth_kbitpsec);
}
void lwip_iperf_server_example () {
struct netif netif;
ip_addr_t ipaddr;
ip_addr_t netmask;
ip_addr_t gw;
/* Initializing lwIP core. */
lwip_init();
/* Set ip address of the board. */
IP4_ADDR(&ipaddr, 192, 168, 10, 4);
IP4_ADDR(&netmask, 255, 255, 255, 0);
IP4_ADDR(&gw, 192, 168, 10, 1);
/* Initialize netif. Please pass rm_lwip_ether_init() function and the instance of rm_lwip_ether to netif_add(). */
netif_add(&netif, &ipaddr, &netmask, &gw, &g_lwip_ether0_instance, rm_lwip_ether_init, netif_input);
/* Set netif as default and enable. */
netif_set_default(&netif);
netif_set_up(&netif);
netif_set_link_up(&netif);
/* Start lwiperf server */
lwiperf_start_tcp_server_default(lwiperf_report_example, NULL);
/* Program main loop. */
while (true)
{
sys_check_timeouts();
}
}
void lwip_iperf_client_example ()
{
struct netif netif;
ip_addr_t ipaddr;
ip_addr_t netmask;
ip_addr_t gw;
ip_addr_t * server_ip_address;
/* Initializing lwIP core. */
lwip_init();
/* Set ip address of the board. */
IP4_ADDR(&ipaddr, 192, 168, 10, 4);
IP4_ADDR(&netmask, 255, 255, 255, 0);
IP4_ADDR(&gw, 192, 168, 10, 1);
/* Initialize netif. Please pass rm_lwip_ether_init() function and the instance of rm_lwip_ether to netif_add(). */
netif_add(&netif, &ipaddr, &netmask, &gw, &g_lwip_ether0_instance, rm_lwip_ether_init, netif_input);
/* Set netif as default and enable. */
netif_set_default(&netif);
netif_set_up(&netif);
netif_set_link_up(&netif);
/* Start lwiperf client */
server_ip_address = &netif.gw;
lwiperf_start_tcp_client_default(server_ip_address, lwiperf_report_example, NULL);
/* Program main loop. */
while (true)
{
sys_check_timeouts();
}
}