SMPP v3.4 PDUs have two parts: a fixed list of mandatory parameters and an optional tail of TLV (Tag-Length-Value) parameters. TLVs are how SMPP carries anything the mandatory body has no field for, such as long payloads, segmentation details and structured delivery receipt fields. Most integration bugs that look like "the carrier is broken" come down to a TLV being encoded, expected or ignored differently on the two sides of a bind.
1. How a TLV is encoded
Every TLV has the same three fields, written in network byte order (big-endian):
- Tag: 2 bytes identifying the parameter, for example
0x020Cforsar_msg_ref_num. - Length: 2 bytes giving the size of the value only, not including the tag and length fields.
- Value: the parameter data, in the type the specification defines (integer, C-octet string or octet string).
Example: sar_msg_ref_num with reference number 66 is encoded as:
02 0C tag = 0x020C (sar_msg_ref_num)
00 02 length = 2 bytes
00 42 value = 66
TLVs always come after the last mandatory parameter, in any order, and the PDU's command_length must include them. A wrong command_length is the most common TLV bug: the peer reads the TLV bytes as the start of the next PDU and the bind fails with a framing error, or the TLV is silently dropped.
2. The TLVs you will actually meet
| TLV | Tag | Size | Used for |
|---|---|---|---|
message_payload | 0x0424 | up to 64 KB | Message text longer than 254 octets, sent in one submit_sm |
sar_msg_ref_num | 0x020C | 2 | Reference shared by all parts of a concatenated message |
sar_total_segments | 0x020E | 1 | Number of parts |
sar_segment_seqnum | 0x020F | 1 | This part's position, starting at 1 |
receipted_message_id | 0x001E | up to 65 | In a delivery receipt: the message ID it reports on |
message_state | 0x0427 | 1 | In a delivery receipt: final state of the message |
network_error_code | 0x0423 | 3 | Network type (1 byte) plus operator error code (2 bytes) |
user_message_reference | 0x0204 | 2 | Your own reference, echoed back by some SMSCs |
source_port / destination_port | 0x020A / 0x020B | 2 | Application port addressing (WAP push, binary SMS) |
sc_interface_version | 0x0210 | 1 | In bind_*_resp: the SMPP version the SMSC supports |
ussd_service_op | 0x0501 | 1 | USSD session operations over SMPP |
Tags from 0x1400 to 0x3FFF are reserved for vendor-specific TLVs. Carriers use them for things such as billing identifiers, operator MCC-MNC or regulatory fields like a template ID. Ask your supplier for their TLV list before you go live.
3. Check the bind response first
An SMSC that supports TLVs returns sc_interface_version (0x0210) in its bind_transceiver_resp. A value of 0x34 means v3.4. If the TLV is missing, the specification says to assume the SMSC does not support optional parameters. In practice that means a v3.3-style platform, and any TLV you send may be ignored. Log the bind response on every connection; it settles most "why is my TLV ignored" questions immediately.
4. Long messages: message_payload, SAR TLVs or UDH
There are three ways to send text longer than one SMS, and suppliers do not all support all three:
- UDH concatenation: set
esm_classbit0x40and prefix each part'sshort_messagewith a User Data Header. This is the most widely supported method and usually the safest default. - SAR TLVs: send each part as its own
submit_smwithsar_msg_ref_num,sar_total_segmentsandsar_segment_seqnum. The SMSC builds the UDH for you. message_payload: send the whole text in onesubmit_smand let the SMSC split it.sm_lengthmust be0andshort_messageempty. Sending both is a protocol error, and many SMSCs reject it withESME_RINVPARLENor a vendor error.
Never mix methods within one message. Using UDH and SAR TLVs together produces doubled headers, and the handset shows garbage at the start of each part.
5. Delivery receipts: read the TLVs, not just the text
A delivery receipt arrives as a deliver_sm with esm_class bit 0x04 set. Its short_message usually holds the familiar text form:
id:0A1B2C3D sub:001 dlvrd:001 submit date:2611181020 done date:2611181020 stat:DELIVRD err:000 text:
That text format is only an informative appendix in the specification, and each vendor varies it. When the SMSC also sends receipted_message_id, message_state and network_error_code, parse those first and fall back to the text. The message_state values are:
| Value | State | Text equivalent |
|---|---|---|
| 1 | ENROUTE | ENROUTE |
| 2 | DELIVERED | DELIVRD |
| 3 | EXPIRED | EXPIRED |
| 4 | DELETED | DELETED |
| 5 | UNDELIVERABLE | UNDELIV |
| 6 | ACCEPTED | ACCEPTD |
| 7 | UNKNOWN | UNKNOWN |
| 8 | REJECTED | REJECTD |
6. The message ID mismatch
The most common delivery receipt bug is that a receipt cannot be matched to the message it reports on. The message_id in submit_sm_resp is one string, while the id: field in the receipt text can be the same ID converted to decimal, zero-padded or truncated. receipted_message_id normally carries the ID exactly as it appeared in submit_sm_resp, which is another reason to prefer the TLV. If you must use the text field, store both the original ID and its hex/decimal conversion, and match on either.
7. Debugging checklist
- Capture the raw PDU in hex (Wireshark's SMPP dissector decodes TLVs) instead of relying on application logs.
- Check that
command_lengthequals the full PDU size including every TLV. - Check each TLV's length against its value. A 1-byte
sar_total_segmentssent as 2 bytes breaks strict parsers. - Peers should ignore TLVs they don't recognise. If yours rejects the whole PDU when it sees an unknown tag, fix the parser.
- Confirm the supplier's version from
sc_interface_version, and their concatenation and delivery receipt formats, during the test bind, not after go-live.
Related reading: what SMPP v3.4 is, configuring an SMPP bind and the SMPP error code and DLR reference. To check TLV handling against a live route, request an SMPP test bind.