[pjsip] choosing an IP address -regarding
caugar at gmail.com
Fri May 23 00:00:29 EDT 2008
Thanks Benny !
That fixed the issue. Windows Mobile forces all traffic to flow
through the network, it decides is best. It does not matter what I
choose it to be. So I added a new entry to the routing table forcing a
lower metric for a particular destination and it worked fine. Since
RTP runs peer to peer, Windows mobile routes that through the WiFi
On Fri, May 9, 2008 at 3:48 AM, Benny Prijono <bennylp at pjsip.org> wrote:
> I think probably you have been going on the wrong route there. In both
> SIP and media transports, there are two IP address settings:
> - IP address used as the transport name (to be published in SIP
> messages or SDP)
> - the bound IP address
> You have been addressing the former setting, while I think the
> appropriate one is the later. If you change the bound IP address, then
> the transport name will automatically use that address. No need to
> change source code at all. While if you only change the former (that's
> what you did), then the transport will still be bound to INADDR_ANY,
> so the OS will chose whatever interface it sees appropriate to send
> the packet.
> On Fri, May 9, 2008 at 1:03 AM, Knight Tiger <caugar at gmail.com> wrote:
>> I am using PJSIP on a Windows Mobile device. (I am using version 0.5.3) .
>> This device has Wi-Fi and a 3G connection. When I connect through only one
>> network (either 3G or Wifi), I am able to register with my SIP server. (a
>> vanilla Asterisk box on the public network).
>> I want to be able to configure such that, for SIP messages it must go
>> through 3G and for RTP/media it must go through Wifi (when both interfaces
>> are available). I am experimenting with a media stack that is not PJMEDIA.I
>> am able to assign the WiFi interface IP address for RTP traffic. But for
>> SIP, I see the following call in many places in the code.
>> status = pj_gethostip(pj_in_addr in_addr);
>> This function gets the IP address on the default interface (it checks for
>> 0.0.0.0 and if nothing comes up, it returns 127.0.0.1) . As kludgy as it
>> sounds, I went and modified everywhere this function is called and checked
>> to see if I had a 3G connection, use that IP instead.
>> in_addr.s_addr = inet_addr(char *cellular_ip_string);
>> My Wifi has a public IP address (126.96.36.199) and the 3G provider assigns
>> a private IP (10.something)
>> I tried to register with the Asterisk server (with both interfaces active on
>> my device). The phone registers but it uses the WiFi interface IP address. I
>> inspected the packet and I shall reproduce the REGISTER message observed on
>> the Asterisk server.
>> Internet Protocol, Src: 188.8.131.52 (184.108.40.206), Dst: 220.127.116.11
>> User Datagram Protocol, Src Port: 5060 (5060), Dst Port: 5060 (5060)
>> Session Initiation Protocol
>> Request-Line: REGISTER sip:myvoipserver:5060 SIP/2.0
>> Message Header
>> Via: SIP/2.0/UDP
>> Max-Forwards: 70
>> From: <sip:1001 at myvoipserver>;tag=42710002ec722c6d1d79
>> To: <sip:1001 at myvoipserver>
>> Call-ID: 42710001ec722c6d1d79
>> CSeq: 38210 REGISTER
>> Sequence Number: 38210
>> Method: REGISTER
>> User-Agent: pjsua/1.0
>> Contact: <sip:10.84.15.87:5060;transport=UDP>
>> Expires: 600
>> Content-Length: 0
>> As you can observe, my 3G IP address is seen in the Via and contact headers
>> while my Wifi IP address is seen on the IP header. I dont understand where
>> did the SIP stack get this IP address from ? The entire SIP message uses the
>> 3G connection IP address. In fact, I checked within the code and I find that
>> wherever in_addr is used, it uses the 3G IP address.
>> Can anyone shed some light as to why this happens ? Is there a place where I
>> had neglected to change the IP address setting ?
>> Thanks in advance,
> Visit our blog: http://blog.pjsip.org
> pjsip mailing list
> pjsip at lists.pjsip.org
More information about the pjsip