Escolar Documentos
Profissional Documentos
Cultura Documentos
A reliable method of rejoining
Received concatenated
SMS text messages
By William Sengdara
Revision 2: August 2010
Introduction
The issue at hand is that of the concatenated text messages. These are messages that are a result of a text message exceeding 160
characters being broken up into 2 or more segments by the cell phone and sent out by the mobile network: each segment will have
a different time stamp and portion of the whole message but all will be identified by a unique ID. This metadata is packaged in the
SMS PDU.
Let me demonstrate with a very crude example:
e.g. This is a sample message that I am writing to my darling – she is currently watching a romantic movie and hates being disturbed.
Part 1: This is a sample message that I am writing to
Part 2: my darling – she is currently watching a romantic
Part 3: movie and hates being disturbed.
In the case of a normal mobile phone, upon receiving these segments, it is designed to rejoin the pieces back to form the original
messages automatically, as they reach the device.
The issue is quite different when it comes to receiving text messages on a computer: an SMS server needs to be able to employ a
most reliable method of rejoining these messages once they have been received. We shall now discuss one such test method, which
we shall henceforth refer to as method X.
This method is actually employed in my own SMS Server and is very reliable.
Method X
We shall create a class to be responsible for the management of the concatenated text message issue. We shall call this class
ClassConcatProc. Another dependency class will be for decoding a PDU and determining whether the message is a concatenated or
not; upon this result, we shall continue with the concatenation procedure or halt. We shall call this class ClassConcatProps.
Where the User Data Header of a text message is set, it includes the following pieces of information of interest:
• An indicator of whether the message is concatenated or not
• A unique identifier which is shared between the segments of the entire message
• A number that indicates the total number of segments
• A number which indicates the current segment number
It should be noted that the concatenated message segments arrive in a random order. So that segment 4 of 4 messages may arrive
before segment 1 and 3 and so forth. Thus, we have to store these segments and then join them together as they arrive and display
the message.
It should also be noted that we cannot wait for all the segments to arrive before we display the message, due to the possibility that
some of the segments may be lost and are never be received at all. Thus, we must join any of the received segments together and
display them, and then add the rest as they arrive to the final message.
We shall thus employ a temporary storage area for the segments. The final message is stored in MySQL but the temporary segments
are stored in Microsoft Access.
Structure of the temporary storage in Microsoft Access
We shall now create a table in Microsoft Access for the temporary storage of the concatenated messages. We shall assume,
incorrectly and lazily, that each of the parts is 160 characters.
Our table will accommodate for 10 segments, this is a possible overestimation.
10 segments x 160 characters yield a total of 1600 characters in total which will be the size of our MySQL SMS_RECV.Message field.
The table will have an underscore as the default for the segment fields to make it easy to identify missing segments.
PartsID PartsTotal PartsReceived DateTime P1 P2 P3 P4 P5 P6 P7 P8 P9 P10
157 3 2 Etc Korea Is _ _ _ _ _ _ _ _
101 4 3 Etc There Is _ Good _ _ _ _ _ _
112 5 4 Etc What Is The Time _ _ _ _ _ _
102 3 2 Etc What Is _ _ _ _ _ _ _ _
119 8 4 Etc Why Are We _ ? _ _ _ _ _
132 10 0 Etc _ _ _ _ _ _ _ _ _ _
Figure 1.1 The missing segments are indicated by an underscore.
Structure of SMS_RECV in MySQL Server
Inside Microsoft Access (note that there is no Primary key defined)
The following statements about concatenated messages are valid
1. Unique segment identifiers are only unique between different segments of the same phone. They are not unique so that you
must use the phone number + segment identifier to identify the messages.
2. Expect some segments to never arrive
Below is a diagram of what the process looks like
A sample from the SMS Server log file
2010/07/25 19:47:59 _concat New concat_sms from Jonathan.1. (id 221, 1/4)
2010/07/25 19:47:59 _concat clearCompletedSegments ‐> 0 record(s) have been affected.
2010/07/25 19:47:59 _concat appended‐msg: 'Well just keep me updated about new developments. Im not going to be using works computer
anymore for my multimedia the other day something dangerous ha'
2010/07/25 19:47:59 _concat virgin segment: No previous segments recorded in MySQL yet.
2010/07/25 19:47:59 _concat first‐time‐segment successfully added to MySQL.
2010/07/25 19:47:59 _concat clearCompletedSegments ‐> 0 record(s) have been affected.
2010/07/25 19:47:59 _concat New concat_sms from Jonathan.1. (id 221, 2/4)
2010/07/25 19:47:59 _concat clearCompletedSegments ‐> 0 record(s) have been affected.
2010/07/25 19:47:59 _concat appended‐msg: 'ppend. I put a 32 gig usb stick into the pc and started scanning it with bitdefender and after 5
minutes a message in a blue window came up and it said w'
2010/07/25 19:47:59 _concat mysql‐updated: 'Well just keep me updated about new developments. Im not going to be using works computer
anymore for my multimedia the other day something dangerous happend. I put a 32 gig usb stick into the pc and started scanning it with
bitdefender and after 5 minutes a message in a blue window came up and it said w__'
2010/07/25 19:47:59 _concat clearCompletedSegments ‐> 0 record(s) have been affected.
2010/07/25 19:48:28 _concat New concat_sms from Jonathan.1. (id 221, 3/4)
2010/07/25 19:48:28 _concat clearCompletedSegments ‐> 0 record(s) have been affected.
2010/07/25 19:48:28 _concat appended‐msg: 'indows has encountered a problem and needs to be shut down and if problem persists then
bitdefender must be uninstalled so i just switched the pc off and'
2010/07/25 19:48:28 _concat mysql‐updated: 'Well just keep me updated about new developments. Im not going to be using works computer
anymore for my multimedia the other day something dangerous happend. I put a 32 gig usb stick into the pc and started scanning it with
bitdefender and after 5 minutes a message in a blue window came up and it said windows has encountered a problem and needs to be shut down
and if problem persists then bitdefender must be uninstalled so i just switched the pc off and_'
2010/07/25 19:48:28 _concat clearCompletedSegments ‐> 0 record(s) have been affected.
2010/07/25 19:48:28 _concat New concat_sms from Jonathan.1. (id 221, 4/4)
2010/07/25 19:48:28 _concat clearCompletedSegments ‐> 0 record(s) have been affected.
2010/07/25 19:48:28 _concat appended‐msg: ' switched it on again and i formatted the usb stick and things came back to normal but some
terrible virus must have been on that stick'
2010/07/25 19:48:28 _concat mysql‐updated: 'Well just keep me updated about new developments. Im not going to be using works computer
anymore for my multimedia the other day something dangerous happend. I put a 32 gig usb stick into the pc and started scanning it with
bitdefender and after 5 minutes a message in a blue window came up and it said windows has encountered a problem and needs to be shut down
and if problem persists then bitdefender must be uninstalled so i just switched the pc off and switched it on again and i formatted the usb stick and
things came back to normal but some terrible virus must have been on that stick'
2010/07/25 19:48:28 _concat clearCompletedSegments ‐> 1 record(s) have been affected.