Principle and Implementation of smpp long message splitting

Source: Internet
Author: User

The rules for sending and receiving short messages mainly include GSM 03.38, GSM 03.40, and GSM 07.05. The first two focuses on the technical implementation of SMS (including the encoding method), the latter sets out the DTE-DCE interface standard of SMS (AT command set ). Messages are sent and received in three minutes: Block, text, and PDU. Currently, block is rarely used. text is a plain text method and can use different character sets. Technically, it can also be used to send Chinese text messages, but it is basically not supported by Chinese mobile phones, it is mainly used in Europe and America. PDU is supported by all mobile phones and can use any character set. This is also the default encoding method for mobile phones.

A pdu string is an ascii code consisting of numbers and letters '0'-'9' and 'A'-'F. These are the hexadecimal numbers of 8-bit bytes. The PDU string contains not only the displayed message, but also many other information, such as the SMS service center number, target number, and encoding method. In PDU mode, three types of codes can be used to send Short Messages: 7-bit, 8-bit, and 16-bit (ucs2.

In the gsm_03.40 specification, the length of an SMS is defined:

140 characters: 8-bit encoding

160 characters: 7-bit encoding

70 characters: 16-bit encoding

Generally, there are two solutions for ultra-long text messages: one is to send multiple separate text messages, so that the mobile phone will receive multiple messages, second, multiple messages are sent through the udhi mechanism, so that a long message is displayed on the mobile phone in order. In terms of implementation principle, the first method is simpler, but the order in which messages arrive on the mobile phone may be disordered. The second method is better, the following describes how to send long text messages over the smpp protocol.

To send an ultra-long message, you need to do two things: set the value of tp_udhi to 1 and add the protocol header to the message body. The protocol can be in the following two formats: 6 protocol headers and 7 protocol headers. The format is as follows:

6-bit protocol Header Format: 05 00 03 xx mm NN
Byte 1: 05, indicating the length of the remaining protocol header
Byte 2: 00, which is defined in GSM 03.40 specification 9.2.3.24.1, indicates that the identification space length of the subsequent ultra-long messages is 1 (xx value in the format ).
Byte 3: 03. This value indicates the length of the remaining text message identifier.
Byte 4: XX, the only identifier of this batch of text messages. In fact, SME (mobile phone or SP) record the message after merging, so it is not very important to determine whether this identifier is unique.
Byte 5: Mm, the number of messages in this batch. For a total of five ultra-long text messages, the value here is 5.
Byte 6: NN, number of messages in this batch. If the value of the first text message in this batch is 1, the value of the second text message is 2.
Example: 05 00 03 39 02 01

7-bit protocol Header Format: 06 08 04 xx mm NN
Byte 1: 06, indicating the length of the remaining protocol header
Byte 2: 08, which indicates that the identification space length of the subsequent ultra-long messages is 2 (XX value in the format) according to the GSM 03.40 specification 9.2.3.24.1 ).
Byte 3: 04. This value indicates the length of the remaining text message identifier.
Byte 4-5: XX, the only sign of this batch of text messages. In fact, after SME (mobile phone or SP) merges the messages, record them, therefore, it is not important to determine whether the logo is unique.
Byte 6: Mm, the number of messages in this batch. For a total of five ultra-long text messages, the value here is 5.
Byte 7: NN, the number of messages in this batch. If the value of the first text message in this batch is 1, the value of the second text message is 2.
Example: 06 08 04 00 39 02 01

The difference between the 7-bit protocol header and the 6-bit protocol header is that the ID field of the 6-bit protocol header text message is one byte, and the flag field of the 7-bit protocol header text message is two bytes. Most mobile phones use 6-bit protocol headers, that is, 05 00 03 xx mm NN.

Use the Logica open smpp API to split long messages. For example:

// Refer to 3GPP ts 23.040 v6.8.1 (2006-10133) // set udhi flag data. sm_udh_gsm = 0x40request. setesmclass (byte) data. sm_udh_gsm); // sets the UDH content bytebuffer ED = new bytebuffer (); ed. appendbyte (byte) 5); // UDH lengthed. appendbyte (byte) 0x00); // ie identifiered. appendbyte (byte) 3); // ie data lengthed. appendbyte (byte) refnum); // reference numbered. appendbyte (byte) totalsegments); // Number of piecesed. appendbyte (byte) I); // sequence numberstringbuilder builder = new stringbuilder (); // encode the text message content try {ed. appendstring (message, encode); Request. setinclumessagedata (ed); return request;} catch (exception e ){}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.