Tuesday 13 September 2011

SMS and Liberia: A Love Story

These days technology just works. There's no magic and there's very little rocket science. You put in some 1s and 0s and get out 1s and 0s. It all works just as it should. The days are gone when bugs, actual insects, would chew their way through the computers wire and cause mayhem.


Now some of you right now are saying, “Yeah, but I still can't figure out how to make my Facebook profile private.” That's a user interface issue; the underlying technology is working perfectly. The layer that exposes that technology to you may be poorly designed, but that's not what we're here to discuss.

Technology, it hums along gloriously.... until certain assumptions no longer hold true. Such assumptions usually include constant electricity and constant Internet - two things that just don't happen very often in Liberia. Thus what seems like a perfect combination - SMS technology and Liberia - has a few obstacles to overcome before riding off into the sun set happily ever after.

For us at Ushahidi Liberia, we wanted SMS and Liberia hit it off. SMS is a great way for people on the ground to send in reports of what's really happening. All you need is a phone and a cell phone signal. Most places in the world have cell phone coverage, and more and more people have cell phones. The Ushahidi platform even has built-in support for SMS because it has worked so well in other deployments. Lets start off by getting to know a bit more about the compatibility of this couple - SMS and Liberia.

SMS, or Simple Messaging Service, is a GSM standard that uses extra bandwidth in the signaling path that controls call flow. The signaling path is used to tell a cell phone that a new call is coming in, that the call has been hung up, the number of the incoming call and so forth. Since the signaling path isn't used when there is no phone call, phone companies realized they could add a messaging service on top of this unused signaling path – and thus SMS was born. Because the signaling path is only intended for short messages like, “incoming call +231-6-555-343”, SMS messages can only be 160 characters long.

Liberia is a small country in West Africa still recovering from a civil war that devastated the nations infrastructure. Despite the lack of power lines, power stations and any kind of hard-wired telecommunications infrastructure, Liberia now has a relatively robust cell phone network. While less than 1% of Liberians have access to the Internet, at least 20% own cell phones and even more have access to shared phones. SMS seems like a natural choice for Liberians to send messages to our Ushahidi Liberia sites, given that even the cheapest cell phones available in-country support SMS.

At this point things look good for our two lovebirds. A simple global standard for sending short messages and a country where about all their telecommunications infrastructure can handle is short messages. In fact, such a partnership has worked so well in other countries that the wonderful people at kiwanja.net created FrontlineSMS. FrontlineSMS is a program that turns your average laptop and a cell phone into an SMS gateway for routing incoming SMSs to the internet. By connecting a cell phone to a computer via a data cable, FrontlineSMS can intercept incoming SMS and automatically send them to a website of your choosing – an ideal matchmaker for SMS and Liberia.

However, it is here we encountered our first obstacle. Computers need power. You can get around this requirement for a few hours by using a laptop. Most laptops can reliably go 4 to 6 hours without power. Ushahidi Liberias first office used a diesel generator for electricity, like most Liberian workplaces that do not have access to a power grid. Diesel isn't cheap in Liberia, so the generator only ran from 9am to 7pm. That leaves 14 hours without power – in other words, 14 hours without the ability to send and receive SMS via a desktop SMS gateway. Because many of the reports sent to our Liberia instances about conflict and instability, we could not afford to be operational for only 10 hours a day.

The second obstacle was an unreliable Internet connection. In Liberia, all Internet connections are via satellite - far slower and more expensive than fiber optic connections. Ushahidi Liberias first ISP leased a satellite Internet connection comparable to a slow DSL connection in the US – until the ISP splits that connection among all of its customers who then split their slice of the connection amongst all the users in the office/home. During peak working hours we could make an educated guess that approximately 500 people were using that one Internet connection, causing it to drop out when bandwidth was exceeded, and cause any user to grind their teeth in frustration when it was working but painfully slow.

When the Internet dropped out in our office and FrontlineSMS received an SMS to forward to Ushahidi servers, the sending would fail and FrontlineSMS would drop the message without resending. FrontlineSMS does not notify the sender or the receiver that a message failed to send, so it could be days before the person manning FrontlineSMS might realize that half the sent messages were missing. FrontlineSMS, like many platforms, is built under the assumption that the Internet works – as it does most of the time in most places.

Considering these glitches, our couple might not be as compatible as we thought – that is until SMSSync came along. SMSSync is an Android app written by the Ushahidi team that replaces the computer as the intermediary and runs the SMS gateway program on the phone itself. Since Android phones can connect to the Internet via WiFi and GPRS, they can receive an incoming SMS and then send it out over the Internet all by themselves. This solved our first problem of power. Phones can easily run 14 hours, or a couple of days, without recharge; that's what they're made to do. But we still have the issue of unreliable Internet.

To address the Internet, our team worked closely with SMSSyncs creator, Henry Addo, to incorporate a resend function that tries sending a message over and over until it is received by the target URL. Now with this feature added, messages can be received by SMSSync even when the Internet is out and they stay in a holding pattern until the connection returns. At this point it seems like everything is going to work out for SMS and Liberia, but not so fast.

There's still one more assumption that I hinted at earlier – that humans will interact with technology correctly. Even the most well-intentioned, experienced user will occasionally get it wrong. The civil war held up the arrival of the latest technologies, and as a result many Liberians don't have extensive experience with technology. This is nothing against Liberians, just the reality of their situation.

We noticed that every so often we'd receive a blank message from our users in the field; someone probably hit send prematurely. At first we didn't pay much attention to this, but then we noticed that SMSSync would stop sending messages after receiving blanks. After a lot of hair-pulling, we realized the problem was with the Ushahidi platform itself. It was programmed to reject blank SMSs as erroneous. SMSSync would try to forward the blank SMS to Ushahidi, Ushahidi would reject it, SMSSync would wait 5 minutes and try again, meanwhile all the other messages were waiting in line. We reprogrammed the Ushahidi platoform to accept all messages, blank or otherwise. Messages that appeared to be errors would be marked as such for the users of the Ushahidi platform to decide what to do with them.

We also had a similar problem with promotional SMSs from the cell phone companies. They'd send out things like, “Talk free this Saturday. Often these messages wouldn’t be from numbers like, “06-555-123”, but from “winBig” or “LonestarCell.” Again, we didn't think much of this, but SMSSync stopped working shortly after receiving these messages. It turns out that the Ushahidi platform is also set to reject SMSs from numbers that aren't numbers, sending an app like SMSSync into a never-ending loop. We also fixed this in the Ushahidi platform.

At this point we've accounted for assumptions about electricity, Internet and human users. The final assumption we had to overcome is that the technology will always, from now to eternity, until you tell it otherwise, do what you want. It seems that in an effort to save battery power, Android phones are programmed to turn off their WiFi radios after a certain period of inactivity. Thus SMSSync would work brilliantly for awhile, but then stop forwarding messages for no apparent reason. We'd look at the phone, see the unsent SMS, and since we were using the phone the WiFi would come back on and mysteriously work. Much to our embarrassment, this also took a long time to figure out.

At this point I'd like to make it clear that 99% of the time it's the simple things that get in the way. It wasn't some small manufacturing default in our phones, it wasn't a rogue bit of code deep in SMSSync, it was just a simple feature of the phones that, when they aren't working as SMS gateways, works to the users advantage.

We fixed the WiFi automatic sleep by installing KeepScreen on the phones. KeepScreen is a free Andoid App that just keeps the screen on all the time. By keeping the screen on, and making the Android think the user is still using the phone, the WiFi also never goes off.

Now our phones work perfectly, day and night, through power and blackouts, high bandwidth bliss and connection timeouts, to send SMSs from our users on the ground to our servers high in the Internets metaphorical cloud. Finally, after so much struggle and hardship, Liberia, a beautiful country, and SMS, a messaging protocol of elegant simplicity, are together at last.

2 comments:

  1. Fascinating. Wonderful to read it looking back and seeing how you solved the problems, but I imagine when the SMS system wasn't working it was pretty frustrating!

    ReplyDelete
  2. Wow!!!! Great job at problem solving!!

    ReplyDelete