Page 1 of 1

How to implement an LWIP bridge?

Posted: Mon Nov 14, 2022 6:55 am
by holysword
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!

Re: How to implement an LWIP bridge?

Posted: Mon Nov 14, 2022 8:33 am
by ESP_ondrej
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.

Re: How to implement an LWIP bridge?

Posted: Mon Nov 14, 2022 9:16 am
by holysword
Thank you very much!

Re: How to implement an LWIP bridge?

Posted: Tue May 23, 2023 8:34 pm
by DrMickeyLauer
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)?

Re: How to implement an LWIP bridge?

Posted: Thu May 25, 2023 2:32 pm
by ESP_ondrej
@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.

Re: How to implement an LWIP bridge?

Posted: Mon Jun 05, 2023 6:19 am
by ESP_ondrej
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