145 American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) ISSN (Print) 2313-4410, ISSN (Online) 2313-4402 © Global Society of Scientific Research and Researchers http://asrjetsjournal.org/ A Singular Function Algorithm for Packing the Protocol Description Unit Packet Kumbirai T. Mukoseraa*, Gilford Hapanyengwib, Ben Nyamboc, Emmanuel Mashonjowad a,b,cComputer Science Department, Faculty of Science, University of Zimbabwe, Harare, Zimbabwe dPhysics Department, Faculty of Science, University of Zimbabwe, Harare, Zimbabwe aEmail: ktmukosera@gmail.com, bEmail: babaticha@gmail.com cEmail: bennynyambo@gmail.com, dEmail: emash@science.uz.ac.zw Abstract A new sequential singular function algorithm for packing Protocol Description Unit packets in the Short Message Mobile Originated Point-to-Point service is proposed. The single function algorithm simplifies the Short Message Entities programming where ATtention Commands are used to link Switched on Mobile Stations with Service Centers. This is in mode 0 of the short message service transmission. This paper shows that by using, only one single string function, the “Mid” or “Substring” function, it is still possible and is simpler to encode all the metadata contained in the Transport Protocol Data Unit frame of the Submit Protocol Description Unit packet. Our results show that, this proposed algorithm, always outputs 100% perfectly accurate packets for any combination of header and user data payload submitted in hexadecimal octets or decimal semi-octet format. It is thus possible for programmers not only to manipulate the distinct fields of the header data but also to modify the metadata using that single function only. Keywords: Algorithm; AT+CMGF=0; Mid String; PDU; SMS SUBMIT; Substring. 1. Introduction Short Message Point-to-Point Services (SMS) is an integral facility of the second generation (2G) Global System for Mobile (GSM) and its subsequent evolution generations [1]. It does not only give users a substitute way of transmitting in a cellular communication platform like GSM but it can at times be the only available option due to its low demand for strong signal strength to communicate [2]. ------------------------------------------------------------------------ * Corresponding author. http://asrjetsjournal.org/ American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2017) Volume 31, No 1, pp 145-155 146 Its operation between a Short Message Entity (SME) and a Short Message Service Centre (SMSC) is managed by an inbuilt asynchronous modem that is controlled via AT (ATtention) commands [3]. 1.1. The Text Mode and Protocol Description Unit (PDU) mode Only two modes of sending or receiving SMS exist on the GSM platform when using an AT commanded ETSI compliant asynchronous GSM modems for data uplink or downlink [4]. These two methods are, “the Text mode” and “the Protocol Description Unit (PDU) mode”. The text mode is the simplest to use and it is just but a higher level of the encoding of the bit streams in the PDU packet. It is activated when an “AT+CMGF=1” command is send to the GSM modem [5]. Unfortunately, the text mode, though easy to program, is limited in flexibility when it comes to how it can structure the different elements of the SMS content. Moreover, there is no guarantee that the text mode will be supported by any given mobile phone [5]. This is unlike with the PDU format which is mandatorily supported on any SME by GSM / ETSI standards [1]. Furthermore, alphabets of the text mode can differ and therefore the displayed messages can display differently from the original message which does not happen with the PDU format [6]. The contents are thus standardized when extracted under any operating system environment. PDU mode also gives the capability to specify the desired destination SME number [4], the period the SMS can be stored in the network suppose the SME device is not reachable and request for delivery reports can also be encoded in the message content [7]. Similarly, a message received in PDU format can display other specifications like the sending SME date and time, number and type of content so that the decoding process can be as accurate as intended. The PDU mode is activated when an “AT+CMGF=0” command is send to the GSM modem. Given the foregoing facts then, of the two methods of sending SMS from an active SME via an SMSC that are available, the most comprehensive is the Protocol Description Unit (PDU) format [5]. The PDU mode therefore, can be visualized as a management mode of all SMS data elements. It is more structured in the construction of the entity of the message when either sending or receiving an SMS. This is why of the two modes, this research prefers to focus on the PDU packet in more depth. As such, in this research we try to come up with only one function that will attempt to make it is as equally easy to implement the PDU packet from source code, as it is with the text mode to handle. In this process however, we still want to leave the programmer with the rich features inherent in the PDU frame design at the same time. 2. Review of the PDU packet The SMS submit PDU / Short Message Mobile Originated Point-to-Point (SMMO) [8] packet has two main parts which are the Service Centre Address (SCA) and the Transport Protocol Data Unit (TPDU). TPDU are the transport layer datagrams that move data packets between the SMEs and the SMSCs. It is mandatory for a response message to be sent back whenever a TPDU moves between these two systems [9]. The relationship between the SMS-SUBMIT PDU and the SCA and TPDU is given in figure 1 below. Not all SME support the full SMS submit PDU format. Some support only the TPDU format where there is no SCA in the PDU packet [3]. These SME will use the SCA which will have been stored in the SIM card by the network operator. This difference then leads to two types of PDU packets. The packet from the SME which supports only TPDU format would have the SCA part replaced with a 00 American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2017) Volume 31, No 1, pp 145-155 147 Hexadecimal octet [4]. SMS SUBMIT PDU PACKET Service Centre Address (SCA) Transport Protocol Data Unit (TPDU) Figure 1: SMS SUBMIT PDU structure A typical encoded PDU packet which supports SCA would look like the one below. 07916213111902F111000C916273335366000000AA0AE8329BFD4697D9EC37 A similar encoded PDU packet which does not support SCA and has TPDU data only is as below 0011000C916273335366000000AA0AE8329BFD4697D9EC37 If the two PDU packet types are compared it is noticed that only starting from the right side going to the left are they alike. This is true going all the way to the header byte of the second PDU. The metadata in the first PDU packet with both an SCA and a TPDU frame can be broken down into the following segments as in table 1. Table 1: PDU metadata segments Segment Data Field Name Meaning 1 07 Length of SMSC There are 7 Octets to follow 2 91 Type of SMSC SMSC is in international format 3 6213111902F1 SMSC Number The SMSC number is 26311191201 4 11 First Octet Defines other settings 5 00 Message ID (TP-MR) The ID auto generated for that SMS by modem 6 0C Sending Number Length The sending number is 12 digits long 7 91 Sending Number format 91 Means international format 8 627333536600 Sender Number Sender Number is +263733356600 9 00 Protocol Identifier TP- PID Indicates network protocol and nature of message 10 00 Data Encoding Scheme TP-DCS 00 means user data encoding scheme 11 AA Message validity TP- VP Will hold message for maximum amount of time possible 12 0A TP-UDL Size of user data in this case 10 characters 13 E8329BFD4697D 9EC37 TP-UD The message encoded “hellohello” American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2017) Volume 31, No 1, pp 145-155 148 3. The single function Mid string method The Mid function is defined by Microsoft Corporation as a function that returns a string that will be containing a required specified number of characters from an initial string [10]. The structure of the Mid function as defined in the Microsoft Developer Network (MSDN) is as follows Public Shared Function Mid(ByVal Str As String, ByVal Start As Integer, Optional ByVal Length As Integer) As String If for instance, the Mid function is called with the value of ‘Str’ being = ‘abcdefghij’, and the value of ‘Start’ being an integer = 3 and the value of ‘Length’ being an integer = 5. The function will return the character string ‘cdefg’. This is because it would have moved 3 places into the ‘Str’ string thus submitted. These 3 places from the start of the string will get us to the character “c” in the string “abcdefghij”. The function then takes the next 5 subsequent characters inclusive as defined by the ‘Length=5’ passed to the function. The function therefore returns a string which has the 5 characters ‘cdefg’. In different programming platforms this function may have different names or other alternatives but the syntax is always the same. For instances this Mid function is also equivalent to the substring function (denoted as “substr”) in some variants of the C programming languages. The substr function however, maintains the same number of arguments and syntax in these languages as those defined for the Mid function [10]. It also returns the same value results as the Mid function for similar argument value calls. We will therefore continue to use the Mid terminology as the common reference to such all functions in their respective languages. So, in order to simplify the process of encoding the full PDU packet, this, Mid function is the only function that we will use to encode the PDU packet. By using only this one function it will be easier to construct the metadata segments of the PDU packet each time that one is programming a code for sending SMS. This is unlike in the cases where several functions are used to create each individual segment of the PDU packet. Several individual functions are used since the data formats are different for each field and one has to use an appropriate function that handles that field format appropriately. However in this proposed case we propose that it is possible to articulate all the fields by just the one versatile function together with our proposed algorithm. 4. The flow chart of the algorithm Figure 2 shows the flow chart of the algorithm that is proposed. The flow chart will start by receiving a number of the intended recipient of the message. It will also concurrently receive the text of the message that needs to be send. Once it has received those two parameters, the flow control shows what validation decisions will be made on the data that will have been input in the algorithm. The flow control assumes that the recipient number that is entered is a valid mobile phone or ME number and it is in the international format. It also assumes that the input text characters are all from the 7 bit GSM character set. Since the characters are all assumed from the 7 bit GSM alphabet the algorithm does not articulate issues of validating them. To also make the PDU packet simpler it will be assumed that the text to be used as input is less than 160 characters long. This will avoid having to accommodate the splitting of the two PDU packets so that they are sent as two packets which are later joined at the Short Message Mobile Terminated Point-to-Point (SMMT) end. American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2017) Volume 31, No 1, pp 145-155 149 Figure 2: Flow chart for the singular function PDU packing algorithm sequence without an SCA Start Get Text Message Get Mobile Number Is Number Length Odd? Append Number with “F” Is Number in International Format? AND Is Text < 160 Characters? NO YES YES Do While x