How to configure the SMPP Replace if Present Field
What is the Replace If Present Field?
The Replace If Present field in SMPP is a 1-byte flag in PDUs like submit_sm
that instructs the SMSC to replace
an existing message stored on the recipient's device or SMSC queue. Key applications include:
- Updating time-sensitive content (e.g., OTPs, status alerts)
- Preventing duplicate messages
- Managing device storage constraints
Field Values and Interpretation
The field uses a simple boolean-like structure:
Value (Hex) | Description |
---|---|
0x00 | Do NOT replace existing messages (default) |
0x01 | Replace existing messages if present |
Note: Message replacement logic depends on SMSC implementation. Common matching criteria include:
- Source/Destination addresses
- Message ID (if provided)
- Protocol ID (PID=0x41 often triggers replacement)
Use Cases
1. OTP Message Update
replace_if_present: 0x01 // Replace prior OTP message PID: 0x41 // Protocol ID for replacement payload: "Your new OTP: 5678"
2. Campaign Message Refresh
replace_if_present: 0x01 // Update promotional content PID: 0x00 // Default protocol payload: "Flash Sale: New prices!"
3. Queue Management
replace_if_present: 0x01 // Overwrite queued message scheduled_delivery_time: (future timestamp)
Example SMPP PDUs
Example 1: Replacement Disabled (0x00)
0000001D // Command Length (29 bytes) 00000004 // Command ID (SubmitSM) 00000001 // Sequence Number ... 00 // Replace If Present (0x00: Disabled) ... 07 // SM Length (7 septets) C8329BFD06DDDF72 // Payload ("Hello!")
Example 2: Replacement Enabled (0x01)
0000001D // Command Length (29 bytes) 00000004 // Command ID (SubmitSM) 00000002 // Sequence Number ... 01 // Replace If Present (0x01: Enabled) ... 07 // SM Length (7 septets) E8329BFD0E... // Payload ("Updated: 3 PM")
Example 3: Combined with PID=0x41
0000001D // Command Length (29 bytes) 00000004 // Command ID (SubmitSM) 00000003 // Sequence Number ... 41 // Protocol ID (PID=0x41: Replace) 01 // Replace If Present (0x01) ... 07 // SM Length (7 septets) C8329BFD06... // Payload ("OTP: 9876")
Interactions with Other Fields
- Protocol ID (PID): PID=0x41 explicitly triggers replacement in many SMSCs
- message_id: Some SMSCs use this to identify messages for replacement
- registered_delivery: Receipts indicate whether replacement succeeded
Common Pitfalls
- Enabling replacement without SMSC support
- Not setting
message_id
for targeted replacement - Assuming all SMSCs use the same replacement logic
- Mismatching PID and replace_if_present values
SMSC Behavior Note:
Replacement policies vary widely. Some SMSCs:
Replacement policies vary widely. Some SMSCs:
- Only replace messages with matching source/destination
- Ignore replace_if_present if PID≠0x41
- Limit replacement to messages in the SMSC queue (not delivered)
Conclusion
The Replace If Present field provides critical control over message lifecycle management but requires careful coordination with SMSC capabilities. Always verify replacement behavior with your provider and use PID=0x41 for explicit replacement requests. For detailed implementations, refer to SMPP v3.4 Section 5.2.20 and GSM 03.40 documentation on message handling.
More information
- How to configure the SMPP Service Type field
- How to configure the SMPP Phone Number fields
- How to configure the SMPP ESM Class field
- How to configure the SMPP PID field
- How to configure the SMPP Prioirity field
- How to configure the SMPP Scheduled Time field
- How to configure the SMPP Validity Period field
- How to configure the SMPP Registered Delivery field
- How to configure the SMPP Replace if Present field
- How to configure the sm_default_msg_id field
- How to configure the SMPP DCS field
- How to calculate the SMPP SM Length field
- How to put data into the SMPP SM field