Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wifi network not prioritzed over mobile network on iOS #85

Closed
perwx3 opened this issue Oct 17, 2017 · 6 comments
Closed

Wifi network not prioritzed over mobile network on iOS #85

perwx3 opened this issue Oct 17, 2017 · 6 comments

Comments

@perwx3
Copy link

perwx3 commented Oct 17, 2017

Hi all,

I'm running baresip on iOS 11.0.2 (on iPhone6) and there seems to be some problems when choosing the default network interface in libre for the SIP-stack.

No specific network interface has been set in baresip config. If both mobile network and wifi are up, then mobile network is chosen over wifi. To make baresip use wifi network, then mobile network has to be disabled in phone settings.

This is different from how it is working on android, where wifi is chosen as the preferred network over mobile network automatically by the baresip net_change monitor.

Is this a bug or 'feature' ? :)

Br,
Per Enstedt - wx3 telecom

@alfredh
Copy link
Contributor

alfredh commented Oct 24, 2017

Hi,

the default network interface is "guessed" based on the routing table. The algorithm
is quite simple. It does not take network cost (Wifi or Mobile) into the equation.

could you please provide output of the "netstat" command and routing table?

NOTE: I think this issue belongs in the baresip project.

/Alfred

@perwx3
Copy link
Author

perwx3 commented Oct 26, 2017

Hi Alfred,

Ok, thanks for clearing that up. I was uncertain if this was supposted work with network cost 'out-of-the-box'.

I am unsure on how to provide output of netstat and routing table.. How do I do that? Note also that I have no jailbreaked iPhone if that is needed for output.

Br,
Per

@alfredh
Copy link
Contributor

alfredh commented Oct 30, 2017

Start baresip and type the /netstat command. Sample output below:

/netstat
--- Network debug ---
 Preferred AF:  AF_INET
 Local IPv4:    enp2s0 - 10.0.0.2
 Local IPv6:        lo - ::
 Domain: getinternet.no
net interfaces:
         lo:  127.0.0.1
     enp2s0:  10.0.0.2
         lo:  ::1
     enp2s0:  fe80::d63d:7eff:fef1:3048
net routes:
 Destination                                 Next Hop                                 Iface           Type
 0.0.0.0/0                                   10.0.0.1                                 enp2s0          
 10.0.0.0/24                                 ?                                        enp2s0          
 ::1/128                                     ?                                        lo              
 fe80::/64                                   ?                                        enp2s0           LINKLOCAL
 DNS Servers from System: (2)
   0: 84.208.20.110:53
   1: 84.208.20.111:53

or use the functions from your code:

net_if_debug()
net_rt_debug()

@perwx3
Copy link
Author

perwx3 commented Nov 7, 2017

Hi,

Sorry for the delay but here's the output from netstat:

--- Network debug ---
Preferred AF: AF_INET
Local IPv4: - 83.182.162.26
Local IPv6: - 2a00:801:212:55e6:10c3:207:28ac:9372
Domain: wx3.local
net interfaces:
lo0: 127.0.0.1
lo0: ::1
lo0: fe80::1
pdp_ip0: 83.182.162.26
pdp_ip0: fe80::ce:4236:4f3d:5446
pdp_ip0: 2a00:801:212:55e6:10c3:207:28ac:9372
pdp_ip0: 2a00:801:212:55e6:75a6:1a23:88b8:2b65
en0: fe80::fc:9b02:e93d:89d6
en0: 192.168.1.129
en2: fe80::1cfc:c93d:cfbf:6dae
en2: 169.254.253.137
awdl0: fe80::6c43:b4ff:fea6:fc99
utun0: fe80::a980:8f0c:957b:c4ec
net routes:
Destination Next Hop Iface Type
DNS Servers from System: (2)
0: 192.168.1.30:53
1: 192.168.1.1:53

--

At this point I have mobile carrier network and WiFi both running and I would like to have 192.168.1.129, the WiFi address as the preferred interface.

I see no net routes. Is that normal?

Br,
Per

@alfredh
Copy link
Contributor

alfredh commented Nov 7, 2017

check if HAVE_SYS_SYSCTL_H and HAVE_NET_ROUTE_H is defined,
and that net/bsd/brt.c is being compiled.

the logic for detecting this is in src/net/mod.mk:

ifneq ($(HAVE_SYS_SYSCTL_H),)
ifneq ($(HAVE_NET_ROUTE_H),)
SRCS	+= net/bsd/brt.c
CFLAGS  += -DHAVE_ROUTE_LIST
endif
endif

oh.. looks like net/route.h is not available for iOS.
you might have to copy that file from another OS, and then rebuild libre
with those flags forced on.

But, I think to solve the problem properly you have to use some iOS specific
functions to retrieve the "default" interface/address.

@perwx3
Copy link
Author

perwx3 commented Nov 7, 2017

Hi.

Yes, I noticed also that net/route.h is missing in the iPhone SDK. I does however exist in the MacOSX SDK so I just made a copy of it:

sudo cp /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/net/route.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/usr/include/net/
and recompiled everything.

And it seems to be working! Netstat command now shows lots of routes and baresip defaults to WiFi just like I would like it to.

I will continue running some more tests but this seems to be a close enough solution.

Thank you for all your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants