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
for 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
for 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?