PDU Coding Protocol

Source: Internet
Author: User
PDU Coding Rules

Currently, text and PDU (Protocol Data Unit) are commonly used for sending short messages. Use text mode to send and receive short message code simple, easy to achieve, but the biggest drawback is not to send and receive Chinese text messages, and PDU mode not only support Chinese text messages, but also send English text messages. PDU mode send and receive SMS can use 3 kinds of encoding: 7-bit, 8-bit and UCS2 encoding. 7-bit encoding is used to send ordinary ASCII characters, 8-bit encoding is typically used to send data messages, and UCS2 encodings are used to send Unicode characters. The general PDU code consists of a B C D E F G H I J m 13.

A: SMS Center address length, 2-bit hexadecimal (1-byte).
B: Short Message Center number type, 2-digit hexadecimal number.
C: The SMS Center number, the length of the b+c will be determined by the data in a.
D: File header Byte, 2-bit hexadecimal number.
E: Information type, 2-bit hexadecimal number.
F: Called number length, 2-digit hexadecimal number.
G: Called number type, 2-digit hexadecimal number, value same as B.
H: Called number, length is determined by the data in F.
I: Protocol ID, 2-bit hexadecimal number.
J: Data encoding scheme, 2-bit hexadecimal number.
K: Valid, 2-digit hexadecimal number.
L: User data length, 2-bit hexadecimal number.
M: User data, whose length is determined by the data in L. J is set to use UCS2 encoding, here is the Unicode character in English and Chinese.

PDU Coding Protocol Simple Description

Example 1 Send: Smsc number is +8613800250500, the other side number is 13693092030, the message content is "hello!". The PDU string sent from the phone can be
F0 0D F0 C8 (9B FD), at the same, and the 0E 01 of a
Control specifications, specific analysis:
Paragraph meaning description
A total of 8 eight-bit bytes (including 91) for the length of the SMSC address information
SMSC address Format (TON/NPI) in international format number (plus ' + ' in front)
F0 SMSC Address 8613800250500, add ' F ' to an even number
11 Basic parameters (TP-MTI/VFP) sent, TP-VP in relative format
00 Message base value (TP-MR) 0
0D the number of destination addresses is 13 decimal digits (excluding 91 and ' F ')
91 Destination Address format (TON/NPI) in international format number (plus ' + ' in front)
F0 Target Address (TP-DA) 8613693092030, complement ' F ' to several even
00 Protocol identification (TP-PID) is a common GSM type, point-to-point way
00 User Information encoding mode (TP-DCS) 7-bit encoding
00 Validity period (TP-VP) 5 minutes
06 User Information Length (TP-UDL) actual length 6 bytes
C8 9B FD 0E 01 user information (Tp-ud) "hello!"

Example 2 Receive: SMSC number is +8613800250500, the other side number is 13693092030, the message content is "Hello!". The PDU string that the handset receives can be
F0 0D F0 (4F) 7D 00 21, at the same, and at the same, in the same.
Control specifications, specific analysis:
Paragraph meaning description
08 the length of the address information is eight bits (including 91)
SMSC address Format (TON/NPI) in international format number (plus ' + ' in front)
F0 SMSC Address 8613800250500, add ' F ' to an even number
84 Basic parameters (TP-MTI/MMS/RP) receive, no more messages, have reply address
0D Reply Address number is 13 decimal digits (excluding 91 and ' F ')
91 Return address format (TON/NPI) in international format number (plus ' + ' in front)
F0 Reply to Address (Tp-ra) 8613693092030, complement ' F ' together with several
00 Protocol identification (TP-PID) is a common GSM type, point-to-point way
08 User Information encoding mode (TP-DCS) UCS2 encoding
30 30 21 80 63 54 80 Timestamp (tp-scts) 2003-3-12 08:36:45 + 8 time zone
06 User Information Length (TP-UDL) actual length 6 bytes
4F 7D 00 21 user information (Tp-ud) "Hello!"


If the highest bit (TP-RP) of the basic parameter is 0, there is no three segment of the reply address. This is often the case with short messages sent from the Internet.
Note that the number and time representations are not followed in the normal order, and that the odd numbers are added to the "F" to even.


In PDU mode, you can encode the content that you send by using three encodings, which are 7-bit, 8-bit, and UCS2 encodings. The 7-bit encoding is used to send a generic ASCII character that encodes a string of 7-bit characters (up to 0) into 8-bit data, each 8 character "compressed" into 7; 8-bit encoding is often used to send data messages, such as pictures and ringtones. , and the UCS2 encoding is used to send Unicode characters. The maximum capacity of the user information (Tp-ud) segment of the PDU string is 140 bytes, so the maximum number of characters that can be sent in the three encoding modes are 160, 140, and 70, respectively. Here, an English letter, a Chinese character, and a data byte are treated as one character.


It is important to note that the user information length (tp-udl) of the PDU string is different in different coding modes. 7-bit encoding refers to the number of characters of the original short message, not the number of bytes encoded. 8-bit encoding is the number of bytes. When UCS2 is encoded, it is also a byte number, equal to twice times the number of characters in the original short message. If there is a header in the user information (Tp-ud) (The Tp-udhi of the basic parameter is 1), the user information length (tp-udl) is equal to the sum of the length of the header and the number of bytes encoded in the encoding mode. If the proposed compression algorithm for GSM 03.42 (Tp-dcs 3 bits is 001), the length is also the sum of bytes after compression encoding or the length of the header and the number of bytes after compression.

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.