4
votes

For a while now I've been playing around with the SipDemo in the Android 2.3 SDK.

The documentation on Android's developer page is nicely written, but it's not a lot. It does not explain anything about IPs, ports, NAT and STUN. I know how this stuff is supposed to work, but it doesn't say how Android's SIP API handles it. Or does it handle NATs at all...

Here, someone mentioned that the API does do some tests for public IP and port, but it's the first time I read it: http://code.google.com/p/android/issues/detail?id=14043&can=1&q=sip%20ip&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars So I'm not sure this is true. At least for me, it didn't work.

But now to my problem: When I deploy the SipDemo as-is either to my device connected to WiFi or to the emulator, provide my credentials (I know they work with SipDroid and other SIP apps) the SipDemo displays "registration failed". I did some sniffing and found out the packets sent to the SipServer all include the devices or emulators local IP, not my NAT's public one. Something like Via: SIP/2.0/UDP 192.168.0.106:53230 The server replies correctly that RFC1918 IPs are not allowed.

I added a STUN test to the SipDemo and successfully retrieved my public IP and port. But I can't find a way how to pass it on to my created SipProfile or the SipManager.

My question: Has anyone ever made an application working with the SIP API behind a NAT? How does the API handle NATs? How can I pass the information I got from my own STUN client to the SIP API?

I know SipDroid and a lot of other SIP implementations, but they all do not use the built-in API.

1

1 Answers

0
votes

I added a STUN test to the SipDemo and successfully retrieved my public IP and port. But I can't find a way how to pass it on to my created SipProfile or the SipManager.

If you are behind symmetric NAT it doesn't matter, because a new NAT binding will be created for the outbound SIP connection, so the information you gathered with STUN is not really usable.

You shouldn't bother about NAT from a SIP API, the server needs to implement NAT traversal techniques for you.

There are cases in which you can actually do something from the client: when ICE is being used and you choose your own TURN server, but I don't think Android implements ICE and TRUN support yet. Even if it would, you'd still need to deploy a TRUN server...

Free services out there do implement NAT traversal techniques, you may try http://sip2sip.info for instance.