This module provides the lwIP Iperf integration documentation.
The lwIP Iperf is a simple performance measuring bandwidth using iPerf2. The documentation for the library can be found at the following link: lwIPerf.
The following build time configurations are defined in lwip/lwip/apps/lwiperf_opts.h:
This is a basic example of minimal use of the lwIP Iperf APIs in an application.
#include "lwip/timeouts.h"
#include "lwip/init.h"
#include "lwip/netif.h"
#include "lwip/apps/lwiperf.h"
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);
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;
lwip_init();
IP4_ADDR(&ipaddr, 192, 168, 10, 4);
IP4_ADDR(&netmask, 255, 255, 255, 0);
IP4_ADDR(&gw, 192, 168, 10, 1);
netif_add(&netif, &ipaddr, &netmask, &gw, &g_lwip_ether0_instance,
rm_lwip_ether_init, netif_input);
netif_set_default(&netif);
netif_set_up(&netif);
netif_set_link_up(&netif);
lwiperf_start_tcp_server_default(lwiperf_report_example, NULL);
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;
lwip_init();
IP4_ADDR(&ipaddr, 192, 168, 10, 4);
IP4_ADDR(&netmask, 255, 255, 255, 0);
IP4_ADDR(&gw, 192, 168, 10, 1);
netif_add(&netif, &ipaddr, &netmask, &gw, &g_lwip_ether0_instance,
rm_lwip_ether_init, netif_input);
netif_set_default(&netif);
netif_set_up(&netif);
netif_set_link_up(&netif);
server_ip_address = &netif.gw;
lwiperf_start_tcp_client_default(server_ip_address, lwiperf_report_example, NULL);
while (true)
{
sys_check_timeouts();
}
}