linphone-iphone icon indicating copy to clipboard operation
linphone-iphone copied to clipboard

Wrong IP in Via Header and SDP after changing from WIFI to cellular

Open kchrispens opened this issue 6 years ago • 5 comments

Hi,

I detected a problem in the SIP stack implementation of liblinphone. My app registers to a SIP registrar (Cisco Unified Communications Manager) via a VPN connection (Cisco AnyConnect). In most cases everything works as expected. But after moving from mobile network to WIFI or the other way round, liblinphone (sometimes) starts using the cell IP address (or WIFI) instead of the IP address of the VPN adaptor.

The log excerpt below contains the log statements beginning with the last successful REGISTER request before the network switch and ending with an outgoing SIP call after the network switch. The network switch from WIFI to cellular network is completed at 16:11:09:001. The IP address of the SIP registrar is 192.168.3.11 which is only reachable via VPN. The VPN address of the phone is 10.10.10.57. The Cell IP of the phone after switching the networks is 100.73.206.42. This is the address which is written into Via Headers and into session descriptions after the network switch. It is not visible from the point of view of SIP registrar, so actually the app should not get any response at all. But there seems to be a kind of fallback mechanism to the Contact header IP in the SIP implementation of the registrar in case of unreachable Via header IP so the response arrives at the phone and the registration process succeeds. I can also establish an outgoing call. But it results in one way audio because of the wrong IP address in the SDP of the INVITE message.

The strange thing is that the correct network interface is chosen for sending the SIP messages so there is connectivity on the VPN adaptor. But there seems to be something wrong in the logic of selecting the IP address for Via and SDP. After restarting the app the VPN interface is used and everything works again.

This behaviour is not always reproducible. I had to switch the networks a lot of times to get the log results.

Our IOS Version: 11.1.2 (15B202) LinphoneCore version: 3.12.0-37-g3c446b769

I found following issues addressing similar problems

#135 #136

But they did not help to solve my problem, I think the version I use is recent enough.

Issue #135 states that there is a new algorithm for selecting the IP address since linphone 3.15 which chooses the IP address that really "connects" to the SIP server. But in my case the SIP registrar is not reachable using a cellular network IP. It does not have a public IP.

Here is the link to the Log excerpt:

https://pastebin.com/41E0EFmk

kchrispens avatar Jul 19 '18 14:07 kchrispens

I might have a similiar issue on desktop https://github.com/BelledonneCommunications/linphone/issues/90. (could I suggest moving the log file to a gist or a pastebin to make the issue more readable ?)

arthurzenika avatar Aug 31 '18 07:08 arthurzenika

Hi, sorry for the logs in the post. I did't find the possibility to append a file. But I will edit my post and outsource the logs to a pastebin link.

kchrispens avatar Aug 31 '18 09:08 kchrispens

Meanwhile we tried a couple of things to bypass the automatic network state monitoring:

  1. Setting the VPN IP as NAT address.
  2. Using a STUN server

But in both cases we still could reproduce the problem.

Can anybody post a code snippet how to disable the automatic network state monitoring permanently?

By the way, is this the correct location to post such problems? Maybe that's the reason why there was no comment by a developer yet?

kchrispens avatar Aug 31 '18 09:08 kchrispens

I would like to know in which file the IP address is being set. Please let me know. Because I am also facing the same issue.

RajanVindaloo avatar Jun 12 '19 07:06 RajanVindaloo

any solution ?

sianami avatar May 05 '22 15:05 sianami