ESPNow - Disabling ACK packets increases latency? #1918
-
Hi, I am trying to send audio over ESPNOW, and for more throughput and less latency, I have decided to try disabling acknowledgement packets. My theory was that by skipping the whole handshake phase, we could achieve more throughput and less latency for the cost of less audio quality or artifacts. I also noticed that the latency increased over time. Over a period of about 20 seconds right after power cycling both the transmitter and the receiver at the same time, I noticed that there was a gradual increase in delay. For my tests, the default latency (when ACK packets were enabled) was about 25ms. When disabled the ACK packets, the latency jumped to about 60ms on startup, which gradually increased to about 80ms. I have disabled the ACK packets by doing Also, while trying to solve this issue, I have made a small change in within `default_recv_cb` in `ESPNowStream.h`:changed from
to
Although this did remove most of the latency buildup, It did not remove the original increase in latency. Now, at least in my setup, the latency stays at around 60ms. I think the latency comes from a blocking function somewhere that waits for the now non-existant ACK packets. However, although I might be missing something, I could not find any blocking functions that expect ACK packets within the How would I remove the extra latency that happens when |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
If the latency is too big, you should try to minimize the buffers in the whole processing chain: e.g. the buffer_size and buffer_count in I2S and ESPNow are a bit big to be on the save side and you can try to optimize this considerably. The use_send_ack in ESPNow is critical to prevent a buffer overflow assuming the sending speed is above the playback speed. If you remove it you need to do 2 things:
Alternatively you could try to save the received data in PSRAM if the sending file is small enought. Maybe it is also an option to save it in a File, but I don't know about the limitations of writing and reading from a file at the same time. ps. I think the delay(1) is important to process some other tasks. |
Beta Was this translation helpful? Give feedback.
If the latency is too big, you should try to minimize the buffers in the whole processing chain: e.g. the buffer_size and buffer_count in I2S and ESPNow are a bit big to be on the save side and you can try to optimize this considerably.
The use_send_ack in ESPNow is critical to prevent a buffer overflow assuming the sending speed is above the playback speed. If you remove it you need to do 2 things: