Unstructured Supplementary Service Data (USSD) codes
If you enter a code that at least ends in a hash sign (and press ) and is not recognized by the phones MMI parser, the code will be sent to the network verbatim. It then depends on the network if this code is supported. One of the most used cases is a code for prepaid cards to check your balance. Many networks use something like *#100#. But it is really the choice of the network operator which code to use as long as it not already taken.
So entering *20*1234# or *21*1234# would do two completely different things: The first code would be sent as-is to the network for further processing (most likely returning an error), while the second code would be parsed by the phone and a structured request for activation of call forwarding would be sent to the network.
This is the category into which the much talked-about Samsung code falls.
Codes specific to your phone model that have been built in by the manufacturer to, for example, activate service menus or reset the device. These codes also contain * and # characters. Since the codes are not being sent to the network, you don’t have to press the key at the end – they are executed as soon as the last digit or character has been entered. There is one code that is mandatory for all manufacturers of GSM/UMTS/LTE phones to implement:*#06#
It shows the devices IMEI (Internatiol Mobile Equipment Identifier). An MMI Code is a sequence of digits that is entered into your phone to make it perform some special action.
These codes start and end with a * or # so they don't get confused with phone numbers you might want to dial. They're usually only valid when you're not on a call, so if you key one in while connected to your cellphone company's IVR system they won't be recognized. Some MMI Codes are dealt with by your phone - for example, there's usually one you can key in to find out what software version your phone has installed.
Most MMI Codes are sent to your Cellphone company as they are used to turn features on and off (Like call forwarding, call waiting, etc).
Supplementary Service (SS) codes
Those are the codes used to control, for example, call forwarding or number presentation.
With *21*123456789# you would instruct your phone to ask the network to forward all your incoming calls to the number 123456789. But this code is not sent directly to the network. Instead, it is parsed by the phone which then constructs an ASN.1 coded request to the network.
These codes are hardcoded into every GSM/UMTS/LTE device worldwide and cannot be changed by your network operator.
SIM control codes
These codes are used, for example, to change your SIMs PIN code.
**04*1234*6789*6789# would change your PIN code from "1234" to "6789".
These codes are also executed without pressing the key.