Tuesday, April 20, 2010

SMS UDH Binary and Concatenated

As a standard SMS can only contain 160 7-bit GSM characters, Concatenated SMS are used to send long SMS which are bigger then 160 characters. Concatenation allows a sender to send more than one SMS which then get stuck together automatically by the phone to appear as one message.

To indicate that the content contains a UDH, a flag on the SMS called the UDH Indicator (UDHI) must be turned on. This tells the phone that it must separate the UDH from the rest of the content.

UDH

Format of an SMS with a UDH

The phone separates the UDH by reading the first byte of the content. The number in this byte is the length of the rest of UDH and is called the User Data Header Length (UDHL). The phone then knows how many bytes make up the UDH and can separate it from the rest of the message.

There are two main kind of SMS systems one is Smart Messaging which is for NOKIA supported and sets (include almost all brand except older version of Sony and Ericsson), and other one is EMS (Enhanced messaging system), both have different type of content and UDH encoding , first with the common between them.

  1. both have same algo to build UDH .
  2. data and udh for both systems are only in hex i.e char having 0-9 or A-F.
  3. both have same Header for split messages i.e. concatenated messages,
    for nokia it goes like for each binary messages there is data and UDH part now Nokia identifies coming binary message as ringtone, pic ,logo etc because of port number present in its header, lets consider full UDH of Nokia

 

06 05 04 1581 1581
06  -  length of whole UDH i.e 6 octet now each octet has two char so 050415811581 counts to 6 octet, got it?, now
05  - it represents as keyword for 16-bit nokia port addressing(according to specs of smart messaging)
04  -  its again count of upcoming octets i.e. 4 ,
1581  -  it is destination port mentioning port number in hex for ringtone, in other words this the thing which identifies upcoming message as ringtone.
1581  -  it is source port , when a ringtone is sent from handset to handset it automatically becomes 1581, but when you send it via GSM modem or SMPP connection it can be assigned to any valid hex string, preferably 0000.

so instead of ringtone if we are sending picture message, or logo or anything else then we just have to change destination port number for different binary messages it is as follows

Ringtone - 1581
CGI /CLI - 1583
Picture Msg- 158A
Operator Logo 1582
vCard 23F4
vCard Secure 23F6
vCalendar 23F5
vCalendar Secure 23F7
eMail Notification 1588
DMCP(obsolete) 1584

now if our message is bigger than preferably 260 chars we need to break it into more than one part ,, that's called concatenation for that you need to append concat header in UDH which goes like

00 03 XX 0N 0n 

it looks confusing but let me explain it ,
00 is offset to mention its new part of UDH


03 is according to specs concat header


XX it can be from 00 to FF , it is called message reference header , its same in UDH of all splited message in order to make receiving body understand that incoming splitted message is part of earlier received message because it has same reference string, get it??


0N represents total count of messages, like after splitting there are 3 parts then it is 03 , so here u can deduce that SMS support maximum 255 splits, becoz 25 if FF and it is largest 2 digit hex number.
0N represents sequence number of upcoming sms part like for first part it will be 01 for next it will be 02 and so on up to 0N,

now there is somthing u should take care of when we append concat header whole UDH becomes of 22 char i.e. 11 octets so UDH begins with 0B instead of 06 so for SMS of 3 splits of ringtone type UDHs will be


0B0504158115810003AF0301
0B0504158115810003AF0302
0B0504158115810003AF0303


this is all about Smart messaging, now EMS is even more simpler,  there is no data part in EMS all is bundled together in UDH its like


XX0CXX00<data hex string>
first XX = length of total data
0C is according to EMS specs octet for melody sound
second XX is length of rest part of data, 00 is offset to show start of data part data part it hex form of iMelody string, now even in EMS concat system is same , as mentioned earlier, so just append 0003XX0N0n before 00 offset of EMS, count the chars and make changes accordingly,

14 comments:

  1. how did you compile the list of port numbers? i'm currently looking for a complete port list but don't see any in the etsi standards and I've a hard time finding something else. I found the nokia smart messaging specs but I'm not sure if they include all used port numbers by manufacturers.
    Thanks!

    ReplyDelete
  2. most of the nokia ports are the same with other manufactures as well. smpp spec should give u a list of ports.

    ReplyDelete
  3. Very nice article. You have explained the binary message concept very well.

    ReplyDelete
  4. i need to add a unique number in UDH, is it possible.
    i want to develop SMS Quiz System and i want to track the reply, so i want to put some id in UDH and when user reply then that id in UDH send back to server so i can track the correct answer against the id

    ReplyDelete
  5. i need to add a unique number in UDH, is it possible.
    i want to develop SMS Quiz System and i want to track the reply,
    so i want to put some id in UDH and when user reply then that id in UDH send back to server so i can track the correct answer against the id.
    any one have idea how to do that.

    ReplyDelete
  6. To my knowledge this is not possible. The UDH headers are something that is used by the SMSC and it's the standard way of sending messages. I don't think you will be able to do this on the request itself. You will need to handle the logic within your application. You can have unique identifier for the question sent out and the msisdn you sent the question to on your programme and track the answer using that.

    ReplyDelete
    Replies
    1. False.

      UDH is inside UD, and you can always set whatever you want in this field, and you are able to set the UDHI in the PDU-Type octet (the first octet after the SCA ones) as well.

      Delete
  7. It was a triumph in as much as every generation needs a technology it can adopt freely, and the next generation took up SMS with enthusiasm http://padisoft.org

    ReplyDelete
  8. These SMS messages were sent to a central administration database, where they updated each officer's individual timesheet.padisoft.org

    ReplyDelete
  9. This article was written by a real thinking writer without a doubt. I agree many of the with the solid points made by the writer. I’ll be back day in and day for further new updates. Binary Today

    ReplyDelete
  10. Yeah!! SMPP is a well-renowned protocol used by the telecommunication industry for effective exchange of SMS between business units and the messaging servers. The gateway works as the relay and thus assists the SMPP Client entity to establish a secured connection with the server without facing any technical glitches. +91-9981122255 or taniya@msgclub.co.in

    ReplyDelete
  11. Awesome and interesting article. Great things you've always shared with us. Thanks. Just continue composing this kind of post. recover lost bitcoins

    ReplyDelete
  12. Greater part of SMS suppliers will cite their administrations and charging framework on a credit premise. Bulk SMS API

    ReplyDelete