Skip to main content
Visitor II
April 30, 2025
Question

LWIP 2 interfaces issue

  • April 30, 2025
  • 4 replies
  • 808 views

Dear colleagues, hello! Question about LWIP. I have two network interfaces, one on the QCA 7000 chip via SPI, the second on LAN 8742, installed on the debug board. I use the Socket API. The problem is as follows: The server is running on one interface, the client on the other. When they are not running at the same time, everything works fine. But if you enable them at the same time, sometimes the outgoing packet on the QCA 7000 interface gets stuck in the LWIP library for about 210ms. And this time interval is always the same. Please tell me which way to look to solve this problem

    This topic has been closed for replies.

    4 replies

    Super User
    April 30, 2025

    Welcome to the forum.

    Please see How to write your question to maximize your chances to find a solution for best results.

     


    @Ivan4S4 wrote:

    on the debug board.


    What board is that?

     


    @Ivan4S4 wrote:

    Please tell me which way to look to solve this problem


    See this article for LwIP debug options.

    See also: https://www.nongnu.org/lwip/2_0_x/group__lwip__opts__debugmsg.html 

    Graduate II
    April 30, 2025

    Just guessing and googling: maybe it's the same problem?

    tcp - LwIP echo client with multiple netif interfaces, how to select a particular netif interface - Stack Overflow

    "LwIP wasn't designed to work well with multiple netif's. The function ip4_route is used, which wrongly selects the first netif it can find, so the tcp traffic used two different physical ports for the same source IP address when routed to the same switch"

     

    And have you given each netif a dedicated IP address?


    Super User
    April 30, 2025

    @LCE wrote:

    "LwIP wasn't designed to work well with multiple netif's..."



    Indeed - people often forget that the "Lw" in "LwIP" stands for Light-weight.

    From the LwIP Home Page:

    "lwIP is a small independent implementation of the TCP/IP protocol suite"

    "The focus of the lwIP TCP/IP implementation is to reduce resource usage while still having a full scale TCP. This makes lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM."

     

    @Ivan4S4 hasn't said what MCU is being used, but F7 is tagged - which has resources far beyond that "tens of kilobytes of free RAM and room for around 40 kilobytes of code" !

    So maybe a more capable stack would be appropriate?

    Ivan4S4Author
    Visitor II
    April 30, 2025

    Dear colleagues, thank you to everyone who joined the discussion. Yes, I am using the STM32F746 Discovery debugging board. By setting the SO_BINDTODEVICE option, I assigned a specific interface to the sockets, as mentioned above. I'm scanning packets using Wireshark. And I see that when using two interfaces at the same time, outgoing packets on one of them are lost from time to time.

    Super User
    April 30, 2025

    So have you enabled the debug trace options to see what's going on?

    Ivan4S4Author
    Visitor II
    April 30, 2025

    What kind of debugging option do you have in mind?

    Ivan4S4Author
    Visitor II
    April 30, 2025

    By the way, if I turn off the TCP client and use PING, ICMP packets that I send to the first interface, this also happens from time to time.