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: 2 comments 6 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.
-
After a month, I have given up. But I have found out some things about this problem. I will document my findings here, and maybe someone smarter than me could pick up from where I left off. The latency comes from queue buildup. This explains why the latency starts small and rises over time. Using the new RTOS buffered library did take a chunk off of the initial latency spike, but the fact that the latency increases to an unuseable state still remains true. The queue buildup seems to originate from the transmitter, not the receiver. I tried my best to monitor the queue buildup before the final I do not know enough about the core library to start diagnosing this problem, nor am i smart enough to confirm/deny anything. I tried to "spoof" the core library by setting the address to FF:FF:FF:FF:FF:FF, but nothing notable changed. I don't think that i successfully spoofed the library, and it still knows that it's in unicast mode. I did find a band-aid solution to this problem. I added a function to flush the queue if the queue got too long. Running this function on the receiver side "prevented" the latency buildup and decreased the latency drastically. If someone stumbles upon this problem, I hope that this will help. Also, sorry about the rambling. |
Beta Was this translation helpful? Give feedback.
After a month, I have given up. But I have found out some things about this problem. I will document my findings here, and maybe someone smarter than me could pick up from where I left off.
The latency comes from queue buildup. This explains why the latency starts small and rises over time. Using the new RTOS buffered library did take a chunk off of the initial latency spike, but the fact that the latency increases to an unuseable state still remains true.
The queue buildup seems to originate from the transmitter, not the receiver.
I monitored the espnow queue on the receiver side, and the data came in with the queue already built up/delayed. Also, resetting/rebooting the receiver did not…