Vous êtes sur la page 1sur 42

Africa Information

Technology Initiative

Lecture 13:
SMS Applications
AITI 2009
Agenda
•  Messaging Protocols
–  USSD, SMS, MMS
•  SMS Background
•  SMS Applications
•  Designing SMS Applications
•  Course Infrastructure
–  SMSLib
–  Emulator

2
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Unstructured Supplementary
Services Data (USSD)
•  Short, user-initiated responses (pull)
–  Balance check: Safaricom: *144#
•  USSD supported in all GSM phones
•  New standards support push messages
–  Balance Transfer
–  M-Pesa
–  Instant messaging
•  USSD is not SMS!

3
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Short Message Service (SMS)
•  GSM Protocol that allows for exchange of
short messages
•  CDMA networks also have SMS protocol

•  Each SMS messages is 140 bytes (byte =


8 bits)
–  Can encode up to 160 7-bit characters
using default GSM alphabet

4
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Multimedia Message Service (MMS)
•  Extension to SMS that allows message to
include more content:
–  Images, videos, and audio
•  Use WAP browser to display the message
•  Much bigger payload than SMS
•  Problems:
–  Displaying on different phone (content
adaption)
–  Access to MMSC from provider
5
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Simplified Network Diagram
Within Network

SMS

SMS

Out of Network

Short Message SMS


Service Center
(SMSC)

6
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Short Message
Service Center (SMSC)
•  GSM network node that delivers SMS messages
•  When user sends a messages:
•  Forwarded to SMSC
•  Stored at SMSC until it can be delivered to recipient
–  If msg cannot be delivered, queue for later retry
–  Termed Store-and-Forward
•  Some SMSCs also provide a "forward and forget"
option where transmission is tried only once
•  SMSCs now connected to Internet
–  Better quality of service

7
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
SMS Gateways
•  Device or service providing SMS transport
–  Allowing SMS transport with or without phone
–  Allow SMS traffic between business and mobiles
•  Direct To Mobile Gateway Appliance
–  Mobile phone or USB GSM modem
–  Connected to PC, can send/receive messages
–  Good for low to medium message volume (this class!)
•  Direct To SMSC Gateway
–  Gateway connected to SMSC via Internet
–  Business has interface to Gateway (usually Internet)
•  Gateway then forwards message to SMSC (SMPP)
8
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Short Message Peer-to-Peer (SMPP)
•  Protocol for transport of SMS between
SMSCs and Gateways using Internet

•  Don’t need to know details.

9
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Simplified Network Diagram
Direct to Mobile
Gateway

USB
SMS

Direct to SMSC
Gateway

Internet
Short Message
Service Center
(SMSC)

10
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Gateway Software for Business
•  Installed on Business computer to send/receive
messages

•  Can use either Direct-to-Mobile or Direct-to-


SMSC
–  Can use multiple at same time!

•  Require either:
–  Sending device (phone/modem)
–  Contract with Operator or Service Provider

Africa Information Technology Initiative © 2009 http://aiti.mit.edu


Gateway Software for Business
Examples:
–  NowSMS
•  Not open-source 
–  Kannel
•  Linux
•  Open source
•  Written in C
–  smslib (this class)
•  Windows XP
•  Open-source
•  Written in Java
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Direct To Mobile Gateway
•  Using a phone or GSM Modem as a
Windows modem
–  Connecting
–  Installing
–  Testing
•  PC to modem/phone connections
–  USB
–  Bluetooth
–  Infrared
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Service Providers
•  Service providers have contracts with operators
–  Resell SMS services to you
–  Provide APIs to send/receive messages
•  HTTP, PHP, Java, etc.
–  Can use Gateway software also (smslib)
•  Examples:
–  Clickatell
•  Problems:
–  Hard to send messages

14
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Email to SMS Gateway
•  One can send an SMS to a phone via
email

•  Usually: recipient_number @provider.com

•  Safaricom:
–  254721123456@safaricomsms.com
–  Must first SMS “EMAIL ON” to 123

15
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
SMS to Email Gateway
•  One can send an SMS to an email
address from a phone

•  Safaricom message format:


–  recipient_address messsage
–  Example: “aiti@mit.edu I love your class!”

16
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
SMS Premium Services with
Operator Agreement
•  Examples: Ringtones, digital content, state
updates
•  Value-added Service Provider (VASP) has
agreement with operator
–  Extra charges are added to SMS to/from VASP
–  VASP and operator share extra charge
•  Revenue share or fixed transport fee
–  Short codes
•  Messages transported between operator and
VASP via Internet
–  VASP uses Gateway software
17
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
SMS Applications

18
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
SMS is Ubiquitous
•  Least-common denominator technology
–  All phone support SMS
–  Almost everyone is familiar with SMS
–  SMS messages are cheap, free on some
networks
•  Reach the most users
•  But many constraints

19
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Types of SMS Applications
•  Information Push
•  Information Pull
•  State Update
•  Mobile-Based Systems
•  Redirect
•  Downloads

20
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Information Push
•  Broadcasting information to a group
–  Bible verses, jokes, pickup lines
•  Alerts and notifications:
–  Ex: weather warnings, coupons, email notification,
stock notification, credit card alerts
•  Users can subscribe and unsubscribe
–  Via SMS, web portal or email
•  Users can pay for service
–  Daily / monthly / yearly rate
–  Operator agreement
–  Reverse SMS billing (charge receiver)
21
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Information Pull (Query)
•  Two way interaction
•  User sends a formatted message
requesting information
–  Ex: Google search, phone number search,
directions, weather, sport scores,
transportation information
•  User subscription or charged per message
–  Operator agreement
–  Reverse billing
22
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
State Update
•  User sends a message to update the state of a system
–  Maybe an acknowledgment is returned

•  Examples:
–  Voting Systems
•  Idols East Africa
–  Update the state of an Internet site
•  Update Facebook/Twitter status, update personal blog, micro-
publishing
–  Disaster Information:
•  Update disaster locations to inform others via SMS
–  SMS Forms:
•  Predefined format
•  Medical Records, Field Surveys, Business Agents
23
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Mobile-Based Systems
•  User interacts with full system via SMS
–  User has continued presence with system
–  Database backed
•  Protocol of SMS interactions
–  “command arguments”
•  Menu driven with session support:
–  Have to remember the state of the users interactions
•  Examples:
–  Independent M-Pesa, IM networks, classified ads

24
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Downloading
•  SMS messages can carry binary data

•  SMS can be used as the transport layer


for wireless downloads.
–  Ex: ringtones, wallpapers, pictures

25
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Redirect
•  SMS as redirection for phone user
–  Can be automatic or require click on link

•  Provide a link to WAP site


–  Download ringtone (Cellulant)
–  Download image
–  Download application

26
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Designing SMS Applications

27
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
SMS Application Basics
•  SMS apps are constrained by many
factors:
–  Only small amounts of text can be sent
–  User interface is the SMS composer
–  Writing text is cumbersome with 12 keys
•  T9 makes things a bit better
–  Each sent message is charged to the user
•  Ways around this
–  No online help / help screens

28
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
SMS Protocol Design Principles
•  Keep user input to a minimum
–  Digits easy to input
–  Long words are hard
–  If requiring a long word, make sure T9 completes it
–  Disregard punctuation, space is adequate
•  Intuitive interactions
–  Command words that makes sense
–  Consistent order of arguments
–  Multiple command words for each command
•  With abbreviations
•  Keep responses to 1 message
29
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Server Considerations
•  What is needed on the server?
–  Support for many users
•  Threaded server
•  Multiple gateways (phones, modems)
–  Parse messages to perform actions
–  Database of users and system state
•  Table design (SQL)
•  Query design (SQL)
•  Atomic actions?
–  Internet connection for query / update
30
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Agents?
•  Are agents needed for you system?

•  Example:
–  M-Pesa agent

31
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Protocol Design Example: AITI-Pesa
•  AITI-Pesa: Operator independent m-
banking service
•  Phone number is account number
•  Agents required for deposit / withdrawal
•  Users interact via SMS:
–  balance query
–  transfer funds
–  approve withdrawal

32
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Protocol
Balance Query:
[b, q, bal, query, balance] pin_number
Transfer Funds:
[t, trans, transfer] pin_number acct_num
amount
Withdrawal:
[w, wd, withdrawal] pin_number
agent_num amount
33
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Course Infrastructure

34
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Modems and SMSLib
•  We will use various USB GSM modems
–  Lab describing how to install software

•  SMSLib as gateway software


–  http://code.google.com/p/smslib
–  Java software (poorly documented)
–  Callback when a message is received

35
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
SMSLib Code Structure
•  An SMS server has one Service object
–  The parent of all the gateways
–  Main interface to interact with server

•  A Service can have one or more Gateways


–  These send and receive messages directly
–  A Gateway is either a modem, phone, or a
Service Provider
–  We are going to use SerialModemGateway
36
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
SMSLib Initialization Code
Service this.srv = new Service();

SerialModemGateway gateway = new


SerialModemGateway("modem.com3", "COM3", 460800,
"huawei", "");
gateway.setProtocol(Protocols.PDU);
gateway.setInbound(true);
gateway.setOutbound(true); Class must implement IInboundNotification

this.srv.setInboundNotification(this);
this.srv.addGateway(gateway);

this.srv.startService();

37
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Receiving a Message
When a message comes in on a gateway,
the registered inbound notification method
is called:

public void process (String gatewayId,


MessageTypes msgType,
InboundMessage msg)

To distinguish the receiving gateway

MessageTypes.INBOUND or
MessageTypes.STATUSREPORT
38
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
InboundMessage
•  Class that models an inbound message
–  Messages that the server receives

•  Most important field is String Originator


–  String getOriginator() is accessor.
–  String of senders number

39
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
Send a Message
try {
OutBoundMessage response = new 

OutboundMessage(msg.getOriginator(),
messageString);

srv.sendMessage(response);
} catch (Exception e) {
System.err.println(“Error while sending.”);
}

40
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
AITI SMS Emulator
•  While testing your code, we don’t want you to
send and receive actual SMS messages
–  Expensive!
–  Only go live after extensive testing

•  We will provide you with a phone emulator that


adheres to the SMSLib Code Structure

•  To change between SMSLib and emulator just


change the imports!

41
Africa Information Technology Initiative © 2009 http://aiti.mit.edu
AITI SMS Emulator
Functionality for:
–  Setting sender phone number
–  Sending message
–  Inbox of messages

42
Africa Information Technology Initiative © 2009 http://aiti.mit.edu

Vous aimerez peut-être aussi