On 1/1/2020, Auron Software B.V. acquired ActiveXperts SMS Component and will continue developing, selling and supporting the product under it's own brand name Auron SMS Component. Maintenance contracts will be continued directly by Auron Software as of 1/1/2020.

USSD Basics

USSD stands for Unstrcutured Supplementary Services Data. It is a way of sending short commands from the mobile phone to the GSM network. It uses, like SMS, the signalling channel of the GSM connection. Unlike SMS, it does not use a store and forward architecture, but a session oriented connection. USSD text messages can be up to 182 bytes in length. Messages received on the mobile phone are not stored.

USSD is defined within the GSM standard in the documents:

USSD applications

USSD is most used to make it easy for the (prepaid) mobile user to query his prepaid balance using his mobile phone. It can also be used in mobile payments systems and information services such as weather forecasts and traffic information.

Automating USSD using a SMPP connection

The plain SMPP protocol does not support the delivery of USSD data. To send USSD data you have to use a TLV parameter. TLV parameters were added to version 3.4 of the SMPP protocol to extend the protocol with enhanced features. TLV stands for Tag-Length-Value. A TLV parameters consists out of three fields, the first field, the tag specifies which option is used. The second parameter (Length) specifies the lengt of the Value field in bytes, and the Value field holds the actual value.

To send USSD requests and receive USSD notifications over SMPP, you have to use the "ussd_service_op" TLV parameter.

The ussd_service_op parameter

The "ussd_service_op" parameter is defined as follows:

Field Size Octets Type Description
Parameter Tag 2 Integer 0x0501
Length 2 Integer Length of value part in octets
Value 1 Integer This value can be one of the following values:

0 = PSSD Indication
1 = PSSR Indication
2 = USSR Request
3 = USSN Request

4 to 15 = Reserved

16 = PSSD Response
17 = PSSR Response
18 = USSR Confirm
19 = USSN Confirm

20 to 31 = Reserved
32 to 255 = Vendor specific operations

To send an USSD request, you have to send a submit_sm packet with this TLV with value "2". When you receive a deliver_sm packet with this TLV in response, the value will be "18".

Sending an USSD request

The following code demonstrates how to send an USSD request using the SMS and MMS Toolkit:

Option Explicit

Dim objSmsProtocol
Dim objSmsMessage
Dim objSmsConstants

Dim strMessageReference

Set objSmsProtocol  = CreateObject ( "ActiveXperts.SmsProtocolSmpp" )
Set objSmsMessage   = CreateObject ( "ActiveXperts.SmsMessage" )
Set objSmsConstants = CreateObject ( "ActiveXperts.SmsConstants" )

Wscript.Echo "ActiveXperts SMS and MMS Toolkit " & objSmsProtocol & " demo."
Wscript.Echo "Expiration date: " & objSmsProtocol.ExpirationDate & vbCrLf

' Set server properties

objSmsProtocol.Server         = "localhost"            ' Set this to your own SMPP server address
objSmsProtocol.ServerPort     =  2775                  ' Set this to your own SMPP serve port
objSmsProtocol.SystemID       = "AX008"
objSmsProtocol.SystemPassword = "812056"
objSmsProtocol.SystemType     = "SMPP"
objSmsProtocol.ServerTimeout  =  5000
objSmsProtocol.SystemMode     =  objSmsConstants.asSMPPMODE_TRANSCEIVER

' Set Logfile

objSmsProtocol.LogFile = "c:\SmppLog_vbs_tlv.txt"

' Connect SMPP provider


If objSmsProtocol.IsConnected = True Then
   objSmsMessage.Recipient     = "+31638740160"
   objSmsMessage.Data          = "*#100#"            ' USSD Request
   objSmsMessage.ServiceType   = "USSD"
   objSmsProtocol.SetTLVValue objSmsConstants.asSMPP_TLV_1BYTE, &H501, 2
   WScript.Echo "Sending the message..."

   strMessageReference = objSmsProtocol.Send ( objSmsMessage )             ' Send the message
End If

' Show the result

If( objSmsProtocol.LastError <> 0 ) Then
   WScript.Echo "Failed to send message, error: " & objSmsProtocol.LastError & " (" &_
                & objSmsProtocol.GetErrorDescription( objSmsProtocol.LastError ) & ")"
   WScript.Echo "To view the trace file, open "   & objSmsProtocol.LogFile & "."
   WScript.Echo "Message successfully submitted" & vbCrLf & vbCrLf & "Message ID : " & strMessageReference
End If

objSmpp.Disconnect                                    ' Disconnect

WScript.Echo "Disconnected."

There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/mobile-messaging-component.