Mobility Project - VoIP over 3G/WiFi networks

Gaël ALLOYER, Marc CABOCEL, Romain CASTAGNET, Pascal CLEMENT, Pierre LEROY, Guillaume LESNE, Nicolas PEPIN

[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]

Abstract. With the increasing of mobility of devices and Internet expansion, users are constantly connected. In this con- text, the is to study if it is possible to create a Voice over IP application for Android and iPhone OS in order to be able to switch between networks to maintain Internet connection. Swapping between networks has to be without discon- nection. A VoIP application dealing with this mobility problem has already been implemented for Linux. This report pre- sents our approach to port a similar application for smartphones. Our results show that smartphones cannot always be considered as small computers with an easy development platform. Access and management restrictions can cause nu- merous problems for developers for this migration on iPhone OS and Android.

1 Mobility Management

The aim of this project is to develop a VoIP (Voice over IP) application with mobility on two mobile OS, iOS and Android. This application allows the user to switch between two networks without any disconnection during a communication. This project is based on a mobility patch created for an open-source project named PJSIP [1], which provides source codes writ- ten in language to build VoIP applications. This patch modifies PJSIP libraries (PJLIB) [2] and PJSUA [3], a UNIX VoIP application for testing purposes that uses PJSIP. The patched version of PJSUA already allows mobility management.

1.1 Context

SIP/RTP. SIP is a signaling protocol used in VoIP. RTP is used for media transport.

IMS. The IMS is an architectural framework delivering Internet Protocol multimedia services. The IMS server provides a database of subscribed users that are allowed to interact with other subscribers using SIP/RTP protocols. In order to provide Voice over IP, an IMS (IP Multimedia Subsystem) server providing VoIP services was installed.

Routers. Users have access to the IMS through two routers, one configured as a public router where accessible through 3G networks, and the other through WiFi. These devices constitute a simulation bench for access switching on mobile devices.

Available Patch. The patched version of PJLIB provides a good starting point to implement mobility on iOS and Android. iPJSUA is an iPhone application that uses PJLIB, as well as CSipSimple [5], a similar application for Android.

1.2 Research

Before implementing the managing of mobility on a smartphone using PJSIP, the context has to be fully understood. During a communication between two devices, packets pass through an IMS proxy (P-CSCF) and the IMS core before passing through another IMS proxy. This leads to the device called.

Calling Process (Figure 1). Firstly, the calling device uses SIP protocol in order to register itself in the IMS (by sending a REGISTER SIP packet). Then the user can make a call (by sending an INVITE SIP packet). If the IMS accepts the registra- tion, and the correspondent answers the call, communication begins. RTP packets carrying the voice are exchanged be- tween the two devices.

1 of 8

Figure 1. Calling process

Mobility Management. With mobility management, this process is slightly modified. The communication has to switch between two network interfaces (e.g. WiFi to 3G) without any disconnection. The device has to be connected to these two networks during a few milliseconds, to REGISTER, REINVITE and quickly synchronize the communication via the se- cond interface. The IMS and PJSIP must be modified to be able to manage two connections with the same device.

Mobility Management Implementation (Figure 2). The chosen solution that was implemented for mobility management was to incorporate a second entry proxy to the IMS. This proxy allows another connection using a second network between the IMS and the second network interface of the device. One was used by the client through its 3G interface, and the other one was used by the WiFi interface.

Figure 2. Mobility management with IMS

2 of 8

Mobility Calling Process. A new connection was added to PJSIP. This signal is a “re-invite” (REINVITE) message sent by the second interface. This message specifies in its header that it must be routed on the first PCSCF proxy via the second PCSCF proxy. Thus, the first proxy understanding that this device is asking for mobility can duplicate the commu- nication. This was achieved by sending packets on both network interfaces. Both connections are kept active during a few milliseconds, while some packets are transiting to make sure that the new connection is stable. After ten RTP packets, the new connection is considered stable if these packets are well received. The first connection is then closed.

1.3 Setup

Routers. In order to have a fully functional environment to test mobility, DDWRT [4], an open-source Unix-based firm- ware was installed on both routers. This (OS) allows very powerful functionalities for debugging and managing routes with classical Unix commands.

Testing. The first important step is to know if the environment is working without mobility. PJSUA was compiled under MacOS 10.6.6 and under Ubuntu 10.04. A call was initialized between two UNIX OS based computers.

Patching. The patch provided is working for PJSIP 1.6. After applying the patch to the 1.6 version, compiling PJSUA under MacOS 10.6.6 was no longer possible due to compilation errors. Ubuntu was used for the next testing process.

First Results (Figure 3). The initial context is that computers are running the previously patched PJSUA under Ubuntu 10.04. The caller makes a call to the second computer via PCSCF1 using a given network interface (eth0). During the communication a REGISTER and REINVITE signal are sent to PCSCF2 through a second network interface (eth1). Con- sequently, after a few milliseconds the communication switches to the second interface (eth1). All the traffic is monitored with a traffic analyzer to log the mobility management and prove that mobility from one interface to another is working.

Figure 3. Wireskark capture - Mobility with test2 (192.168.0.9 then 172.18.1.217) calling test user (172.18.1.6)

As expected, the first interface of test2 subscriber registers itself in the IMS then calls the test correspondent. An invite packet is sent and the communication is established once test picks up. RTP packets are exchanged (in Figure 5 only SIP packets are filtered). Then, the second interface of test2 registers itself into the IMS. The two interfaces receive RTP pack- ets during 10 RTP packets (few milliseconds). Then the first connection is closed and only the second connection remains active.

2 Migration on Smartphone

This project aims to develop an application on smartphones to manage mobility as the one running on UNIX. To implement this functionality, the project was split up in two parts: one for iOS and one for Android.

3 of 8

2.1 Investigation

At the beginning of the project, studies about IMS, SIP/RTP and VoIP were done to understand the context of this project. This investigation was needed to understand how a VoIP application works, and how it can be modified for mobility. Stud- ies on PJSIP were also done to understand how the mobility management was implemented for the PJSUA UNIX applica- tion.

Devices. Some tests were performed on the iPhone 3GS and on the iPhone 4 to know if managing mobility can work on them. Android devices such as the Samsung GALAXY Tab and the Samsung GALAXY S were also tested. These tests are explained later on this report.

Application Choice. Patching an existing application that uses PJLIB with mobility enhance mobility management imple- mentation. It has been previously demonstrated that PJSUA works with PJLIB patched. Thus, a VoIP application for each operating system (Android and iOS) using PJSIP needs to be found. iPJSUA is a port of PJSUA for iOS, and CSipSimple is the one for Android. PJSIP is directly included in IPJSUA whereas CSipSimple belongs to another project which is based on PJSIP. The two screenshots below (Figure 4) show a part of the GUI of both applications.

Figure 4. CSipSimple running on Android (left) iPJSUA running on an iPhone 3GS (right)

Application Compilation. CSipSimple can be compiled and runs on the Android emulator included in the Android SDK; PJLIB can also be compiled and integrated to CSipSimple. The latest version of this application is working with PJLIB 1.8. On the iOS side, jailbroken iPhones are required. This allows any compiled application to be brought on real devices and not only on the Xcode provided iPhone simulator. At least, iPJSUA was running on both the Xcode simulator and iPhones.

Application Testing. These applications were tested without mobility management. Even after their configuration, some problems were still remaining such as the RTP communication, which is unidirectional. After some research into the source code of these applications, it seems RTP packets should be sent. Thanks to a Man In The Middle (MITM) attack between the client (iPhone 3GS in communication) and the wireless Access Point (AP) on which it was connected, it was discovered using Wireshark that the router was dropping every RTP packet sent by the iPhone. Indeed, this problem was coming from route tables of the router. Its routes were fixed, and both CSipSimple and iPJSUA were working well.

4 of 8

2.2 From PJSIP 1.6 to PJSIP 1.8.10 Patched with Mobility Management

PJLIB is used by CSipSimple and iPJSUA. Unfortunately, CSipSimple requires PJLIB 1.8.10 to work and iPJSUA is not yet implemented in PJLIB 1.6. Consequently, the patch given for PJSIP 1.6 has to be ported for PJSIP 1.8.10.

New Patch. A new patch was created to generate a 1.8.10 version of PJSIP, which handles mobility management. The process was to compare PJSIP 1.6, PJSIP 1.8.10 and the patched version of PJSIP 1.6. This comparison highlighted the dozens of modified files due to the PJSIP update. Moreover the same amounts of files were changed with the implementa- tion of the mobility management. Kdiff3 is the software used to compare all these files. It gives an overall vision of the entire project and all the differences between these files. After the comparison and modification of all the files from the different projects, a new patch for PJSIP 1.8.10 was finally released. These modifications done, many tests were performed to correct problems coming from an incorrect file modification. Finally, mobility management on Linux with PJSUA works with the 1.8.10 version.

Conflicts. CSipSimple and iPJSUA was modified to implement mobility. However, a new problem occurred, the PJLIB version used in CSipSimple was the 1.8.10, but the author of this application also adapted it. Thus, these modifications and the one from the mobility management were combined to apply mobility management in CSipSimple.

Issue with MacOS X. The new patch does not fix MacOS compilation issues for PJSUA found for the 1.6 version. An investigation found that the issue was coming from socket definitions that are different under MacOS X and Linux. Fortu- nately the patching part for sockets is not required for the mobility to work. Mobility is strictly based on routing packets from the PJSUA application to the specified network interfaces using their IP addresses. After having cleaned up all the modifications regarding socket management, the application still had some minor compilation errors due to the gcc version that is different from the Linux gcc version. These errors were C syntax errors, and were easy to fix.

For better project management it was decided to use SVN and have two different versions of PJSIP on it, one for CSipSim- ple and the other for iPJSUA.

2.3 iOS

Network Interfaces. Some tests were made on the iPhone to understand if the activation of WiFi and 3G interfaces could be done at the same time. The iPhone was rooted in order to install our application and network management packages such as ifconfig and OpenVPN using Cydia [6]. The use of OpenVPN will be explained later. ifconfig allows the user to config- ure his network interfaces the way he wants. Thus the two interfaces, 3G and WiFi of the iPhone were turned on. Both network interfaces can work at the same time. Therefore mobility management should be possible on this device.

Why Debug PJSUA Instead of iPJSUA. To clearly understand the following part and the choice to debug PJSUA rather than iPJSUA, it is important to know that iPJSUA is an extension of PJSUA with a basic Graphical User Interface (GUI). Because iOS and MacOS are very close Operating Systems, the debug part was first based on PJSUA on MacOS. In the next parts, we saw that it was a very good choice because it was easier to debug and iPJSUA was working instantaneously after this debug process.

Troubles. When proceeding to a mobility test with the patched PJSUA 1.8.10 under MacOS X, the first issue was a Seg- mentation Fault when the application tried to REGISTER the first interface. Using gdb, ltrace, strace and verbose tracing in the application, the cause of this issue was finally located in the code. Another issue was identified when running the PJSUA application under MacOS X. When the application is launched it checks all audio devices, and if the configuration is wrong, audio cannot work. A mistake in a PJSUA configuration file before compiling the sources was pointed to be the cause of this issue.

PJSUA Working. Finally after all required corrections, PJSUA was finally working with mobility. The next step was to check if iPJSUA was working the same way.

5 of 8

Mobility with the second network interface

Figure 5. iPJSUA patched with mobility running on an iPhone 3GS

OpenVPN. In order to get connected to our local Gateway designed to be accessible via 3G networks it was required to create a tunnel between our cellphones and the router. For security reasons in school it is not possible to forward specific ports from the borderline routers to our project router. Thus, because SSH is allowed, it was possible to create an SSH tunnel between an iPhone and a local port on the router where OpenVPN Server is running. The next step was to install and configure OpenVPN for the iPhone. After these steps it has been possible to connect the iPhone via 3G to the router by a tunneled VPN access.

Mobility is Working. Here are the details regarding the procedure used to prove that iPJSUA patched is working with mobility:

1. 3G is ON. 7. OpenVPN is launched. 2. SSH is initialized on 3G. 8. REGISTER the second network interface (3G). 3. OpenVPN is DOWN. 9. REINVITE via the 3G network. 4. WiFi is ON. 10. WiFi is turned OFF after one or two seconds. 5. iPJSUA registers using WiFi. 11. No communication cutting, mobility is working. 6. Communication is initialized.

GUI. A Graphical User Interface was implemented for iPJSUA during this project. Two tools were used, Xcode and Inter- face Builder.

Figure 6. AppDelegate describes the application. The window represents the highest layer of the graphical interface.

6 of 8

Description (Figure 6). Our application centers on a Tab Bar that contains four windows. The two last windows are al- ready built in the base iPJSUA application. The two first windows named “Home” and “User” were added. Our “User” window introduces a TableView, which appears as a contacts list. A Table View needs a NavigationController and a view controller to switch freely between views. Then by tapping on a contact in the list we can access a new view where it is possible to call the contact and manage the mobility (Figure 7).

Figure 7. iPJSUA GUI – (left), mobility management (right)

2.4 Android

Network Interfaces. Some tests were performed to check if both 3G and WiFi interfaces are able to work at the same time. These tests were performed on a Samsung Galaxy Tab and a Samsung Galaxy S. These phones were flashed and rooted in order to enable access to a root terminal. Busybox, a tool that provides some UNIX commands, was installed, and we were able to use ifconfig. OpenVPN Client was working with the 3G network interface.

Interfaces Issue. Unfortunately, it was demonstrated with ifconfig that the Android Operating System does not accept to have two data connections enabled at the same time. Many hacks were tried to enable both interfaces, without success. Finally, in March an American researcher posted his research on the same problem [7]. This researcher provides a solution on his blog to enable both interfaces.

The Hack. On Android phones, a system service called Connectivity Service is responsible for the WiFi and 3G interface management. This service checks the state of the two interfaces and only allows connections via the preferred data connec- tion (the system default is WiFi). In order to use WiFi and 3G simultaneously, the solution consists in a masquerade of Connectivity Service. This process causes WiFi and 3G not be automatically turned off.

The Hack Process. The modification of the “services.odex” system file provided in the Android OS is part of the masquer- ade process. This file is precompiled and is executed by the Android Virtual Machine, which manages Connectivity Ser- vice. It is created from a “services.jar” file with the DexOpt tool. Unfortunately, the build process of “services.jar” from Android source code for our specific Samsung devices cannot be performed manually. The solution was to generate two different “services.jar” using the Android OS compilation process. The first file generated is the original one while the second was generated with the hack source code to allow 3G and WiFi to work together. The creation of the corresponding “services.odex” of both files was made. Thanks to the differences between the two “services.odex” files, the original Samsung “services.odex” file was modified. The problem of interfaces was consequently solved. WiFi and 3G were working at the same time on our two Samsung Android devices.

CSipSimple. Unlike PJSUA, which directly uses the 1.8.10 version of PJLIB, CSipSimple uses an adapted version of this library. Modifications from the mobility patch and the CSipSimple changes on PJLIB were applied to compile CSipSimple with the mobility functionalities. In order to add the mobility functions to the application, the architecture [8] of the CSipSimple application and its interac- tion with PJLIB was studied. Since PJSIP is coded in C programming language, it cannot be directly used in CSipSimple coded in Java programming language. Therefore, the NDK tool (Native Development Kit) was used to build the library file for the Java environment. Also, this code in C programming language was optimized for its future integration. To perform this last step, the SWIG wrapper tool was used.

7 of 8

Two buttons were implemented on CSipSimple. They are displayed during a call (Figure 8) and are linked to the register and re-invite mobility functions available in the adapted PJLIB library file.

Figure 8. CSipSimple – Calling GUI with two new mobility buttons “Reinvite” and “Register”

3 Conclusions

Goal. This project came to create an application, which manages mobility between 3G and WiFi network interfaces on iPhones and Android devices. VoIP communications without disconnections can be performed with mobility for the iPh- one. The goal was reached. The Android part was very hard due to difficulties encountered managing the 3G and WiFi interfaces. However, two interfaces can finally work together on Android and easily switch from 3G to WiFi or the contra- ry. We almost entirely implemented a patched CSipSimple working with mobility.

Thanks. We would like to thank our tutors for this very interesting project, where we were able to fully highlight and use our network knowledge on interesting application. We also have been able to discover the Android and iOS community on the Internet, and mainly the PJSIP community that we thank for the very good VoIP library they provide. We would also like to give special thanks to the American researcher for his help and work on the Android hack.

References

[1] http://www.pjsip.org/; PJSIP Open Source Project Home Page. Professionally supported open source, portable, small footprint mul- timedia communication libraries written in C language for building portable VoIP.

[2] http://www.pjsip.org/pjlib/docs/html/main.htm; PJLIB Home Page. PJLIB is an Open Source, small footprint framework library written in C for making scalable applications.

[3] http://www.pjsip.org/pjsua.htm; PJSUA Home Page. PJSUA is an open source command SIP user agent.

[4] http://www.dd-wrt.com/; DD-WRT, a free Linux-based firmware for several wireless routers.

[5] https://code.google.com/p/csipsimple/; SIP application for Android devices

[6] Cydia/Telesphoreo, developed by Jay Freeman (saurik).

[7] http://mobisocial.stanford.edu/news/2011/03/let-wifi-and-3g-connection-work-together-by-hacking-connectivityservice-java/; Let WiFi and 3G connection work together by hacking ConnectivityService.java, 03/03/11.

[8] Florent Garin and Sylvain Wallez, ANDROID : Développer des applications mobiles pour Google Phones, Dunod, Paris 2009

8 of 8

Annexe – Management du projet

1 Le Travail en Commun

1.1 Organisation du Groupe

Manageur. Durant la phase d’intégration, le groupe a connu un manageur tournant durant quatre semaines. Finalement, Pascal CLEMENT a été élu par la majorité pour être le manageur définitif. Ce choix s’est prononcé suite à sa bonne vision et compréhension générale du projet, ainsi qu’à ses compétences en matière de développement et de management.

Répartition du Groupe. Le sujet du projet traitant de deux parties qui sont iOS et Android, le groupe a donc été divisé en deux selon les préférences et compétences de chacun. Trois membres incluant le manageur ont intégré le groupe iOS et les quatre autres le groupe Android. Cependant, certaines tâches comme la partie recherche ont été effectuées en commun.

1.2 Réunions

Chaque semaine une réunion pour la mise en commun du travail fut organisée. À l’issue de ces réunions, un rapport fut envoyé à chaque membre et aux encadrants contenant le compte rendu ainsi que la répartition de nouvelles tâches.

2 Les Outils

2.1 Diagramme de Gantt (Figure 1)

Figure 1. Diagramme de Gantt

2.2 SVN et Wiki

SVN. Un dépôt SVN a été utilisé par tous les membres pour la mise en commun du développement. Ce dépôt privé est organisé en deux parties, l’une contenant iPJSUA fonctionnel avec mobilité et l’autre contenant CSipSimple avec mobilité en phase finale de développement.

Wiki. Tout au long du projet un Wiki en anglais et privé a été maintenu à jour. Il contient près de 30 articles et tutoriels complets rédigés par les membres pour le projet. Ce Wiki constitue une documentation technique et chronologique très détaillée du travail fourni. Il est le recueil de toutes les connaissances acquises par les membres durant ce projet.

1 of 1