SMPP Engineering

SMPP TLV Optional Parameters: Encoding, Delivery Receipts and Debugging

How SMPP v3.4 TLV optional parameters are encoded, which TLVs matter in practice (message_payload, SAR, receipted_message_id, message_state) and how to debug TLV problems on a live bind.

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 0x020C for sar_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

TLVTagSizeUsed for
message_payload0x0424up to 64 KBMessage text longer than 254 octets, sent in one submit_sm
sar_msg_ref_num0x020C2Reference shared by all parts of a concatenated message
sar_total_segments0x020E1Number of parts
sar_segment_seqnum0x020F1This part's position, starting at 1
receipted_message_id0x001Eup to 65In a delivery receipt: the message ID it reports on
message_state0x04271In a delivery receipt: final state of the message
network_error_code0x04233Network type (1 byte) plus operator error code (2 bytes)
user_message_reference0x02042Your own reference, echoed back by some SMSCs
source_port / destination_port0x020A / 0x020B2Application port addressing (WAP push, binary SMS)
sc_interface_version0x02101In bind_*_resp: the SMPP version the SMSC supports
ussd_service_op0x05011USSD 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:

  1. UDH concatenation: set esm_class bit 0x40 and prefix each part's short_message with a User Data Header. This is the most widely supported method and usually the safest default.
  2. SAR TLVs: send each part as its own submit_sm with sar_msg_ref_num, sar_total_segments and sar_segment_seqnum. The SMSC builds the UDH for you.
  3. message_payload: send the whole text in one submit_sm and let the SMSC split it. sm_length must be 0 and short_message empty. Sending both is a protocol error, and many SMSCs reject it with ESME_RINVPARLEN or 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:

ValueStateText equivalent
1ENROUTEENROUTE
2DELIVEREDDELIVRD
3EXPIREDEXPIRED
4DELETEDDELETED
5UNDELIVERABLEUNDELIV
6ACCEPTEDACCEPTD
7UNKNOWNUNKNOWN
8REJECTEDREJECTD

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_length equals the full PDU size including every TLV.
  • Check each TLV's length against its value. A 1-byte sar_total_segments sent 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.

Enterprise Consultation

Start Messaging with NAMX Telecom

Connect directly with our global wholesale connectivity team to discuss Web messaging platform access, SMPP v3.4/v5.0 binds, API connectivity, or custom pricing.

NAMX Telecom Operations

Global Telecom Network Hub 路 International Carrier Exchange

24/7/365 Global Network Operations Center (NOC)
Need to check previously stored inquiry entries?

Request a Wholesale Proposal

Fill in your parameters to receive a custom quote and technical spec.

|
Available on:
Direct delivery to admin@namxtelecom.site & namxtelecom@gmail.com