Tuesday, March 8, 2011

VoIP and Android (Updated below)

Update: June 22nd

I'm keeping the below article around for largely historical reasons, but I have to say that 99% of my opinion of the system had more to do with issues connecting to Ekiga.net than anything else. As it turned out, the system is sufficiently open that it works well with my Asterisk PBX, even when I'm connected via T-Mobile's 3G network.

In general, if you use an entirely open SIP network like Ekiga's, you're likely to have problems with the Gingerbread SIP client - at least until the great switchover to IPv6. If you use a system that routes your call via a proxy, this will be less of a problem.


One of the new features of "Gingerbread", also known as Android 2.3, is voice over IP - specifically the ability to configure the phone app to route some or all calls over the Internet instead of the telephone network. I decided to try it out yesterday, but I regret to tell you that the implementation is incomplete and, as a result, not for everyone. Let's talk a little about what they have, why it's not there yet, and what the alternatives are.

Voice over IP

For almost as long as personal computers have been hooked up to the Internet, there's been a collection of applications and systems designed to route audio over it, with two way, telephone-style, communication being one popular add-on to Instant Messenger type systems.

It's a great idea, but until relatively recently has been fraught with problems. The Internet is not a reliable network, and it's impossible to guarantee that anything sent over it will arrive in a predictable way, so much has depended upon the Internet itself becoming higher quality.

An additional issue is that nobody can agree the best approach to routing audio in this way. While some attempts have been made to standardise voice over IP, the most popular "standard" isn't actually a VoIP standard itself (VoIP runs over it), and it has some severe limitations that make it awkward to use in 99% of real world settings. That "standard" is called "SIP".

SIP itself is a low level protocol that encapsulates point to point communication - obviously if you're going to route audio to somewhere and have audio returned, you need a way to set up a link, and a way to communicate data over that link, and that's what SIP does. SIP's origins lay in a generalised framework for instant messaging, but it's most commonly associated with voice over IP.

SIP's major technical problem is that it behaves poorly with most private networks. Almost everyone who uses the Internet today connects via a private network, which in turn connects to the Internet via a system called NAT. This system, built to deal with the shortage of possible Internet addresses, has limitations that prevent an outside party from being able to make a direct connection to a machine within the private network.  The long term fix to this is a system called IPv6, but IPv6 is not live yet, and many parties are refusing to take it seriously, delaying its implementation.

To get around SIP's issues with internal networks, various workarounds have been built. One is called STUN. STUN uses various quirks common to 99% of NAT implementations to punch those holes so that SIP systems can communicate with one another even when both are on internal networks.

This isn't the only problem with SIP. As I said before, how you run VoIP over SIP isn't completely standardised, although various de-facto standards exist. Confusingly, many protocols exist that are completely incompatible with the de-facto standards, such as UMA (a way for GSM users to use their phones over Wifi) and IMS (a VoIP system intended for use with next generation mobile networks) that are, in fact, built upon SIP.

To make matters worse, SIP is only one of the standards for Voice over IP. Google Talk, for example, is built upon XMPP, an entirely unrelated but open protocol. Another documented and free to use protocol is IAX, the default protocol of the popular Asterisk virtual PBX. Skype and Vonage, two of the most popular VoIP providers, use proprietary protocols, requiring the use of their own software and hardware.

SIP is, however, well supported. There are huge numbers of clients for it, and a large number of VoIP providers, many of which provide basic, over-the-Internet-only, services for free. I signed up at Ekiga.net, an organisation that both provides free VoIP accounts, and a free software (open source) client that runs on a variety of platforms.

SIP in Gingerbread

The implementation of VoIP provided with Android 2.3 is based upon the de-facto SIP-based VoIP standard. However, only the bare minimum is provided. In particular - and this is arguably a deal breaker - the Android implementation lacks support for STUN, which immediately renders it unusable under many circumstances.

The issue is that without STUN, a VoIP connection can only be set up in a small set of circumstances. Specifically, the called party must either:

1. Be directly connected to the Internet. It is exceedingly rare that an Android handset is directly connected to the Internet, even when the phone has a cellular data connection it is usually on an internal network owned by the carrier.

2. Be the only device on the Internet network using SIP and be behind a router that recognises this.

In practice, (2) will be hit or miss. Obviously it rules out receiving calls when connected to the mobile Internet, or while at an Internet hotspot, and even receiving calls at home may be problematic without the user knowing exactly what they're doing. Without STUN, there's no "just works" configuration.

SIP is the only protocol supported. Despite Google being responsible for Android and running their own VoIP system based upon XMPP, the Gingerbread VoIP system does not support XMPP and there is no way to make it work with Google Talk. While Google provides a Talk client for Android, it's text, not audio, based system and cannot be used for voice communication.


Thankfully, Android is open, and there are workarounds. The easiest? Just use the same VoIP solutions that existed prior to Gingerbread's release.

I found the simplest, easiest to configure and most trouble free, VoIP tool for Android to be Linphone. It's a basic SIP client, but it supports STUN and various other extras you may need. It's well integrated into the Android system, you can even have it take over from the phone app if you dial a number and have a Voice over IP account that supports making calls to telephone numbers. Another popular VoIP client is SipDroid, which is a swiss-army knife of a VoIP client. If you find Linphone doesn't get you what you need, try SipDroid.

If you'd still like to be reachable over the phone, and your main reason for using VoIP is because of coverage, not cost, you might want to switch to T-Mobile and use their UMA service. Their recent Android phones, as well as the Android phones upgradable to CyanogenMod 7, have a VoIP system built in called Wifi Calling, which is an implementation of UMA. And Skype is also available - although, like UMA, it only routes calls over Wifi, not cellular.

Voice over IP has some very interesting ramifications for your business, and I'll be covering it in depth in forthcoming blog entries.

Update: 10.45am - something just clicked.

It just occurred to me that the list of situations where Gingerbread's SIP implementation would work above was incomplete, and there was one more application where suddenly Google's logic for implementation suddenly comes together: you will be able to receive calls via the SIP implementation if both you and the caller are on the same network.

In other words, while the SIP implementation may be virtually useless for external communications, an office could use Android phones coupled with a system like Asterisk to put together a very advanced internal wireless phone system. I actually was going to cover the topic in a forthcoming update, but for some reason it didn't click for me that this is actually what Gingerbread's SIP solution is actually intended for.

Stay tuned!

No comments:

Post a Comment