Layer 2 bridging

thag8keepr
Posts: 2
Joined: Sun Sep 13, 2020 12:44 pm

Layer 2 bridging

Postby thag8keepr » Sun Sep 13, 2020 1:08 pm

Hi,
I would like to create a wifi bridge between two networks - a server on my home network, and one or more ethernet clients on a small rover. I would like to use the LR-mode as I value range over throughput in this use case.

My idea was to setup one ESP32 in AP-STA mode, with STA connecting to my home wifi, and the softAP in LR mode. The rover would also have an ESP32 in LR STA mode, with an ethernet module connected to one or more ethernet clients.

Sketch of the setup below:
esp32_server_client.PNG
esp32_server_client.PNG (57.92 KiB) Viewed 6222 times

I have tried out AP_STA and also tried out an ESP32 NAT implementation, however what I would really like is to have Layer 2 functionality, where the ethernet clients in the rover transparently (as in bridging) communicate with the base network.

Anyone tried this? Does the ESP32 IDF support this use-case?

ESP_morris
Posts: 290
Joined: Wed Sep 05, 2018 6:23 am

Re: Layer 2 bridging

Postby ESP_morris » Mon Sep 14, 2020 3:43 am

I would say it's doable, and esp-idf has a very simple example showing how to bridge Wi-Fi and Ethernet on Layer II https://github.com/espressif/esp-idf/tr ... net/eth2ap

markxr
Posts: 15
Joined: Sun Aug 16, 2020 7:32 pm

Re: Layer 2 bridging

Postby markxr » Mon Sep 14, 2020 8:25 am

The thing to remember is that in Wifi, packets usually only have three addresses, bssid, src and dest.

This means we can do bridging to ethernet ONLY in AP mode, not in STA mode, because there aren't enough address fields.

Commercial wifi extenders use another mode, typically called WDS mode, which has four addresses.

So I think you can do it only if you put the esp32 on your rover into AP mode. This is what the espressif bridging example does.

--

EDIT: to clarify, you can't using bridging on both sides unless you use four-address packets, because there will not be enough address fields. I don't know if the expressif libraries can do this.

It should still be possible to set up the esp32 as a ip router though, and route packets, which should work. What's the problem with that?

thag8keepr
Posts: 2
Joined: Sun Sep 13, 2020 12:44 pm

Re: Layer 2 bridging

Postby thag8keepr » Mon Sep 14, 2020 5:21 pm

ESP_morris wrote: I would say it's doable, and esp-idf has a very simple example showing how to bridge Wi-Fi and Ethernet on Layer II https://github.com/espressif/esp-idf/tr ... net/eth2ap
Thanks, I'll look into this.
markxr wrote: So I think you can do it only if you put the esp32 on your rover into AP mode. This is what the espressif bridging example does.
Got it, thanks.
markxr wrote: It should still be possible to set up the esp32 as a ip router though, and route packets, which should work. What's the problem with that?
While I have been working a lot with FreeRTOS on other CPUs, I'm new to ESP32, so I'm not yet familiar with the capabilities of the IC. My gut feeling told me that sticking to L2-bridging would take a lot less horsepower from the CPU, however as I'm not too concerned with throughput maybe routing would work just fine

markxr
Posts: 15
Joined: Sun Aug 16, 2020 7:32 pm

Re: Layer 2 bridging

Postby markxr » Wed Sep 16, 2020 6:12 pm

Looking at what you're trying to do, it does seem a bit complicated an unlikely. Given that you won't be able to bridge in both AP and STA mode, and the esp32 does not support WDS mode, it might be a better idea to either simplify your topology, or try something a bit simpler,

Maybe port forwarding would be ok, or running some kind of proxy (socks proxy?) that your client / server applications can use?

It seems the esp32 network stack is not as flexible as, say, Linux.

IP routing should work, but I can't see how to easily enable that, lwip does support it if enabled at compile time, but there is no esp-idf config option to turn it on.

Who is online

Users browsing this forum: No registered users and 142 guests