Page 1 of 1

Wi-Fi RX packets are available in a socket only every 250ms or so.

Posted: Fri Jul 24, 2020 9:28 am
by tionebrr
Hello folks.

I made a simple TCP socket (based on the example) and the client is pushing small packets about every 10ms to 50ms. The ESP32 is in STA mode, with Power saving set to WIFI_PS_NONE. The connection is made based on the get-started STA wifi example, any other config is default from the example.

I noticed that the packets are only recv in the socket task about 4 times per seconds, and are processed by chunks. I was expecting the incoming packets to get forwarded and made available to the lwip recv at an higher frequency.

My socket task have the highest priority, and changing the priority doesn't change the behaviour.
I started to dig around trying to find a timer or something linked to lwip or wifi that would explain this, but didn't find any.

If someone has any idea, it would be great help.

Re: Wi-Fi RX packets are available in a socket only every 250ms or so.

Posted: Fri Jul 24, 2020 12:04 pm
by tionebrr
Alright, this is a bit hard to explain and I am not good enough to guide you through my code. I have made a repo with a minimal test program showing exactly the problem I have.
https://github.com/tionebrr/ESP32_tcp-socket-test

Re: Wi-Fi RX packets are available in a socket only every 250ms or so.

Posted: Fri Jul 24, 2020 8:53 pm
by ESP_Sprite
Did you try to disable power saving mode?

Re: Wi-Fi RX packets are available in a socket only every 250ms or so.

Posted: Fri Jul 24, 2020 9:48 pm
by tionebrr
ESP_Sprite wrote:
Fri Jul 24, 2020 8:53 pm
Did you try to disable power saving mode?
Yes. The demo code I posted doesn't (because it uses connect example), but the code I am working on has power saving disabled. I tried both ways also.

Did you try my demo in the repo ?

Re: Wi-Fi RX packets are available in a socket only every 250ms or so.

Posted: Sat Jul 25, 2020 2:15 am
by WiFive
Are you sure there is no delay on the sender side? Check with Wireshark?

Re: Wi-Fi RX packets are available in a socket only every 250ms or so.

Posted: Sat Jul 25, 2020 10:17 am
by tionebrr
WiFive wrote: Are you sure there is no delay on the sender side? Check with Wireshark?
I tried with different soft, and with different computers... I was sure there was no delay on this side. I was wrong indeed.
The sender TCP socket is aggregating packets together (stream protocol) and I didn't knew that.

There is a TCP socket option, TCP_NODELAY, that will solve my problems with python, but the sender software I am using is proprietary and I guess I'll not be able to set the socket correctly for it.

Thanks for the hint =)