How to implement an LWIP bridge?

holysword
Posts: 4
Joined: Tue Nov 01, 2022 7:39 am

How to implement an LWIP bridge?

Postby holysword » Mon Nov 14, 2022 6:55 am

https://www.nongnu.org/lwip/2_1_x/group__bridgeif.html
Some instructions are given here, but it's too simple. How do I implement an LWIP bridge in ESP-IDF? Please help, thank you!

ESP_ondrej
Posts: 211
Joined: Fri May 07, 2021 10:35 am

Re: How to implement an LWIP bridge?

Postby ESP_ondrej » Mon Nov 14, 2022 8:33 am

There is already an example to demonstrate it :) Please see https://github.com/espressif/esp-idf/tr ... ork/bridge

Just note that Ethernet is supported only.

holysword
Posts: 4
Joined: Tue Nov 01, 2022 7:39 am

Re: How to implement an LWIP bridge?

Postby holysword » Mon Nov 14, 2022 9:16 am

Thank you very much!

DrMickeyLauer
Posts: 168
Joined: Sun May 22, 2022 2:42 pm

Re: How to implement an LWIP bridge?

Postby DrMickeyLauer » Tue May 23, 2023 8:34 pm

In a way to solve the requirements shown in the first post of https://github.com/espressif/esp-idf/issues/5697 I tried the bridge example, but I need to have a) a dhcp server running and b) bridge eth and wifi.

Although the manual forwarding as shown in one of David Cermak‘s examples works fine, it strikes me at being a bit hacky, I‘d prefer a solution done inside lwip. What would it take to enhance the bridging to also feature Wi-Fi (while having support for running a DHCP server on the Bridged interface)?

ESP_ondrej
Posts: 211
Joined: Fri May 07, 2021 10:35 am

Re: How to implement an LWIP bridge?

Postby ESP_ondrej » Thu May 25, 2023 2:32 pm

@DrMickeyLauer I currently work on the LwIP bridge example to demonstrate bridged Wifi as well. I have working demo but it is very hacky so far to say. Please stand by.

Regarding DHCP server, try to modify

Code: Select all

esp_netif_br_config.flags = ESP_NETIF_DHCP_SERVER | ESP_NETIF_DEFAULT_ARP_FLAGS | ESP_NETIF_FLAG_EVENT_IP_MODIFIED | ESP_NETIF_FLAG_IS_BRIDGE; 
There should be also ESP NETIF API to do it programatically to modify properties of `br_netif`. Please excuse my vague suggestions. I'm on train, I'll check that tomorrow.

Please also note that LwIP's bridge Forwarding Database Functions are meant as an example as stated at https://www.nongnu.org/lwip/2_1_x/group ... __fdb.html. In addition, SPI is also bottle neck if you use SPI Ethernet. Therefore please expect limited performance.

For example, I achieved the following performance between two endnodes with bridge realized by two KSZ885's (SPI @40MHz):
UDP = 9.4 Mbps
TCP = 7.0 Mbps

This is good enough for generic IoT use case in my opinion. However may not be sufficient for some high performance use case.

ESP_ondrej
Posts: 211
Joined: Fri May 07, 2021 10:35 am

Re: How to implement an LWIP bridge?

Postby ESP_ondrej » Mon Jun 05, 2023 6:19 am

You can find the very first "work in progress" version of bridge working with option to bridge WiFi AP at https://github.com/kostaond/esp-idf/tre ... ork/bridge

Who is online

Users browsing this forum: Bing [Bot] and 230 guests