You can chat about native SDK questions and issues here.

User avatar
By supergiox
#62734 Hi,
I noticed bad network performance on all of my ESP projects. In particular, when I send a sequence of small packets, the first is slow (delivered in ~100 ms) and all the subsequent are fast (~2 ms). Until the packets are sent at a high rate (> 1 per second) they are delivered quickly, but if I send them "occasionally" there is this bad latency.

Initially I thought it was related to the TCP Nagle algorithm, so I tried with ping (ICMP).
If I ping the ESP from a PC, also in this case the delay depends on the ping rate.

Ping rate: 10 per second
Code: Select allfor i in $(seq 1 100); do ping -c 1 192.168.1.141 | grep icmp | cut -d' ' -f7; sleep .1; done

time=215
time=198
time=115
time=2.49
time=1.40
time=1.32
time=1.38
time=1.30
time=1.37
time=1.46
time=1.39
time=2.48
time=8.21
time=3.39
time=1.39
time=1.32
time=1.35


Ping rate: 1 every 3 seconds
Code: Select allfor i in $(seq 1 100); do ping -c 1 192.168.1.141 | grep icmp | cut -d' ' -f7; sleep 3; done

time=160
time=63.7
time=215
time=1.78
time=123
time=90.6
time=87.3
time=1.58
time=119
time=62.0
time=55.2
time=64.6
time=61.7
time=61.9
time=58.0
time=59.2
time=112


Then I tried several projects, including one that only consist on connecting to my Wi-Fi AP. I tried almost all versions of SDK, NON_OS_SDK and esp-open-sdk, always with same results. I also tested it with other Wi-Fi APs.

And now the strangest part: I replaced my firmware with the AT Firmware binary (compiled by Espressif) and the ping is always fast (1-2 ms)!

What am I doing wrong? Can you tell me if you have this latency too?
User avatar
By toni
#83075 Hi all,

yes it is. With esp8266 and arduino-ide ping shows 5-6ms latency, while the same code on esp32 shows a strange delay like:

64 bytes from 192.168.10.205: icmp_seq=91 ttl=255 time=30.6 ms
64 bytes from 192.168.10.205: icmp_seq=92 ttl=255 time=53.2 ms
64 bytes from 192.168.10.205: icmp_seq=93 ttl=255 time=74.4 ms
64 bytes from 192.168.10.205: icmp_seq=94 ttl=255 time=97.3 ms
64 bytes from 192.168.10.205: icmp_seq=95 ttl=255 time=118 ms
64 bytes from 192.168.10.205: icmp_seq=96 ttl=255 time=143 ms
64 bytes from 192.168.10.205: icmp_seq=97 ttl=255 time=165 ms
64 bytes from 192.168.10.205: icmp_seq=98 ttl=255 time=188 ms
64 bytes from 192.168.10.205: icmp_seq=99 ttl=255 time=209 ms
64 bytes from 192.168.10.205: icmp_seq=100 ttl=255 time=28.4 ms
64 bytes from 192.168.10.205: icmp_seq=101 ttl=255 time=52.0 ms
64 bytes from 192.168.10.205: icmp_seq=102 ttl=255 time=74.9 ms
64 bytes from 192.168.10.205: icmp_seq=103 ttl=255 time=105 ms
64 bytes from 192.168.10.205: icmp_seq=104 ttl=255 time=127 ms
64 bytes from 192.168.10.205: icmp_seq=105 ttl=255 time=139 ms
64 bytes from 192.168.10.205: icmp_seq=106 ttl=255 time=164 ms
64 bytes from 192.168.10.205: icmp_seq=107 ttl=255 time=185 ms
64 bytes from 192.168.10.205: icmp_seq=108 ttl=255 time=210 ms
64 bytes from 192.168.10.205: icmp_seq=109 ttl=255 time=26.3 ms
64 bytes from 192.168.10.205: icmp_seq=110 ttl=255 time=50.2 ms
64 bytes from 192.168.10.205: icmp_seq=111 ttl=255 time=73.2 ms
64 bytes from 192.168.10.205: icmp_seq=112 ttl=255 time=93.2 ms
64 bytes from 192.168.10.205: icmp_seq=113 ttl=255 time=116 ms
64 bytes from 192.168.10.205: icmp_seq=114 ttl=255 time=138 ms
64 bytes from 192.168.10.205: icmp_seq=115 ttl=255 time=171 ms
64 bytes from 192.168.10.205: icmp_seq=116 ttl=255 time=185 ms
64 bytes from 192.168.10.205: icmp_seq=117 ttl=255 time=215 ms
64 bytes from 192.168.10.205: icmp_seq=118 ttl=255 time=34.2 ms

But just here https://github.com/espressif/arduino-esp32/issues/1484 there is the solution:

#include "esp_wifi.h"
WiFi.mode(WIFI_STA);
esp_wifi_set_ps (WIFI_PS_NONE);

and it disables power saving in esp32, so ping becomes "normal":

64 bytes from 192.168.10.205: icmp_seq=1 ttl=255 time=9.87 ms
64 bytes from 192.168.10.205: icmp_seq=2 ttl=255 time=6.19 ms
64 bytes from 192.168.10.205: icmp_seq=3 ttl=255 time=6.16 ms
64 bytes from 192.168.10.205: icmp_seq=4 ttl=255 time=7.30 ms
64 bytes from 192.168.10.205: icmp_seq=5 ttl=255 time=6.94 ms
64 bytes from 192.168.10.205: icmp_seq=6 ttl=255 time=7.66 ms
64 bytes from 192.168.10.205: icmp_seq=7 ttl=255 time=5.73 ms
64 bytes from 192.168.10.205: icmp_seq=8 ttl=255 time=5.74 ms
64 bytes from 192.168.10.205: icmp_seq=9 ttl=255 time=5.77 ms
64 bytes from 192.168.10.205: icmp_seq=10 ttl=255 time=7.18 ms

Two days to find it, wtf.

Thanks.