- User Data Header (UDH)
- Connector keywords
EMG handles messages longer than one SMS (concatenated SMS) and can transparently split a long message into multiple SMS.
It can also merge multiple sms that are parts of a longer message which can be forwarded via http, for example, as one long message.
One sms can hold 1120 bits of message payload which translates into 160 characters of 7-bit text, 70 characters of 16-bit UCS2 text or 140 bytes of binary data.
User Data Header (UDH)
When a SMS holds a part of a longer (concatenated) message a binary header called User Data Header will be present in the message data.
This header is in binary format and in the concatenated message case will tell the message part number and the total number message parts the long message is made up of.
A minimal UDH for concatenated messages will be 6 bytes long and is binary (8-bit). This means that the actual message data for a 7-bit message can only hold up to 153 characters. The UDH uses 48 bits which (rounded up to closest 7-bit boundary) “steals” 49 bits = 7 characters.
Sample UDH which concat message info:
0500033C0201 05 = UDH length, 5 bytes00 = UDH type, 00 = concatenated message 03 = Length of concat message header, 3 bytes 3C = Concat message reference number 02 = Total number of parts in message, 2 parts 01 = Sequence number for this part, 1
Normally messages sent over SMPP puts the message data in the “short_message” field in a submit_sm or data_sm operation.
The “short_message” field is a variable length field that holds up to 255 characters.
For longer messages (if connector keyword MESSAGELENGTH has been increased) optional parameter (TLV) “message_payload” will be used instead. This field can hold up to 64k of message data.
If a message with UDH is sent over SMPP the field “esm_class” must have bit 6 (value 64) set. This will set the User Data Header Indicator (UDHI) for the message.
When EMG billing is used message will be initially billed a default charge when received by EMG.
At a later stage when the message has been sent EMG will correct the charge based on the charge set and the number of pdus required to send the message.
For example, consider a long message is received via http and then forwarded as 3 parts / pdus. Default charge is set to 0.01 but the price for one sms via the route determined for message is 0.02.
EMG will initially bill 0.01 towards the users charge balance when the message is received but will then bill another 0.05 since the message charge was in fact 0.02 and the message was sent in 3 parts giving a total charge of 0.06.
If a concatenated message is received in multiple parts via SMPP to be forwarded via, for example, HTTP which has no length restriction EMG can merge the parts together before sending the message via HTTP.
This is configured by adding connector keyword “MERGE” to the sending connector. By default EMG will wait for 10 seconds for all parts to arrive. This can be changed via keyword “MERGE_EXPIRES”.
If all parts have not been received before timeout has been reached EMG will forward the received parts separately without any merging taking place.
A long message split by EMG when sent will have multiple connector log entries for the same message id. Each log entry has a “pdu” section:
2016-11-0808:50:23.704442(0) SEND OK (pdu=1/2) 001:58021940... 2016-11-0808:50:23.705592(0) SEND OK (pdu=2/2) 001:58021940...
If a concatenated message has been sent via SMPP, each pdu will have the esm_class parameter set which shows up in the pdu log:
2016-11-08 08:50:23.696106 INFO (clx,0) Write op:0x00000004 (SUBMIT_SM) status:0 trn:2847 datalen:198 SOURCEADDRTON:5 SOURCEADDRNPI:0 SOURCEADDR:test DESTADDRTON:1 DESTADDRNPI:1 DESTADDR:4676xxxxxxx ESMCLASS:64 PROTOCOLID:0 PRIORITYFLAG:0 REGISTEREDDELIVERY:1 REPLACEIFPRESENT:0 DATACODING:0 SMDEFAULTMSGID:0 SMLENGTH:159 SHORTMESSAGE:0500033C0201... 2016-11-08 08:50:23.696274 INFO (clx,0) Write op:0x00000004 (SUBMIT_SM) status:0 trn:2848 datalen:82 SOURCEADDRTON:5 SOURCEADDRNPI:0 SOURCEADDR:test DESTADDRTON:1 DESTADDRNPI:1 DESTADDR:4676xxxxxxx ESMCLASS:64 PROTOCOLID:0 PRIORITYFLAG:0 REGISTEREDDELIVERY:0 REPLACEIFPRESENT:0 DATACODING:0 SMDEFAULTMSGID:0 SMLENGTH:43 SHORTMESSAGE:0500033C0202...
If EMG receives a long message and splits it into multiple parts npdus field of the routelog entry will be set to the number of parts (pdus).
A routelog.npdus value of 3 means that message was split into 3 parts when EMG sent it.
The total cost for a message where routelog.charge is set would be npdus * charge.
Sample sql to calculate total cost for messages sent by user “user1” during June 2016:
SELECT SUM(IFNULL(npdus, 1)*charge) FROM routelog WHERE username = 'user1' AND starttime >= '2016-06-01' AND starttime < '2016-07-01' AND msgtype = 1;
Below you find connnector keywords that affect how EMG handles long / concatenated messages.
|PRE_SPLIT||Force splitting of message before message is received by EMG. This will cause all message parts to be billed immediately by EMG.|
|MESSAGELENGTH||The number of 7-bit characters that can be sent in one part via the connector. Default: 160 for SMS protocols (SMPP, UCP, CIMD2).|
|MERGE_EXPIRES||Specifies time to wait for concatenated message parts after first part has been received. Default: 10 (seconds).|
|MERGE||Wait for parts of a concatenated message and send full message. Normally used when forwarding messages via HTTP.|
|LONGMODE||Specifies how “too long” (message length > max message length) messages should be handled, truncate or reject. Default: Truncate.|
|LONGMESSAGE||Specifies the max number of parts that can be sent via connector for one message. Default: 4.|