-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Revisiting WiFi Connection Speed (<200ms with static ip + bssid+ channel, 1.5-2 secs without static IP) #11139
Comments
There's a lot of variables in WiFi connection that are outside of the control of the ESP device. Looking at verbose logs will let you see some of them, but a full understanding of the transaction will require a wireshark. I can see on my esp32 logs that the WiFi negotiation only takes about 100ms. Then, on first connection, DHCP negotiation takes about 3.5sec. On a restart, where the lease can be reused, DHCP only takes 100ms. From this, I can conclude that most of the time is spent by the AP (which is the DHCPd) figuring out a valid address and committing it to memory, not in getting that info back to the esp32. |
Got it, thanks! In my tests, the time difference seemed fairly consistent so I was curious whether any of the scan related parameter was at play. |
scan related parameters? I don't see any scanning in your code. I ran the simplest connection code possible with verbose logging
I get this in the logs:
That gap between STA_CONNECTED and the finish of GOT_IP is the DHCP transaction. Any extra code other than that simple begin is unnecessary (well, some error checking is good). If you aren't allowing the device to save the wifi connection information (which includes the lease info), then that will slow your connection down. |
By scan, I meant channel scan before connecting. I ran verbose with and without static IP, and I see what you mean. Connecting to wifi_ssid (with static settings)
Connecting to wifi_ssid (dhcp) with WiFi.persistent(true);
I would have thought that after the first dhcp connect, subsequent connections would be faster with persistent(true), but timing remains the same over repeated sleep/wake/connects. WiFi.begin(ssid, password, channel, bssid, 1); Seems to be performing about 800ms faster than WiFi.begin(ssid, password); Connecting with WiFi.begin(ssid, password);
Not sure what those error mean, but it does connect. |
You would need to wireshark (or have logs on the DHCPd) to see exactly what is going on in the dhcp negotiation. But, it seems like the slowdown is not on the esp32. |
Board
ESP32 Dev Module
Device Description
ESP32 Dev Module
Hardware Configuration
Base Board with no peripherals.
Version
latest master (checkout manually)
IDE Name
Arduino IDE 2.3.4
Operating System
Windows 11
Flash frequency
80
PSRAM enabled
no
Upload speed
921600
Description
I am working on a battery powered application, hence connection speed to wifi is being tested. I have gone through 1675, but wanted to check if there has been any changes (for good or bad) in this context.
Is the almost 10x time disparity between static ip and dhcp expected?
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: