What is Replace Message?
The 3GPP (ETSI) standard for GSM communication specifies a way to replace an existing message on a mobile phone by sending another message. I had a requirement to use this functionality with Kannel connected to an SMS GW that communicates over SS7/MAP.
Using Kannel to Replace Message
Sending a self destruct or replaceable message is pretty easy with Kannel as long as your SMSC supports it.
Send first SMS with pid=65
Send second SMS with pid=65
Quest for correct PID value
The documentation of Kannel doesn’t provide any information about the method at all. It however mentions the field PID that can be set while sending SMS. Looking at some forums related to NowSMS gateway, it appeared that PID can be used to send such SMS.
The next issue was to find out what exact value to provide as NowSMS GW allows a value of between
41--47 in decimal. This doesn’t work with Kannel.
3G TS 23.040 V3.2.0 (1999-10) on page 52-53 states this:
18.104.22.168 TP-Protocol-Identifier (TP-PID)
The TP-Protocol-Identifier parameter serves the purposes indicated in subclause 3.2.3. It consists of one octet, and the
bits in the octet are used as follows:
In the case where bit 7 = 0, bit 6 = 1, bits 5..0 are used as defined below
5 .. . .0
000000 Short Message Type 0
000001 Replace Short Message Type 1
000010 Replace Short Message Type 2
000011 Replace Short Message Type 3
000100 Replace Short Message Type 4
000101 Replace Short Message Type 5
000110 Replace Short Message Type 6
000111 Replace Short Message Type 7
Here is explanation of Replace Short Message from standard
The Replace Short Message feature is optional for the ME and the SIM but if implemented it shall be performed as
For MT short messages, on receipt of a short message from the SC, the MS shall check to see if the associated Protocol
Identifier contains a Replace Short Message Type code.
If such a code is present, then the MS will check the originating address and replace any existing stored message having
the same Protocol Identifier code and originating address with the new short message and other parameter values. If
there is no message to be replaced, the MS shall store the message in the normal way. The MS may also check the SC
address as well as the Originating Address. However, in a network which has multiple SCs, it is possible for a Replace
Message type for a SM to be sent via different SCs and so it is recommended that the SC address should not be checked
by the MS unless the application specifically requires such a check.
According to this
01000001 or in decimal
65 would give me Replace Short Message Type 1 and it can go upto
I have tested this on Samsung, Nokia, HTC and iPhone. Seems to work fine on all of these.