-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Ping fluctuations #6664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
After my search I came out here WiFiGeneric.cpp, I'm thinking of a memory problem and maybe caused by a timout. |
When I run WiFi on core 0 the fluctuate sooner bigger. And than it stabilizes and than pops up much bigger, but less over time. I tried with these settings too
it stills occur.
|
I set the log to verbose, nothing is shown. I found this about how wifi works And than I cam out here that includes FreeRTOS The task of the event running on the same core as the task I am running, during selecting core0 a see a difference in timing. |
It have to be something that is running in the background and runs on core0. Why could it be that if the WiFi runs on an other core and the breaks get soo long above the 200. It even cuts the data off from a stream (core independent), but the clock keeps running. |
I m ended in FreeRTOS. This is called form the ESP and I think that the buffer takes longer than expected to allocated in to the memory, because something else is called that takes long... or it want to take the same place. And because there is data been lost, I think it's the place that has been taken. There most be priority for the buffer! Anyway that memory has to be preserved for the buffer. There is something I have done and that is serial... Which can not be turned off, but it's a start. The serial monitor works for both cores and ends up one pin gpio 3. And if we run the wifi on core0 it need to switch from core0 to core1. it starts to make sens now. It more constant, but when it happens it get more clear. |
I have set WIFI_TASK_CORE_ID to 1 in esp_wifi.h, task in to 0. The biggest number I ever had is 81ms, The varriation could be 23ms. but that is not in the standaard deviation, that is normaly around 9ms. I diden't measure the beginnings because the doesn't count for me. I think this is the best number I ever had. By setting my task to core0 and set the WIFI_TASK_CORE_ID to 0 I get a corrupted backtrace after a few package received. So I changing back to default. Now strang things happens... Task core1 199ms at most, verry bad setting Task core1 (default) I cot a corruped backtrace (few package received and crash) Task core0 I got a corruped backtrace (few package received and crash) Task core 0 I got a corruped backtrace (few package received and crash) Task core 0 78ms at most. Task core 1 169ms at most Note: the package where still sending when I changed the settings uploaded and rebooted. I did changed the setting in the library it self and diden't set CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1. This can be the causes the corrupted backtracé. If I set it in to my sketch it doesn't recognize it and esp_wifi_init. If somebody know how to do it, I would be glad to know! The UART running on to the default core. And the something that triggers FreeTROS to put UART information from core0 in to core1. Still the antenna is not only receiving data but is also transmitting data. Switching between transmitting and receiving happens really fast if the transmitting is not the same amount data than the receiving, like most cases (including mine). What I do see as that switching between cores doesn't go that fast. Thing to do: Test a connection without DHCP. |
I always wondered why the ping times for the ESP32 is in general higher as for ESP32-S2, S3 and C3. |
The probebly have a beter design, but I m curious... Could you try the shetch, let it run for 10 min and and post your worst results? |
Further test with the esp32 devkit tells me that the urart not causing this breaks. I m testing now my stream, and it still breaks with loop core0 and WiFi_event to core1, so 60ms is still to much. But it doesn't cuttoff anymore. That's a good thing. For me it's clear that the software is the solution to solve this... Still wondering why I can't set the loop and the event on the same core, core0. If I would have less than 16ms for every package, I think it would work. |
Spoken to soon, it still breaks. Probably on the 60ms, because the occure after a couple minuts. It is like it running out of sync... |
This surprises me in the WiFiGeneric.h...
Why deleting it, when the connection is still open? |
Ok, I did some measurement. It doesn't take time to create a task a task on a other core and it doesn't take time to delete a task. @Jason2866 My mistake, switching cores doesn't take time. If you say that an S doesn't have that issue. than it could be board driver related, but we be still not sure. wifi is under 2.0.3-RC1\tools\sdk\esp32\include\esp_wifi\include. other board other esp_wifi. Mistery unsolved |
I know that WiFi uses LWIP layer to perform networking protocols, and the main point here, buffering and memory allocation. But there is a caveat... using less memory for LWIP implies in performance downgrade. Unfortunately, it is beyond Arduino Layer and demands understanding LWIP setup and configuration. |
Here is where the memory allocation happens and it is possible to change buffers size, static x dynamic buffers and so on. You can maybe play with it in your machine... just to see if you can reach to a configuration that works best for your applications. In order to be able to use such parameter, the Arduino Sketch shall use This is the general order of execution for using WiFi.useStaticBuffers(true);
WiFi.mode(WIFI_MODE_STA);
WiFi.begin("SSID", "Password"); |
Another option, as said, is to convert it to an IDF project using Arduino as Component and then try changing such LWIP parameters using ESP-IDF MenuConfig. Anyway, as also said, current Arduino Framework configuration goes in the direction of a nice general network performance, for simple and low latency network usage, with higest possible HEAP availability to users. It can't be changed by API at this time. |
First of all, thanks to take your time to replying this observation. Actually I have two point I am working on. This is performance, right... And there is memory. I already looked in how to save memorie as much as I can be choosing addition software that doesn't use to much in order to handel my big stream. So I afraid I am a bit stuck here with the memorie. I know the configmenu from python, but I rader like to program in Arduino. That where my most code are. It is sad that it can't be configt in the Arduino environment. However, I could try to change it in python, look at the settings of LWIP (keep the change) and edit it like it is generated with python. But indeed unfortunately it is not in the arduino so I can not test with it. I did already tried with static buffer to true, but that wasn't engough. I will try to increase CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 I am going to set it to 44 and do the ping test... it didn't changed the fact that sometimes there is a delay in it. And it happens really soon and decrease again and increases again and so on... I tried every setting... also static buffer and increasing the size. Every time it causes a delay no matter how big the packages are. I tried also package of 32bytes and the delay stays! And than I was wondering if it was because there is something connected to it. And without anything connected to it still happens now and than. |
Does anybody knows what is called in the background, that take an enormes time? I m starting to thing back it is wifigeneric. because when I cause a bad receiving position I see that delay to after some time! I think that after a connection has ben established it does something and repeated it self ( but not time depended). |
Not sure about what is called in the background, but just a thought. Edit: esp_bluedroid_disable();
esp_bluedroid_deinit();
esp_bt_controller_disable();
esp_bt_controller_deinit(); But maybe this is not enough? |
Powersave to false for the wifi didn't help ether... |
This is the thing we have to look for and where there is no log in it. |
Since it is not size depended I don't think that tcpip would make a difference. |
wow. Looking at some crazy things now... I did set the esp in a position long enough until the connection was lost.
I will do the test over and see if I can repeat it... Now it takes longer for the esp32 to see that the connection has been lost. Before it reconnects itself.
Even the autoreconnect was not showed on that moment. It was after a minute that autoreconnect shows up.
|
What does this line it to my log??? And this line
I am not connecting to a server or a beacon. I just did WiFi.begin and logged in and tested with the connection lost and pinged it. |
It does a number of things, the callback is repeatedly called.
I checkt if the callback causes the delay, but it isn't even called... |
And what do we get now, without any change... host not been reached.
|
I just tested connecting to the wifi without internet (Begin() without ssid and pass). Same issue |
Changing the dchp to static doesn't change anything. And I don't know how to use less to test the connection , if I don't get input on this. But I am wondering why such a big portMAX_DELAY...
If someone can setup an own connection without using wifi.h I would be glad to test the shetch. But I think it is a task that is running independ from the wifi connection that causing this delay. If I could use a less as possible library's we could maybe have a clue. And it something big. Because sometimes it takes a lot of time to handle. |
is it removed from the Queue??? I see an infant loop.
I let you decide if it deleted after it has been received... I see the data is released and the callback is completed. but the loop is still there. Don't know if there is an other callback in the make. |
I can be wrong, but I think that loop keeps running, and that it never been properly deleted.
But still it is an event call that isn't called that much
I still can't find where the data comes in. |
If I delete the task after the data is received I get some realy bad timings.
|
Forgot to set a break |
@podaen - Is this issue about ping reaction time? |
yes ping, yes wlan. |
OK, Ping wil be processed by ESP32 Cores along with all other tasks and peripherals ISRs. I think that more important than the ping response time is how the main application performance is doing. |
I propose a different topology: Esp32 in AP mode and another in STA mode. One connected to each other. Ping times are now stored in a array (no DBG printing when getting ping times). STA pings AP. This may give you a better and cleaner perspective. |
Yeah, it would be a proper way to test it more precice, but hunderd ms for serial monitor once arround the few minutes? According to me it could be done more fluwedly. Normally the pings are really amazing for such little resources. |
Hmmm, strange... I see delays of 100ms when I ping from my pc to the dns server too. @SuGlider I will try like you advice me. It blows my mind now. |
The issue is related ONLY to a ESP32. Tested with a ESP32-solo1 and i had never a Ping >15ms. Most was always around 6ms. Not a single timeout. |
When pinging with a computer with a high data consumption it causes a delay. That was the reason why it took so long to get there. |
Board
DOIT ESP32 devkit v4
Device Description
N
Hardware Configuration
I2S audio output
Version
latest development Release Candidate (RC-X)
IDE Name
1.8.19
Operating System
windows10
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
115200
Description
I am making a program that involves url audio streams and starting to notist that it starts fluctuating in filling the buffer.
By doing a ping test I see once the response start to be fluctuating above 200ms and it doesn't recover. And that is what I see in my stream too.
Can it not been made that the ping is not fluctuating so much?? I got this problem also in WiFiclient.h and WiFiClientSecure.h, but I think this is not where the issue is.
Sketch
Debug Message
Other Steps to Reproduce
See also
pschatzmann/arduino-audio-tools#180
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: