Skip to content

Commit

Permalink
example: add iperf example
Browse files Browse the repository at this point in the history
Support iperf
  • Loading branch information
liuzfesp committed Sep 26, 2017
1 parent 845c3fb commit 05b0d56
Show file tree
Hide file tree
Showing 12 changed files with 1,188 additions and 7 deletions.
34 changes: 32 additions & 2 deletions components/lwip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,36 @@ config LWIP_IP_REASSEMBLY
help
Enabling this option allows reassemblying incoming fragmented IP packets.

config LWIP_STATS
bool "Enable LWIP statistics"
default n
help
Enabling this option allows LWIP statistics

config LWIP_ETHARP_TRUST_IP_MAC
bool "Enable LWIP ARP trust"
default y
help
Enabling this option allows ARP table to be updated.

If this option is enabled, the incoming IP packets cause the ARP table to be
updated with the source MAC and IP addresses supplied in the packet.
You may want to disable this if you do not trust LAN peers to have the
correct addresses, or as a limited approach to attempt to handle
spoofing. If disabled, lwIP will need to make a new ARP request if
the peer is not already in the ARP table, adding a little latency.
The peer *is* in the ARP table if it requested our address before.
Also notice that this slows down input processing of every IP packet!


config TCPIP_RECVMBOX_SIZE
int "TCPIP receive mail box size"
default 32
range 6 64
help
Set TCPIP receive mail box size. Generally bigger value means higher throughput
but more memory. The value should be bigger than UDP/TCP mail box size.

menu "TCP"

config TCP_MAXRTX
Expand Down Expand Up @@ -131,7 +161,7 @@ config TCP_WND_DEFAULT
config TCP_RECVMBOX_SIZE
int "Default TCP receive mail box size"
default 6
range 6 32
range 6 64
help
Set TCP receive mail box size. Generally bigger value means higher throughput
but more memory. The recommended value is: TCP_WND_DEFAULT/TCP_MSS + 2, e.g. if
Expand Down Expand Up @@ -188,7 +218,7 @@ menu "UDP"
config UDP_RECVMBOX_SIZE
int "Default UDP receive mail box size"
default 6
range 6 32
range 6 64
help
Set UDP receive mail box size. The recommended value is 6.

Expand Down
20 changes: 15 additions & 5 deletions components/lwip/include/lwip/port/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@
* The queue size value itself is platform-dependent, but is passed to
* sys_mbox_new() when tcpip_init is called.
*/
#define TCPIP_MBOX_SIZE 32
#define TCPIP_MBOX_SIZE CONFIG_TCPIP_RECVMBOX_SIZE

/**
* DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
Expand Down Expand Up @@ -520,10 +520,20 @@
---------- Statistics options ----------
----------------------------------------
*/

/**
* LWIP_STATS==1: Enable statistics collection in lwip_stats.
*/
#define LWIP_STATS 0
#define LWIP_STATS CONFIG_LWIP_STATS

#if LWIP_STATS

/**
* LWIP_STATS_DISPLAY==1: Compile in the statistics output functions.
*/
#define LWIP_STATS_DISPLAY CONFIG_LWIP_STATS
#endif


/*
---------------------------------
Expand Down Expand Up @@ -674,7 +684,7 @@
* The peer *is* in the ARP table if it requested our address before.
* Also notice that this slows down input processing of every IP packet!
*/
#define ETHARP_TRUST_IP_MAC 1
#define ETHARP_TRUST_IP_MAC CONFIG_LWIP_ETHARP_TRUST_IP_MAC


/* Enable all Espressif-only options */
Expand All @@ -692,8 +702,8 @@
#define ESP_IP4_ATON 1
#define ESP_LIGHT_SLEEP 1
#define ESP_L2_TO_L3_COPY CONFIG_L2_TO_L3_COPY
#define ESP_STATS_MEM 0
#define ESP_STATS_DROP 0
#define ESP_STATS_MEM CONFIG_LWIP_STATS
#define ESP_STATS_DROP CONFIG_LWIP_STATS
#define ESP_STATS_TCP 0
#define ESP_DHCP_TIMER 1
#define ESP_LWIP_LOGI(...) ESP_LOGI("lwip", __VA_ARGS__)
Expand Down
8 changes: 8 additions & 0 deletions examples/wifi/iperf/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
# project subdirectory.
#

PROJECT_NAME := iperf

include $(IDF_PATH)/make/project.mk
52 changes: 52 additions & 0 deletions examples/wifi/iperf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Iperf Example

This example implements the protocol used by the common performance measurement tool [iPerf](https://iperf.fr/).
Performance can be measured between two ESP32s running this example, or between a single ESP32 and a computer running the iPerf tool

Demo steps to test station TCP Tx performance:

1. Build the iperf example with sdkconfig.defaults, which contains performance test specific configurations

2. Run the demo as station mode and join the target AP
sta ssid password

3. Run iperf as server on AP side
iperf -s -i 3

4. Run iperf as client on ESP32 side
iperf -c 192.168.10.42 -i 3 -t 60

The console output, which is printed by station TCP RX throughput test, looks like:

>esp32> sta aptest
>
>I (5325) iperf: sta connecting to 'aptest'
>
>esp32> I (6017) event: ip: 192.168.10.248, mask: 255.255.255.0, gw: 192.168.10.1
>
>esp32> iperf -s -i 3 -t 1000
>
>I (14958) iperf: mode=tcp-server sip=192.168.10.248:5001, dip=0.0.0.0:5001, interval=3, time=1000
>
>Interval Bandwidth
>
>esp32> accept: 192.168.10.42,62958
>
>0- 3 sec 8.43 Mbits/sec
>
>3- 6 sec 36.16 Mbits/sec
>
>6- 9 sec 36.22 Mbits/sec
>
>9- 12 sec 36.44 Mbits/sec
>
>12- 15 sec 36.25 Mbits/sec
>
>15- 18 sec 24.36 Mbits/sec
>
>18- 21 sec 27.79 Mbits/sec

Steps to test station/soft-AP TCP/UDP RX/TX throughput are similar as test steps in station TCP TX.

See the README.md file in the upper level 'examples' directory for more information about examples.
11 changes: 11 additions & 0 deletions examples/wifi/iperf/components/component.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Component Makefile
#
# This Makefile should, at the very least, just include $(SDK_PATH)/Makefile. By default,
# this will take the sources in the src/ directory, compile them and link them into
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
# please read the SDK documents if you need to do this.
#

#include $(IDF_PATH)/make/component_common.mk
COMPONENT_ADD_INCLUDEDIRS := .
Loading

0 comments on commit 05b0d56

Please sign in to comment.