[SMPP] Sending long SMS through SMPP
SMS is designed to send small text messages upto 140 chars. It actually depends upon the encoding. Using 7 bit encoding, you can send 160 chars, using Unicode, you can only send 70 chars. The data is carried in User Data section.
This post talks about ways of sending Long message using SMPP
Using SMPP we can send long SMS by two means
Using Payload option
Submit SM PDU has a field called message_payload. Set the data in it and you can send upto 64K octets. But this option is not supported by a lot of provider. Verify with your provider, if they support the same.
Using Message fragementation
This format is more common and widely supported. Essentially, the long SMS is divided into smaller messages and send with a particular format, by setting UDH.
The key TLV options used are
sar_msg_ref_num - The reference number for a particular concatenated short message
sar_total_segments - Indicates the total number of short messages within the concatenated short message
sar_segment_seqnum - Indicates the sequence number of a particular short message fragment within the concatenated short message
How do you set these, depends upon the SMPP library you use. Will brief the algo
- Break the long sms into parts, so that fragement can fit into single Submit SM PDU
- The total number of fragements shall give the value of sar_total_segments
- Generate a unique identifier value, this becomes the values of sar_msg_ref_num
- Now in a loop send the message fragements, with values in step above. sar_segment_seqnum values shall be the value of the loop count (ensure that it starts from 1)
This is it

Thanks, It is small but give me very useful idea to search ahead for it.
Hi,
I am unable to send some special characters through smpp like £(pound) ,• (bullet).
can you tell me how to generate unique sar_msg_ref_num for messages.I am using random number to generate for this.But some times we may get same random number diff requests.In that case both messages will be failed.
Vikram, I am not sure about how to send them. Can you try jsmpp forum.
Hi,
I am getting special chracters through smpp using my java code..
Now I am gettting diff problem.I am not getting long sms in one updation.In several updation I am getting complete long sms.
Is there any way to get complete sms in one updation???
Please help me…
Hi,
For each SubmitSM of the message fragment, do we get a SubmitSMResp?
Pls clarify
Yes it will. try it with real SMSC
Thanx a lot!!
Can anyone told me how can I add the optional paramter after the mandatory parameter. Can give me a example?
Can any body, please share java code to send Long SMS messages using SMPP Version 3.4?
How does JSMPP send 3000 – 5000 messages per second?
Meaning, is this by creating multiple threads or any particular mechanism.
Thanks in advance!!
Yup it uses Executors for the same. Though the number is not guranteed. A lot depends on how soon the SMPP Server is responding back to requests.
Thanks for the quick reply Ashish
What do you mean when you say by setting UDH?
There is a way of adding chars to the PDU but is not working on my SMPP Client
I think it’s because I’m not reciving the sm_resp from the SMSC and using the value.
Can you help me giving me a php code example of how you do this?
Thanks a lot.
Hi Ashish,
I have a query with regard to fragmentation. I need to send a long message using fragmentation i.e. dividing a long message into multiple short messages. Now, this has to be done along with encoding, say GSM 7-Bit. There are two scenarios:
a) Need to send fragments using SAR TLVs. The question arises whether I will fragment messages first and then encode it or other way. Let’s say I have original message spanning (in ASCII) 400 octets. Now, If I encode this message into GSM 7-Bit, then it converts to 350 octets (400 * 7/8). If I follow encode first, fragment next, then it means 3 fragments of 140, 140, 70 octets. What is the ideal way of doing it?
b) Need to send fragments using UDH. I have same question over ordering of encoding & fragmentation.
Please reply ASAP.
Hi can any body tell me how to send long concatenated sms using Logica smpp. Can somebody give me code to send long sms Please help.Thanks in advance.
hi
any one reply me plz…
i am send sms using jsmpp the msg send successfuly but cant able to read….it says “Unable to open. Message format not supported”
i am new for this…
how can identify find the error i dont knw wat to do..any one helpme its urgent……..
Anyone managed to send long Unicode messages with the logica smpp library?
Yes, you should set dataCoding value to 8 and use UTF-16 for encoding of the short message.
Figured it out. I had correctly constructed the UDH bytes and put the split message into a bytebuffer. But when I put the buffer back into a String I forgot to tell it the encoding to use.
Can you share the sample code with other? would be great. Thanks!
try
{
if(Text_SMS.length() > 160)
{
//SMS length is more than 160 Char
SubmitSM smRequest = new SubmitSM();
//Set other request values
smRequest.setEsmClass((byte)Data.SM_UDH_GSM); //Set UDHI Flag Data.SM_UDH_GSM=0×40
String[] splittedMsg = this.SplitByWidth(Text_SMS, 153);
int totalSegments = splittedMsg.length;
//iteerating on splittedMsg array. Only Sequence Number and short message text will change each time
for (int i = 0; i < totalSegments; i++) {
ByteBuffer ed = new ByteBuffer();
ed.appendByte((byte) 5); // UDH Length
ed.appendByte((byte) 0×00); // IE Identifier
ed.appendByte((byte) 3); // IE Data Length
ed.appendByte((byte) 2) ; //Reference Number
ed.appendByte((byte) totalSegments) ; //Number of pieces
ed.appendByte((byte) (i+1)) ; //Sequence number
//This encoding comes in Logica Open SMPP. Refer to its docs for more detail
ed.appendString(splittedMsg[i], Data.ENC_ASCII);
smRequest.setShortMessageData(ed);
smRequest.setSourceAddr(SourceAddr);
smRequest.setDestAddr(DestAddr);
resp = Server.session.submit(smRequest);
Date maDate = new Date();
if (resp.getCommandStatus() == Data.ESME_ROK) {
Log(MSISDN + " " + maDate.toLocaleString() + " : part "+(i+1)+"/"+totalSegments+" submitted. Status=0");
Thread.sleep(100);
}
else
{
Log(MSISDN + " " + maDate.toLocaleString() + " : part "+(i+1)+"/"+totalSegments+" submission failed. Status=" + resp.getCommandStatus());
//envoyé l'erreur au client
ByteSend= (MSISDN + " NOK").getBytes();
Out.write(rsaEncrypt(ByteSend));
break;
}
}
ByteSend= (MSISDN + " OK").getBytes();
Out.write(rsaEncrypt(ByteSend));
}
else // SMS length is less than 160 Char
{
SubmitSM msg = new SubmitSM();
msg.setSourceAddr(SourceAddr);
msg.setDestAddr(DestAddr);
msg.setShortMessage(Text_SMS);
resp = Server.session.submit(msg);
Date maDate = new Date();
if (resp.getCommandStatus() == Data.ESME_ROK)
{
Log(MSISDN + " " + maDate.toLocaleString() + " Message submitted. Status=0");
ByteSend= (MSISDN + " OK").getBytes();
Out.write(rsaEncrypt(ByteSend));
}
else
{
Log(MSISDN + " " + maDate.toLocaleString() + " Message submission failed. Status=" + resp.getCommandStatus());
//envoyé l'erreur au client
ByteSend= (MSISDN + " NOK").getBytes();
Out.write(rsaEncrypt(ByteSend));
}
}
}
catch (Exception e)
{
Log(String.valueOf(e.fillInStackTrace()));
fichierSortie.println (e.toString() + ": dans le MSISDN " + MSISDN);
}
Hello, i have a question.
What is the library (and version of it) you use in this example? It looks like Java SMPP Library by Logica, but in version that I found (The Java SMPP Library version 1.3) I dont see the method setShortMessageData( ByteBuffer byteBuffer ) in class SubmitSM.
Did you add it to the library by yourself?
If not, can you put correct link to the library you use?
for the method that spleet the SMS text
public String[] SplitByWidth(String s, int width) throws Exception
{
try
{
if (width==0)
{
String[] ret = new String[1];
ret[0]=s;
return ret;
}
else
{
if (s.isEmpty()) return new String[0];
else
{
if (s.length() <= width)
{
String[] ret = new String[1];
ret[0]=s;
return ret;
}
else
{
int NumSeg = s.length() / width + 1;
String[] ret = new String[NumSeg];
int startPos = 0;
for (int i = 0; i < NumSeg – 1; i++)
{
ret[i] = s.substring(startPos,((width*(i+1))));
startPos = (i+1)*width;
Log(ret[i]);
}
ret[NumSeg-1] = s.substring(startPos,s.length());
return ret;
}
}
}
}
catch (Exception e)
{
Log(String.valueOf(e.fillInStackTrace()));
return new String[0];
}
}
the code that I posted work with SMPP Logica 1.3, & I am searching how to send Long Arabic (UCS2) Unicode SMS :S
use setDataEncoding((byte) 2)
and setShortMessage(“blablabla”, “UTF-16″)
for long unicode UCS2 SMS I tested with logica today it’s working
this is the code:
Message =”لحمدُ لله ربِّ العالمين، والصلاةُ والسلامُ على مَنْ أرسله اللهُ رحمةً للعالمين، وعلى آله وصَحْبِهِ وإخوانِه إلى يوم الدِّين”;
String[] splittedMsg = Main.SplitByWidth(Message, 63);
int totalSegments = splittedMsg.length;
//iteerating on splittedMsg array. Only Sequence Number and short message text will change each time
for (int i = 0; i < totalSegments; i++) {
SubmitSM msg = new SubmitSM();
msg.setSourceAddr(SourceAddr);
msg.setEsmClass((byte)Data.SM_UDH_GSM); //Set UDHI Flag Data.SM_UDH_GSM=0×40
msg.setDataCoding((byte) 0×08);
ByteBuffer ed = new ByteBuffer();
ed.appendByte((byte) 6); // UDH Length
ed.appendByte((byte) 0×08); // IE Identifier
ed.appendByte((byte) 4); // IE Data Length
ed.appendByte((byte) 00) ; //Reference Number 1st Octet
ed.appendByte((byte) 00) ; //Reference Number 2nd Octet
ed.appendByte((byte) totalSegments) ; //Number of pieces
ed.appendByte((byte) (i+1)) ; //Sequence number
//This encoding comes in Logica Open SMPP. Refer to its docs for more detail
ed.appendString(splittedMsg[i], Data.ENC_UTF16_BE);
msg.setShortMessageData(ed);
System.out.println(splittedMsg[i]);
DestAddr.setAddress("213661133673");// 213661686742 0661686746 0661698177 0661686742 0661502966
msg.setDestAddr(DestAddr);
resp = session.submit(msg);
}
What is Main here?
can i have the full code which is there in Main too.
Hi,
Can anyone send the sample java code to send Long messages using Logica SMPP API’s version 1.3.
Thanks in advance.
Dharmendra Singh
Hi,
I have some problems regarding sms sending. Can some one please give me an idea on this regards.
When sending encoding the message for sending concatenated sms in GSM7-bit encoding, do we have to do the packing of bytes??
In the SMPP specification it is said that data_coding value 0 means SMSC default alphabet. Does this refers to GSM7, GSM7packed or does it depends on the SMSC??
Thanks and regards,
Nihanth.
You can show you how long the SMS through SMPP using C #
Hi,
How to add the sar_msg_ref_num into PDU?
I have 2 messages:
- “This is a message 001″ with the PDU in normal format: 0000004B0000000400000000000000020001013139303035373135393200010130313233363734353737380000000300000000000015546869732069732061206D65737361676520303031
- “This is a message 002″ with the PDU in normal format: 0000004B0000000400000000000000020001013139303035373135393200010130313233363734353737380000000300000000000015546869732069732061206D65737361676520303032
—> How to add the sar_msg_ref_num,sar_total_segments,sar_segment_seqnum into these PDUs?
Hi,
I have used Logica SMPP code with a client page. I am getting an error :
Exception: com.logica.smpp.pdu.InvalidPDUException
PDU debug string: (submit_resp: (pdu: 16 80000004 439 2) )
Underlying exception: com.logica.smpp.util.NotEnoughDataInByteBufferException: Not enough data in byte buffer. Expected 1, available: 0.
Did anyone came across it. Or anyone with a solution . Pls Suggest !!
Hi,
Can you help me please, i’m facing the same problem.
Did you find the cause of this exception.
Thanks in advance.
Also find the Log details :
main: Session.send(Request) trying to create pdu from unprocessed buffer (1)
07:28:57 main: Session.send(Request) PDU.setData() parsing header 00000019800000090000000000000001 (5)
07:28:57 main: Session.send(Request) PDU.setData() parsing body 62726d000210000134 (5)
07:28:57 main: Session.send(Request) have 5 bytes left. (5)
07:28:57 main: Session.send(Request) received complete pdu(bindresp: (pdu: 25 80000009 0 1) brm 52) (1)
07:28:57 main: Session.send(Request) there is 0 bytes left in unprocessed buffer (1)
07:28:57 main: Session.send(Request) ReceiverBase.receivePDUFromConnection finished (3)
07:28:57 main: Session.send(Request) Got pdu (bindresp: (pdu: 25 80000009 0 1) brm 52) (1)
07:28:57 main: Session.send(Request) Got response(?) pdu (bindresp: (pdu: 25 80000009 0 1) brm 52) (4)
07:28:57 main: Session.send(Request) checking response if it’s what we expected. (4)
07:28:57 main: Session.send(Request) exited
Hi ,
I am also using smpp protocol.I am sending the long unicode message with encoding format as UTF-16 for encoding the unicode message and using setmessagPayLoad(buffer bb)function for sending the long message. This method is defined in submit_sm class of smpp protocol.For me the receiver is getting the empty message suggest what to do so that receiver will get the correct encoded message.