Author Topic: Issues with LwIP Multi-Interface Switching  (Read 551 times)

0 Members and 1 Guest are viewing this topic.

Offline tilblackoutTopic starter

  • Contributor
  • Posts: 31
  • Country: cn
Issues with LwIP Multi-Interface Switching
« on: April 19, 2024, 08:45:02 am »
Hello everyone, I am implementing a program with LwIP that supports multiple network interfaces, allowing internet access via both a 4G module and Ethernet. Switching between network interfaces is simply done by calling netif_set_down/up and netif_set_default.

The 4G module is connected to the microcontroller via USB and supports RNDIS mode, which means the TCP protocol runs within the module, and the microcontroller can acquire an IP address via DHCP from the 4G module to access the internet.

However, I've encountered a peculiar issue. When switching the network to the 4G module, I cannot access the internet. Here are a few things I've tried:

1、Without using Ethernet, upon powering up, the device successfully accesses the internet through the 4G module. If I then turn off the 4G module's internet connection and turn it back on, the device can obtain an IP via DHCP but fails to access the internet again, with continuous ping failures. (This makes me suspect a problem with the USB driver reinitialization.)
2、With Ethernet connected, after powering up and accessing the internet via the 4G module, I then turn off the 4G module. The device automatically switches to Ethernet (which works fine for internet access). Then, when I turn off Ethernet and switch back to the 4G module for internet access, the 4G connection surprisingly works. (This leads me to suspect an issue with the LwIP multi-interface switching logic.)

This means that as long as the netif switches from Ethernet to the 4G module, internet access is possible, but restarting the 4G module alone does not allow internet access. This makes it difficult to determine whether the issue lies with the USB driver or the LwIP stack.

Does anyone have any insights or suggestions? Thanks for your input! :)

Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo