Presence of User Data Header is indicated by the TP-UDHI (Transfer Layer Protocol User Data Header Indicator) bit - 6th bit of the first octet of the GSM 03.40 or 3GPP 23.040 message.
If UDH is present, it is at the beginning of the TP-UD (TP-User Data) field and it always starts with an UDHL (UDH Length) octet. The rest of UDH is a sequence of Tag-Length-Value triplets. The Tag is named Information-Element-Identifier (IEI) and is always 1 octet long, the Length field is always 1 octet long and it specifies the length of the Information Element Data.
UDH uses space intended for the message payload. The longer the UDH, the less space remains for the message text or other contents. When TP-UD contains seven-bit data, the length of TP-UD is given in septets (but UDHL is still in octets, so length in septets is (UDHL + 1) * 8 / 7) and the UDH is filled to a septet boundary with 0-6 zero bits. The next table shows how a TP-UD of a message in the GSM 7 bit default alphabet containing text 'Hi' with a predefined sound 'Chord high' will be encoded:
The total message length TP-UDL will be 8. (UDH has 8 * (1 + 4) = 40 bits, 2 bits is the padding as (40 + 2) / 7 = 6 without remainder, 2 * 7 = 14 bits for text; total TP-UD length is 40 + 2 + 14 = 56 bits = 7 octets = 8 septets.)
The UDH is used in other protocols for short message transport - Short Message Peer-to-Peer (SMPP), Universal Computer Protocol (UCP) and in WEMT teleservice in CDMA2000.
"Alphabets and language-specific information". portal.3gpp.org. Retrieved 2021-07-19. https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=745 ↩
3rd Generation Partnership Project; Technical realization of the Short Message Service (SMS) http://www.3gpp.org/ftp/Specs/html-info/23040.htm ↩