Saturday, October 11, 2008

How SMS works, quick and dirty.

OK, the main purpose of this post is to streamline and consolidate the bits and pieces of my knowledge about the SMS technology and how to go about sending SMS from your program, So here goes a quick and rough overview of what I know about the SMS technology.

When you send an SMS from your mobile, it is first submitted to an SMSC (Short Message Service Center).
SMSC is an entity in wireless network of a telecom operator, which is supposed to handle all the stuff related to SMS, The address details of the SMSC are pre-configured in your SIM card by your network operator (like Etisalat in UAE) hence the SMS reaches the SMSC first, with all the details like the source number (originating party), SMS text, the validity period, the target number (terminating party), date-time, size etc.

Usually an SMS consists of 160 characters but if exceeds it is classified as a long sms and broken down into more than one part, but all those parts have a particular identifier (which remains same in all the parts) which indicates that the parts are actually one SMS. SMSC recognizes it and concatenates all those parts.

The job of SMSC is to route the SMS to the target number, SMSC queues and routes the messages to the desired numbers. If the target mobile number is offline, the SMSC stores the SMS for a certain time period and then again forwards the SMS when the target number comes online. This "certain time period" is actually called Validity Period and there is a default value set for every SMSC for this (but you know what, you can increase it while sending your SMS).

The underlying protocol which is used for this data exchange is SMPP (v 5.0 is the latest one). Short Message Peer to Peer protocol. The mobile device and SMSCs exchange data through this protocol and the basic unit of data here is called PDU, (protocol Data Unit). This of course has a certain header and body and a particular format.

Now let us explore sending SMS through your code, when you are writing program to send the SMS from your application, you are basically using an API which is an implementation of SMPP protocol. The two common Java based APIs are SMPPAPI and OpenSMPP.

SMPP API
http://smppapi.sourceforge.net/

Open SMPP
http://opensmpp.logica.com/introhtml/menu.htm


Before you can write your program to send an SMS via SMSC, you need to make sure that you have the following information from your telecom company about the SMSC
1- the IP address of the SMSC
2- the port allocated for SMS
3- the username
4- the password
5- Address range
6- System type
7- etc. :)

It is better to use an SMSC simulator while you are writing your code rather than hit the live SMSC each time while you are still developing your program. Plenty of free SMSC simulators are available online.

http://opensmpp.logica.com/CommonPart/Download/download2.html

OK now let us revisit the API (the first one, SMPPAPI). The most important classes which you need to know very quickly are

ie.omk.smpp.Connection
ie.omk.smpp.message.SMPPPacket
ie.omk.smpp.message.SubmitSM
ie.omk.smpp.message.SubmitSMResp
ie.omk.smpp.event.SMPPEvent
ie.omk.smpp.event.ConnectionObserver

In the next post, I ll give an overview of how to actually use these classes to be able to send an SMS from your code to a mobile phone.

to be continued...

6 comments:

Anonymous said...

Nice summary.
Looks good for reference purpose as well as quick intro.

Raja Ghulam Rasool said...

Tahir, thanks for your review :)

Hammad said...

Very clear and clean explanation. Waiting for 2nd part.

Anonymous said...

I came across these terminologies while implementing the SMS Service for my company.

Do u know that there are many things you cant do through Code which can be done by Cell phone to Cell Phone SMS ? How about elaborating that ;)

Let me tell you one. Etisalat is still unable to give the Confirmation Reports than it usually delivers to the cell phone on successful receipt of the SMS.

Raja Ghulam Rasool said...

Hammad, thanks for your comment I will write the second part as soon as I get some time :)
Shoaib, wow ! dude good to know that you have worked on SMS, I am impressed :P, but relax man, you can't expect me to write everything in one post do you ? I'll get to that part and we can discuss it then :)
Cheers, keep reading keep posting :)

Umer Farooq said...

when is the next post coming?