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

tionebrr
Posts: 8
Joined: Mon Jul 20, 2020 3:16 pm

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

Postby tionebrr » Fri Jul 24, 2020 9:28 am

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.

tionebrr
Posts: 8
Joined: Mon Jul 20, 2020 3:16 pm

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

Postby tionebrr » Fri Jul 24, 2020 12:04 pm

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

ESP_Sprite
Posts: 9719
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Fri Jul 24, 2020 8:53 pm

Did you try to disable power saving mode?

tionebrr
Posts: 8
Joined: Mon Jul 20, 2020 3:16 pm

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

Postby tionebrr » Fri Jul 24, 2020 9:48 pm

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 ?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

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

Postby WiFive » Sat Jul 25, 2020 2:15 am

Are you sure there is no delay on the sender side? Check with Wireshark?

tionebrr
Posts: 8
Joined: Mon Jul 20, 2020 3:16 pm

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

Postby tionebrr » Sat Jul 25, 2020 10:17 am

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 =)

Who is online

Users browsing this forum: Google [Bot] and 73 guests