7BIT 编码 长短信

5.5.4. UDH and Information Elements

User Data Headers (UDH) are a very general framework used by binary SMS in GSM networks to transmit special binary data associated with the message. An understanding of User Data Headers is a prerequisite to many of the binary SMS topics in the rest of the chapter.

When an SMS message is delivered to a phone over a GSM network, it contains both the usual 140 bytes of data and separate flags that record the encoding used by the data (GSM, UCS-2, or binary) and the presence of a User Data Header (UDH) at the beginning of the message.

5.5.4.1. Size and alignment

When there is a UDH, it is part of the 140 bytes of data, which then include the UDH followed by the SMS text or binary data. The total size of UDH plus text/data must stay within the 140-byte limit.

In most cases, the conversion between ASCII and GSM text is done by the network operators, and SMPP connections to a gateway usually require you to send ASCII characters instead of GSM ones. In that case, to send a UDH you just send the UDH followed by the 8-bit ASCII characters. But if you are expected to send 7-bit GSM text, you need to manually concatenate the UDH and the following 7-bit GSM text: make sure that the 7-bit GSM text starts on a 7-bit boundary by adding filling bits (if required) between the UDH and the 7-bit GSM text. "Filling bits" could be 1 or 0; they are ignored by the phone.

For example, if your UDH is 6 bytes (which is common for fragments of concatenated messages, as explained later in this chapter), you still have 134 bytes to send 7-bit GSM data. 134 bytes is 153 GSM characters and 1 bit. You need to add this one filling bit before the 7-bit GSM data, not afterwards., So your message will consist of the UDH (6 bytes), 1 filling bit, and 153 GSM characters. The UDH takes up 48 bits (6 bytes of 8 bits each), and adding the filling bit brings the total to 49, a multiple of 7 so the GSM text is aligned on a 7-bit boundary. It is also aligned with the end of the message, so there is no waste in the 140 available bytes.

你可能感兴趣的:(7BIT 编码 长短信)