apache / nuttx

Apache NuttX is a mature, real-time embedded operating system (RTOS)
https://nuttx.apache.org/
Apache License 2.0
2.49k stars 1.06k forks source link

Prioritize Ethernet or WiFi over PPP #7104

Open vshymanskyy opened 1 year ago

vshymanskyy commented 1 year ago

I have successfully configured a dual-interface connection on ESP32 (TTGO T-Call):

nsh> pppd &
[...] CONNECT
nsh> ifconfig
wlan0   Link encap:Ethernet HWaddr 98:cd:ac:7a:81:e0 at UP
        inet addr:192.168.10.236 DRaddr:192.168.10.1 Mask:255.255.255.0

ppp0    Link encap:TUN at UP
        inet addr:10.97.10.240 DRaddr:192.168.254.254 Mask:0.0.0.0

nsh> route
SEQ   TARGET          NETMASK         ROUTER          
   1. 0.0.0.0         0.0.0.0         192.168.254.254

However, ping shows that modem connection is preferred over WiFi:

nsh> ping 8.8.8.8
PING 8.8.8.8 56 bytes of data
56 bytes from 8.8.8.8: icmp_seq=0 time=630 ms
56 bytes from 8.8.8.8: icmp_seq=1 time=360 ms
56 bytes from 8.8.8.8: icmp_seq=2 time=490 ms
56 bytes from 8.8.8.8: icmp_seq=3 time=580 ms
56 bytes from 8.8.8.8: icmp_seq=4 time=370 ms
56 bytes from 8.8.8.8: icmp_seq=5 time=520 ms
56 bytes from 8.8.8.8: icmp_seq=6 time=630 ms
56 bytes from 8.8.8.8: icmp_seq=7 time=400 ms
56 bytes from 8.8.8.8: icmp_seq=8 time=550 ms
56 bytes from 8.8.8.8: icmp_seq=9 time=640 ms
10 packets transmitted, 10 received, 0% packet loss, time 10100 ms
nsh> ifdown ppp0...OK
nsh> ping 8.8.8.8
PING 8.8.8.8 56 bytes of data
56 bytes from 8.8.8.8: icmp_seq=0 time=30 ms
56 bytes from 8.8.8.8: icmp_seq=1 time=20 ms
56 bytes from 8.8.8.8: icmp_seq=2 time=20 ms
56 bytes from 8.8.8.8: icmp_seq=3 time=20 ms
56 bytes from 8.8.8.8: icmp_seq=4 time=20 ms
56 bytes from 8.8.8.8: icmp_seq=5 time=20 ms
56 bytes from 8.8.8.8: icmp_seq=6 time=20 ms
56 bytes from 8.8.8.8: icmp_seq=7 time=20 ms
56 bytes from 8.8.8.8: icmp_seq=8 time=20 ms
56 bytes from 8.8.8.8: icmp_seq=9 time=20 ms
10 packets transmitted, 10 received, 0% packet loss, time 10100 ms

Changing the order of network configuration doesn't help. It looks like on Linux, this is handled by route metrics (ifmetric command). Is there a way to achieve this on NuttX?

acassis commented 1 year ago

@vshymanskyy you can use the route command to remove that route and add a new route. The idea of add ifmetric sounds very interesting!