SIPWISE CE - NEWS

back to all Sipwise CE - News

SIP beyond VoIP – location based services using sip:providerCE

SIP is famous for being the protocol to be used for VoIP signaling nowadays. With the (not so simple) SIMPLE extension, it also offers PUB/SUB and messaging capabilities. The plan was obviously to lay grounds for a full-blown communication framework for telephony, instant messaging and presence, as we know it from XMPP. Due to various reasons, SIMPLE never really took off, but that’s a completely different story.

Still, the PUB/SUB model of SIMPLE on one hand and the inherent bi-directional communication model of SIP on the other hand open up quite some interesting possibilities for applications to experiment with.

Together with Rene Krenn from the Technical University of Graz we’ve created a proof-of-concept implementation for geotracking a mobile device by just using SIP. It could be easily turned into a nice hobby or full business in the area of

  • Kids security tracking (e.g. define the path from home to school once by recording it, then trigger an alarm if your kid leaves it by a certain treshold).
  • Theft-fraud protection (remotely disable possibility to place calls or shut it down entirely, report position to police).
  • Lost phone locator (let it ring by the click of a web button, show position in a map).

Publishing Geo Location

In RFC 5491, the IETF defines the XML document format for publishing geo locations on top of SIP/SIMPLE, called The Presence Information Data Format Location Object (PIDF-LO). Beside other details, it defines, how a SIP client should publish GPS information to a SIP server or to subscribers of this resource, respectively.

In our implementation, the SIP client on our mobile defines several triggers for publishing geo locations. A combination of perimeter and interval configurations is used for defining the granularity (like “publish new location every 50 meters, but at most every 10 seconds and at least once every minute” for not flooding the server when moving really fast, while still having something like a keep-alive when moving slow).

Consuming Geo Location

One way of consuming the provided geo location information would be to subscribe clients interested in this data to the SIP user who is publishing it. This approach is interesting for real-time updates, when you want to avoid polling a server. Every time a publisher sends a location update, all subscribers will get it pushed to their clients immediately.

For our concept implementation, we just focused on a server-side implementation. On top of our sip:providerCE, we implemented the parsing of the PIDF-LO document and write any location updates for a user directly into the database. Since the CE uses Kamailio 3.0 as a SIP server, it’s a matter of a couple of lines of configuration to fetch the data from the xpath of the xml document. This is how a PUBLISH message holding PIDF-LO information ends up in the database:

mysql> select * from geo_location limit 700,1\G
*************************** 1. row ***************************
              id: 32460
     insert_time: 1294756018
        username: someuser
          domain: geo.sipwise.com
       device_id: urn:device:XXXXXXXXXXXXXXXXXXXXXXXXXXX
        gps_type: Sphere
    gps_latitude: 46.95543
   gps_longitude: 14.89872
    gps_altitude: 1019.1
   gps_precision: 16.8
gps_utctimestamp: 2011-01-11 14:26:43
1 row in set (0.00 sec)

When applying the data to Google Maps, here’s how it looks like when you drive over the highways through parts of Austria with the geotracker application running on your phone:

Geotracking a mobile phone with SIP

Bi-Directional Communication

With the information provided above, you might say that this could be done much easier by just posting HTTP requests to a server, providing the GPS information in your own and simple format. That’s actually true, but what you get with SIP is the possibility of bi-directional communication just out-of-the-box.

When you fire up your SIP client, it will register with your SIP server, which is nothing else then providing contact information (IP/port) for inbound requests. When your network address changes (due to roaming, changing from 3G to WiFi, getting a new DHCP lease etc.), the client will re-register, so the SIP server is always aware of where to reach your client.

Depending on your use-case and implementation, you can at any time trigger actions on your mobile. Possibilities would be to send a specific SIP INFO request to your mobile, triggering in the background a video call using the front-camera of the device to snoop on the user of the phone (or however you put it). Using a SIP MESSAGE request, you could send a message to the user of the device. Or you could shut it down remotely using for example a special SIP OPTION request. It’s really just up to your creativity and implementation.

Putting it all together

The test-bed we’re using is an installation of the sip:providerCE, which we provide for free and open-sourced over here. On top of that, we have configured the presence modules of Kamailio in order to support PUB/SUB and the parsing of xml documents. The parsed geo data is written to a MySQL database, and a simple PHP script using the Google Maps API is used to display paths on a map as seen in the screenshot above.

On the client side, Rene has implemented the PIDF-LO extension in a custom SIP client for Windows Mobile phones. We’ve developed a proof-of-concept mass provisioning tool for it as well in order to remote-provision the SIP client. Users just enter a token they get from us when starting the client for the first time, and a full configuration file including SIP credentials to authenticate on the SIP server is fetched by the client.

Geo Tracker Mass Configurator

Do you want to join?

Currently all of our efforts in this area are purely for educational and research purposes. If you on one hand have the know-how to implement a client for Android or the iPhone, or if you got inspired by our approach to create some kind of web service on top of it, we’d be happy to support you. We’re going to give out our geo-location technology implemented on top of our open-source platform to anyone seriously interested as a free SDK. Just contact me at agranig@sipwise.com and outline your plans, and we’d be happy to support you on a technical side.

Leave a Reply

Your email address will not be published. Required fields are marked *