GSM 03.40 or 3GPP TS 23.040 is a mobile telephony standard describing the format of the Transfer Protocol Data Units (TPDU) part of the Short Message Transfer Protocol (SM-TP) used in the GSM networks to carry Short Messages.3GPP TS 23.040 3rd Generation Partnership Project; Technical realization of the Short Message Service (SMS) This format is used throughout the whole transfer of the message in the GSM mobile network. In contrast, application servers use different protocols, like Short Message Peer-to-Peer or Universal Computer Protocol, to exchange messages between them and the Short Message service center (SMSC).

GSM 03.40 is the original name of the standard. Since 1999 has been developed by the 3GPP under the name 3GPP TS 23.040. However, the original name is often used to refer even to the 3GPP document.

Usage

The GSM 03.40 TPDUs are used to carry messages between the Mobile Station (MS) and Mobile Switching Centre (MSC) using the Short Message Relay Protocol (SM-RP),3GPP TS 24.011 3rd Generation Partnership Project; Point-to-Point Short Message Service (SMS) support on mobile radio interface while between MSC and Short Message Service Centre (SMSC) the TPDUs are carried as a parameter of a Mobile Application Part (MAP)3GPP TS 29.002 3rd Generation Partnership Project; Mobile Application Part (MAP) specification package.3rd Generation Partnership Project; Technical realization of the Short Message Service (SMS) (3G TS 23.040 version 11.5.0) (zipped .doc file), ETSI, March 2013.

In emerging networks which use IP Multimedia Subsystem (IMS) Short Messages are carried in the MESSAGE command of Session Initiation Protocol (SIP). Even in these IP-based networks an option exists which (due to compatibility reasons) defines transfer of Short Messages in the GSM 03.40 format embedded in 3GPP 24.011 as Content-Type: application/vnd.3gpp.sms.3GPP TS 24.341 3rd Generation Partnership Project; Support of SMS over IP networks3GPP TS 24.451 Support of SMS and MMS over NGN IMS subsystem; Stage 3 of 3GPP TS 24.341 Release 7

TPDU Types

GSM 03.40 defines six types of messages between Mobile Station (MS) and SMS Center (SC), which are distinguished by the message direction and the two least significant bits in the first octet of SM-TP message (the TP-MTI field):

+ TPDU Types TP-MTI direction message type 0 0 MS → SC SMS-DELIVER-REPORT 0 0 SC → MS SMS-DELIVER 0 1 MS → SC SMS-SUBMIT 0 1 SC → MS SMS-SUBMIT-REPORT 1 0 MS → SC SMS-COMMAND 1 0 SC → MS SMS-STATUS-REPORT 1 1 any Reserved

SMS-SUBMIT is used to submit a short message from a mobile phone (Mobile Station, MS) to a short message service centre (SMSC, SC).

SMS-SUBMIT-REPORT is an acknowledgement to the SMS-SUBMIT; a success means that the message was stored (buffered) in the SMSC, a failure means that the message was rejected by the SMSC.

SMS-COMMAND may be used to query for a message buffered in the SMSC, to modify its parameters or to delete it.

SMS-DELIVER is used to deliver a message from SMSC to a mobile phone. The acknowledgement returned by the mobile phone may optionally contain a SMS-DELIVER-REPORT. When home routing applies, SMS-DELIVER is used to submit messages from an SMSC to another one.

SMS-STATUS-REPORT may be sent by the SMSC to inform the originating mobile phone about the final outcome of the message delivery or to reply to a SMS-COMMAND.

TPDU Fields

The fields of SM-TP messages, including their order and size, are summarized in the following table, where M means a mandatory field, O an optional field, E is used for fields which are mandatory in negative responses (RP-ERR) and not present in positive responses (RP-ACK), x is a field present elsewhere:

+ SM-TL TPDU fields SMS-COMMAND size Field name SMS-STATUS-REPORT SMS-SUBMIT-REPORT SMS-SUBMIT SMS-DELIVER-REPORT SMS-DELIVER field TP-MTI M M M M M M 2 bits Message Type Indicator TP-MMS M M 1 bit More Messages to Send TP-RD M Reject Duplicates TP-LP O O 1 bit/ 2 bits Loop Prevention TP-VPF M Validity Period Format TP-SRI O 1 bit Status Report Indication TP-SRR O O Status Report Request TP-SRQ M Status Report Qualifier TP-UDHI O O O O O O 1 bit User Data Header Indicator TP-RP M M 1 bit Reply Path TP-FCS E E 1 octet Failure Cause TP-MR M M M 1 octet Message Reference TP-DA M x 2–12 octets Destination Address TP-OA M 2–12 octets Originating Address TP-RA M 2–12 octets Recipient Address TP-SCTS x x M 7 octets Service Centre Time Stamp TP-DT M 7 octets Discharge Time TP-ST M 1 octet Status TP-PI M M O 1 octet Parameter Indicator TP-SCTS x M x 7 octets Service Centre Time Stamp TP-PID M O M O O M 1 octet Protocol Identifier TP-DCS M O M O O 1 octet Data Coding Scheme TP-SCTS M x x 7 octets Service Centre Time Stamp TP-VP O 0, 1 or 7 octets Validity Period TP-UDL M O M O O 1 octet User Data Length TP-UD O O O O O given by TP-UDL User Data TP-CT M 1 octet Command Type TP-MN M 1 octet Message Number TP-DA x M 2-12 octets Destination Address TP-CDL M 1 octet Command Data Length TP-CD O given by TP-CDL Command Data

The first octet of the TPDU contains various flags including the TP-MTI field described above:

+ Bit fields in the first octet of SM-TL TPDU bit(s) Meaning 1-0 TP-Message-Type-Indicator (TP-MTI) 2 TP-More-Messages-to-Send (TP-MMS) in SMS-DELIVER (0 = more messages) 2 TP-Reject-Duplicates (TP-RD) in SMS-SUBMIT 3 TP-Loop-Prevention (TP-LP) in SMS-DELIVER and SMS-STATUS-REPORT 4-3 TP-Validity-Period-Format (TP-VPF) in SMS-SUBMIT (00 = not present) 5 TP-Status-Report-Indication (TP-SRI) in SMS-DELIVER 5 TP-Status-Report-Request (TP-SRR) in SMS-SUBMIT and SMS-COMMAND 5 TP-Status-Report-Qualifier (TP-SRQ) in SMS-STATUS-REPORT 6 TP-User-Data-Header-Indicator (TP-UDHI) 7 TP-Reply-Path (TP-RP) in SMS-DELIVER and SMS-SUBMIT

By setting the TP-More-Messages-to-Send (TP-MMS) bit to 0 (reversed logic), the SMSC signals it has more messages for the recipient (often further segments of a concatenated message). The MSC usually does not close the connection to the mobile phone and does not end the MAP dialogue with the SMSC, which allows faster delivery of subsequent messages or message segments. If by coincidence the further messages vanish from the SMSC in the meantime (when they are for example deleted), the SMSC terminates the MAP dialogue with a MAP Abort message.

The TP-Loop-Prevention (TP-LP) bit is designed to prevent looping of SMS-DELIVER or SMS-STATUS-REPORT messages routed to a different address than is their destination address or generated by an application. Such message may be sent only if the original message had this flag cleared and the new message must be sent with the flag set.

By setting the TP-Status-Report-Indication (TP-SRI) bit to 1, the SMSC requests a status report to be returned to the SME.

By setting the TP-Status-Report-Request (TP-SRR) bit to 1 in a SMS-SUBMIT or SMS-COMMAND, the mobile phone requests a status report to be returned by the SMSC.

When the TP-SRQ has value of 1 in an SMS-STATUS-REPORT message, the message is the result of an SMS-COMMAND; otherwise it is a result of an SMS-SUBMIT.

When TP-UDHI has value 1, the TP-UD field starts with User Data Header.

Setting the TP-RP bits turns on a feature which allows to send a reply for a message using the same path as the original message. If the originator and the recipient home networks differ, the reply would go through another SMSC then usually. The mobile operator must take special measures to charge such messages.

Both SM-RP and MAP used to transmit GSM 03.40 TPDU carry enough information to return acknowledgement—the information whether a request was successful or not. However, a GSM 03.40 TPDU may be included in the acknowledgement to carry even more information. The GSM 03.40 has undergone the following development:

Up to GSM 03.40 5.2.0 SMS-DELIVER-REPORT and SMS-SUBMIT-REPORT was sent only in the case of an error. Since 5.3.0 they are sent in case of success as well. MO-ForwardSM-Res was introduced back in GSM 09.02 5.6.0 August 1997 Up to GSM 03.40 6.0.0 SMS-DELIVER-REPORT and SMS-SUBMIT-REPORT sent in case of an error contained only TP-MTI and TP-FCS fields and the last field in SMS-STATUS-REPORT was TP-ST. Since version 6.1.0 these TPDUs has format shown in the table above.

Although these changes are ancient (version 6.1.0 occurred in July 1998), old formats of MAP are frequently seen even in today's networks.

Message Content

The content of the message (its text when the message is not a binary one) is carried in the TP-UD field. Its size may be up to 160 × 7 = 140 × 8 = 1120 bits. Longer messages can be split into multiple parts and sent as a Concatenated SMS. The length of message content is given in the TP-UDL field. When the message encoding is GSM 7-bit default alphabet (depends on TP-DCS field), the TP-UDL gives length of TP-UD in 7-bit units; otherwise TP-UDL gives length of the TP-UD in octets.

If the TP-UDHI is 1, the TP-UD starts with User Data Header (UDH); in this case, the first octet of the TP-UD is User Data Header Length (UDHL) octet, which contains the length of the UDH in octets, excluding the UDHL itself. UDH eats room from the TP-UD field. If the message encoding is GSM 7-bit default alphabet and a UDH is present, padding bits are inserted after the UDH so that the start of the first text character following the UDH is aligned with a septet boundary. This behaviour was designed for older mobile phones that do not understand UDH; such mobile phones might display the UDH as a jumble of strange characters; if the first character after UDH were Carriage Return (CR), the mobile phone would overwrite the garbled output caused by the binary data with the text that follows the UDH.

Addresses

A GSM 03.40 message contains at most one address: destination address (TP-DA) in SMS-SUBMIT and SMS-COMMAND, originator address (TP-OA) in SMS-DELIVER and recipient address (TP-RA) in SMS-STATUS-REPORT. Other addresses are carried by lower layers.

The format of addresses in the GSM 03.40 is described in the following table:

octet Meaning 0 address length in nibbles (semi-octets) 1 EXT, TON, NPI 2-11 address digits

Type of number (TON):

Bit6 5 4 Meaning 0 0 0 Unknown 0 0 1 International number 0 1 0 National number 0 1 1 Network specific number 1 0 0 Subscriber number 1 0 1 Alphanumeric, (coded according to 3GPP TS 23.038 GSM 7-bit default alphabet) 1 1 0 Abbreviated number 1 1 1 Reserved for extension

If a subscriber enters a telephone number with `+' sign at its start, the `+' sign will be removed and the address gets TON=1 (international number), NPI=1. The number itself must always start with a country code and must be formatted exactly according to the E.164 standard.

In contrast, for numbers written without `+' sign the address gets TON=0 (unknown), NPI=1. In this case the number must adhere to the mobile operator's dial plan, which means that international numbers must have the international prefix (00 in most countries, but 011 in the USA) before the country code and numbers for long-distance calls must start with the trunk prefix (0 in most countries, 1 in the USA) followed by a trunk code.

Numbering plan identification (NPI):

Bits3 2 1 0 Meaning 0 0 0 0 Unknown 0 0 0 1 ISDN/telephone numbering plan (E.164/E.163) 0 0 1 1 Data numbering plan (X.121) 0 1 0 0 Telex numbering plan 0 1 0 1 Service Centre Specific plan 1) 0 1 1 0 Service Centre Specific plan 2) 1 0 0 0 National numbering plan 1 0 0 1 Private numbering plan 1 0 1 0 ERMES numbering plan (ETSI DE/PS 3 01 3) 1 1 1 1 Reserved for extension

Telephone numbers should have NPI=1. Application servers may use alphanumeric addresses which have TON=5, NPI=0 combination.

The EXT bit is always 1 meaning "no extension".

Address examples

U.S. number +1 555 123 4567 would be encoded as 0B 91 51 55 21 43 65 F7 (the F in upper four bits of the last octet is a filler which is used when the number length is odd).