Skip to content
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

Can edge-dhcp be used as dhcp client with esp-wifi instead of the default there using smoltcp? #55

Open
yanshay opened this issue Jan 13, 2025 · 3 comments

Comments

@yanshay
Copy link

yanshay commented Jan 13, 2025

Background:
I'm using esp32s3 and esp-wifi and face issues getting IP via dhcp when using esp-wifi when several access points serve the SSID (when there is coverage from several AP's). If I enable that SSID on only one of the access points it works.
I discussed this with the esp-hal team in esp-rs/esp-hal#2345 and eventually after a long discussion it looked like unclear behavior in processing dhcp messages on my network and I was told that to debug need to start from smoltcp (esp-rs/esp-hal#2345 (reply in thread)).
I filed an issue with smoltcp at smoltcp-rs/smoltcp#1017 but there was no response for some time.

And the question is:
I noticed this repo has edge-dhcp which is supposed to provide also a dhcp client. So I wondered if I could try and use it instead of the smoltcp one that's in use by esp-wifi by default?

Or maybe, given you have the expertise, you can think of reasons why would DHCP fail under multiple AP's when it's working when only one is serving the SSID?

@ivmarkov
Copy link
Owner

ivmarkov commented Jan 13, 2025

Background: I'm using esp32s3 and esp-wifi and face issues getting IP via dhcp when using esp-wifi when several access points serve the SSID (when there is coverage from several AP's). If I enable that SSID on only one of the access points it works.

Let's start here.
I do not understand Wifi in depth, but even with my limited understanding, I don't think it matters at all if you have 1, 2, 3 or 30 access points all with the same SSID.

Ultimately, you are connected to one and only one access point.
An access point is not identified by its "SSID" (this might even be missing), but by its BSSID, which is always present and unique per access point.

Now, if you have multiple access points with the same SSID, the one with the strongest signal should be chosen when connecting, but this you can control I think by specifying concrete BSSID. There also something called "roaming" where you can switch from one access point to another without the IP-stack even realizing this and provided that all of your access points have a single DHCP server and are bridged in the same L2 subnet. If you just created multiple access points with the same SSID which are not bridged and each has its own separate DHCP server and subnet, this is a wrong setup.

But with that said, I also don't believe roaming to be your issue. If it is, you should see the esp disconnecting from one BSSID and connecting to another. But then your problem is either on the Wifi level, or a wrong IP config, as per above, where your access points are not bridged.

By the way, I am myself running in a setup with multiple access points which are bridged and have the same SSID, and I've never seen any problems with that, including on baremetal and with esp32s3, esp32, esp32c3 c6 etc. I was also running the latest drivers recently (on c3, esp32 and s3) and didn't notice a huge delay or reconnections.

And the question is: I noticed this repo has edge-dhcp which is supposed to provide also a dhcp client. So I wondered if I could try and use it instead of the smoltcp one that's in use by esp-wifi by default?

That's not easy. To use it, you need an IP+ethernet layer (Wifi is still "ethernet") that will give you access to the payload of the ethernet frames, so that you can construct your own IP messages.
This is necessary, because DHCP is a bit weird in that it sits right on the border between L2 (ethernet) and L3 (IP). Specifically, it needs to be capable of broadcasting IP packets (this is your "request" DHCP client packet) as well as receive boradcasted DHCP server packets (the "offer" DHCP packet) without even having an IP assigned.

Unfortunately, I don't think smoltcp has hooks for that (yet).

I discussed this with the esp-hal team in esp-rs/esp-hal#2345 and eventually after a long discussion it looked like unclear behavior in processing dhcp messages on my network and I was told that to debug need to start from smoltcp (esp-rs/esp-hal#2345 (reply in thread)). I filed an issue with smoltcp at smoltcp-rs/smoltcp#1017 but there was no response for some time.

Sure but your request is very generic. Basically help me figure out what is going on. It is very unlikely that folks will have enough time to spend in debugging the issue together with you and having a lot of back-and-forth.

I think your best bet is what you have already started: debug with wireshark what is going on in terms of sent received packets. And make really sure, that the Esp is not disconnecting from one access point and connecting to another. If this happens, then you have a different problem altogether, especially if your access points are not in the correct (bridged) setup.

Or maybe, given you have the expertise, you can think of reasons why would DHCP fail under multiple AP's when it's working when only one is serving the SSID?

As I said above my first instinct is to check if you have properly bridged the access points, and they are all running with the same single subnet and a single DHCP server. And if you get reconnections in a rapid cycle.

@yanshay
Copy link
Author

yanshay commented Jan 13, 2025

Thanks!

I have a TPLink Omada system and all AP's are wired using ethernet, managed and configured centrally as a single configuration so I guess that means are are bridged properly. There is a single DHCP server.
All my equipment work well with that (printers, phones, laptop, etc.), only the ESP32 (all of them) fail to when several AP's within range serve the SSID (these are the terms I configure Omada with) and when I let only a single AP do that SSID then it's working great. Very consistently.

In the logs it seemed like the client is not behaving correctly, and that's a smoltcp issue, so I thought edge-dhcp might be a solution.

I exhausted my knowledge with that issue, looks like for now I'll take care of it using the network configuration and will have to wait until it becomes a larger audience issue and they face it with some large paying customer 😄

@ivmarkov
Copy link
Owner

I have a TPLink Omada system and all AP's are wired using ethernet, managed and configured centrally as a single configuration so I guess that means are are bridged properly. There is a single DHCP server.
All my equipment work well with that (printers, phones, laptop, etc.), only the ESP32 (all of them) fail to when several AP's within range serve the SSID (these are the terms I configure Omada with) and when I let only a single AP do that SSID then it's working great. Very consistently.

OK.

esp-rs/esp-hal#2345 (reply in thread) - this comment is a bit of a key. Why don't you try to figure out why smoltcp is not reusing the transaction id when sending the "request" message? That's indeed weird?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants