jonask1337 / esp-idf-nat-example

ESP-IDF example project with NAT setup.
83 stars 15 forks source link

How to increase speed? #9

Closed DynamicLoader closed 4 years ago

DynamicLoader commented 4 years ago

The NAT speed is not very fast.When download,it can run at 700KB/s for a very short time. most of the time is 200KB/s,even 90KB/s.So I want to increase speed.

What should I do? Change the lwip settings?

Thanks.

jonask1337 commented 4 years ago

With the default sdkconfig you should normally get ~10 MBit/s download. (This depends of course also a lot on your internet connection and setup).

You can improve the speed by enlarge the WiFi and TCP receive and transmit buffers. With the following changes made to the sdkconfig I was able to get ~16MBit/s download speed:

       # Component config -> LWIP
       CONFIG_ESP32_WIFI_IRAM_OPT=y

       # Component config -> LWIP -> TCP
       CONFIG_TCP_SND_BUF_DEFAULT=65534
       CONFIG_TCP_WND_DEFAULT=65534
       CONFIG_TCP_RECVMBOX_SIZE=64

       # Component config -> WiFi
       CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=16
       CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=64
       CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=64
       CONFIG_ESP32_WIFI_TX_BA_WIN=32
       CONFIG_ESP32_WIFI_RX_BA_WIN=32

As basis for these changes I used the sdkconfig from here: https://github.com/espressif/esp-idf/blob/master/examples/wifi/iperf/sdkconfig.ci.99