What is USSD – MMI Code – USSD Code?
USSD is the primary service a GSM network operator provides for sending and receiving data (or strings) on a mobile device to/from the core network of a mobile operator
USSD full form is Unstructured Supplementary Service Data. A mobile operator offers an essential service, along with voice and SMS. It does not require an internet connection from the device. Enables USSD to run on elementary phones. Very useful to reach people living in rural areas and can not afford smartphones.
As per gsm network specifications, a USSD message can be a maximum of 160 bytes long.
The number of user-entered characters depends on the encoding scheme. E.g., With GSM 7 (English alphabets )bit encoding, the USSD string can be a maximum of 182 bytes long. While for UCS-2 (Arabic), where a single character is two bytes long, this results in the USSD string being a maximum of 80 characters long.
USSD enables a mobile operator to provide, call back service while in roaming, location-based services, balance services, content marketing based on location, etc.
Protocol standards are defined in GSM MAP 09:02 and GSM 03.90. A USSD message uses a gsm map protocol over SS7.
To access a service over USSD, a mobile subscriber dials a known string (e.g., *123#) for a service, the home network of the cellular operator responds with the required menu or content. A USSD session established between the handset and a USSD application for an interactive interaction.
What are USSD Code and IVR?
A mobile operator may provide an IVR option too. A mobile subscriber needs to dial a number to access the IVR. Sometimes it is long, and sometimes it is short. E.g., Airtel India provides a 121 number to its subscribers for IVR/customer care. The dialing a number initiates a call towards the IVR and sets up a voice session.
A user dials a fixed string to initiate a USSD session, which is called the USSD Code. E.g., for customer services, Airtel India has *121# USSD Code. The roaming network routes the USSD code towards the USSD server in-home network.
The dialed string should not be from any MMI code used by the device hardware.
We are providing details of the MMI code in the coming paragraphs. A USSD code decides what service a mobile user needs.
Home network USSD application decides the menus based on USSD code.
There are two modes. MMI mode and Application Mode. In MMI mode, the mobile user dials string to start a menu-based session with the home network. In Application mode, an application transfer binary data from the handset to the HPLMN.
What is MMI Code or Man-Machine Interface Code:
An MMI code is a value that works as a command to the device. For example, the GSM network provides many supplementary services to a mobile subscriber. Users can activate/register/deactivate services from a mobile device. Supplementary services examples are, call forwarding no conditional, call forwarding when busy, etc. These days mobile phones are very advance (smartphones) for supplementary service management. You can activate/deactivate/register services from a graphical user interface. But before smartphones, only MMI Code was the option. The full details for MMI Codes are specified in GSM Spec. This spec has a standard MMI interface for GSM services. Phone manufacturers can define their own MMI codes too. This provides flexibility to the manufactures for providing new features and can compete in the market.
But these services should be supported on all GSM phones. To achieve this, every phone comes with MMI or man-machine interface to interact with the phone. MMI’s full form is Man-Machine Interface, so an MME code is the command to the phone. A code can display device information (e.g., *#06#, displays IMEI number), can generate a protocol message on a network, or can send dialed string in a USSD message.
E.g., *21*787687878# <SEND> will activate the call forwarding. Here 21 is the supplementary service code. A list of other codes can get at the SS Code List.
The mobile device parses the MMI code and generates a MAP 09:02 protocol message for activating/deactivating /register a service. HLR holds the status of each supplementary service for a subscriber or IMSI.
If a user dials a code that is not in the list of MMI codes provided by the device manufacturer, the dialed string is transferred in the USSD message from the device to the home network.
The network has roaming MSC/VLR connected via SS7/Sigtran links to the home network. A device connects to the MSC/VLR via BTS/BSC.
HLR or Home Location Register:
HLR is a subscriber database in-home network. After a successful location update, VLR stores the GT (SCCPaddress) of HLR. When a user dials a USSD string, VLR sends a GSM MAP operation to the HLR in HPLMN. The destination GT is the HLR number received in Location Update.
MSC or Mobile Switching Center:
An MSC or mobile switching center is a GSM node in a visiting network. One side connects to the wireless network via BSC or RNC. Another side connects to the PSTN or SS7 network. Mostly it is co-located with the VLR.
VLR or Visitor Location Register:
A VLR is a database that stores the subscriber profile temporarily. The profile is downloaded from HLR upon a location update gsm map protocol procedure. The roaming network provides services based on the profile downloaded.
USSD Gateway :
This is a dedicated node that converts menu-based business logic to the signaling on wire and vise Versa. For mobile-initiated USSD, HLR sends the signaling to the USSDGW, while in network-initiated, the string may be directly passed to the roaming network using SS7 connection.
Gateway opens new opportunities for providing USSD based platform for advertisement the same text as SMS gateway does for SMS.
The gateway connects with mobile operators over ss7/sigtran (GT and Point code). Provider of USSDGW purchases USSD codes and all mobile operators set the outing of shortcodes towards the gateway.
An application is the actual business logic for service. E.g., A prepaid balance application. One side connects to the HLR or USSDGW, and the other side connects to the subscriber profile for billing. When a balance request (e.g., *2345#) arrives at the HLR, a USSD application is invoked with a mobile number of IMSI. Applications return a menu, which is sent to the phone via HLR or USSDGW.
There are situations when a VAS provider wants to develop a USSD application and wants to reach the mobile subscribers within an area. The following is required to develop a USSD application.
USSD Application over ss7/sigtran:
With this option, the USSD gateway of mobile operators does not get overloaded. But at the same time, it is difficult to get this kind (ss7/Sigtran) of connection.
- VAS provider gets a USSD code. It is not required if the service logic only involves network-initiated USSD.
- We need to connect the mobile operators for the SS7/Sigtran. There can be multiple mobile operators.
- VAS provides a Global title and a Point Code. This is the address of the VAS node in the mobile network.
- SS7 stack required to receive and send ss7 messages from/to the roaming network.
- Develop the actual application on top of the stack.
USSD Application via USSD gateway:
With this option, the APIs provided by the mobile operator will be used. Most of the time, these are HTTP APIs.
USSD parameters :
Data Coding Scheme,
This parameter identifies, string characters encoding in bytes. The receiving side drives a user-readable string from bytes value and data coding scheme. A character may be encoded in different bits or byte sizes. E.g., GSM 7 encoding encodes a character in 7 bits, and a UCS2 encoding encodes a character in 2 bytes or 16 bits.
This is the sequence of characters shown on the mobile device, or a device sends to the home network. The size of the string depends on the encoding scheme.
This parameter sets the alert type, which mobile gives to its user upon receiving the USSD string. E.g., Beep Once.
An IMSI identifies a subscriber globally, a unique identity of a sim card.
Service uses standard GSM MAP 09:02 protocol. GSM MAP, which uses the services of SS7/Sigtran protocol. In this example, the protocol stack is SIGTRAN, in the case of the SS7 (E1/T1), the M3UA layer will be replaced by MTP3, SCTP with MTP2, and IP with MTP1. In SIGTRAN, no special hardware required for IP links, SIGTRANlinks the ethernet card work.
IP or Internet Protocol Layer, IP layers routes the user (here its SCTP) messages over the IP network. Both peers assigned an IP address.
SCTP or Stream Control Transmission Protocol Layer, it s a transport layer, set up a connection with the peer node. SCTP provides error-free messages in both directions.
M3UA or MTP3 User Adaptation Layer in SIGTRAN carries SS7 signaling over IP for the upper SS7 layers. An ss7 point code identifies an m3ua layer.
Other layers belong to the SS7 protocol standard. Please check at SS7 Layers.
USSD Protocol Messages:
Every layer uses protocol messages for a USSD session. The below table mentions the protocol messages used by layers.
USSD Message Flow:
Mobile Initiated :
When a mobile subscriber dials a string (*123#), a USSD call starts. The first message of the call is from VLR to the HLR. E.g
Mobile user dials *123# for prepaid balance.
User Receives a menu
1, for main balance 2, for data balanced mobile subscriber press 2
The on-screen mobile subscriber gets the USSD menu:
Your data balance is 200MBm valid for the next ten days. Thank you
Network Initiated Call Flow:
When a mobile operator or a gateway wants to display a menu to the mobile user, a network-initiated session starts. USSDGW can send the menu directly to the roaming MSC/VLR, or it can be via HLR. Direct sending, offloads the HLR. To send the menu directly, the USSDGW should know the IMSI and visiting MSC/VLR. HLR lookup is one of the options to get IMSI and roaming MSC.
Example Call Flow :
Mobile Subscriber Receives Menu
Select 1. To activate free Roaming, 2. For No Free Roaming. Mobile Subscriber Selects 1
Mobile Subscriber Receives String
Difference between USSD and SMS:
USSD and SMS both enable a mobile user to send a text to the home network and to receive a text from the home network. But there are many differences which make these two to fit in different places.
USSD is session-based while SMS is not, upon dialing string on a device, a session is set up with the home network. If a response does not come in time, the session is terminated. In SMS, there is no session maintained.
No long text in USSD, A SMS can be more than 160 bytes, this is achieved by doing segmentation on SMSC and reassembly at the mobile device. No segmentation on USDGW and reassembly on mobile devices.
USSD enables two-way communication. While doing an advertisement, the advertiser might get an immediate response from a mobile user if it uses the USSD session. In SMS, the mobile user may not send a reply immediately or forget after some time.