Cómo introducir datos en el campo SM de SMPP
En SMPP (Short Message Peer-to-Peer), la carga útil del Short Message (SM) es el texto real (o datos binarios) del mensaje SMS que se transmite. Para garantizar la interpretación correcta de este contenido, el campo data_coding en el PDU juega un papel crítico al indicar el formato de codificación del mensaje.
Codificaciones comunes en SMPP
El campo data_coding
es de 1 byte e informa al SMSC cómo interpretar la carga útil del mensaje.
Hex | Decimal | Codificación | Descripción |
---|---|---|---|
0x00 | 0 | GSM 7-bit por defecto | Juego de caracteres estándar para SMS |
0x01 | 1 | ASCII | ASCII de 8 bits (subconjunto Latin-1) |
0x03 | 3 | Latin-1 (ISO 8859-1) | Juego de caracteres de Europa occidental |
0x08 | 8 | UCS2 | Unicode (16-bit, big-endian) |
0x04 | 4 | Binario | Datos binarios crudos de 8 bits |
Ejemplos de mensajes codificados
1. GSM 7-bit (data_coding = 0x00)
Codificación estándar para SMS. Eficiente (hasta 160 caracteres en un solo mensaje).
Texto: "Hello" GSM 7-bit Packed: C8 32 9B FD 06
2. UCS2 (data_coding = 0x08)
Usado para scripts no latinos (ej. árabe, chino, emojis). Soporta 70 caracteres por mensaje.
Texto: "مرحبا" UCS2 Hex: 0645 0631 062D 0628 0627 Bytes (hex): 06 45 06 31 06 2D 06 28 06 27
3. ASCII (data_coding = 0x01)
Solo caracteres latinos básicos, menos eficiente en espacio que GSM 7-bit.
Texto: "Hello" ASCII Hex: 48 65 6C 6C 6F
Ejemplo de PDU SMPP con codificación UCS2
Aquí hay un PDU submit_sm
de SMPP que lleva un mensaje Unicode:
0000004B // Longitud del comando (75 bytes) 00000004 // ID del comando (submit_sm) 00000000 // Estado del comando 00000001 // Número de secuencia 74657374 // service_type: "test" 01 // source_addr_ton: Internacional 01 // source_addr_npi: ISDN 31323334 // source_addr: "1234" (ASCII) 00 01 // dest_addr_ton 01 // dest_addr_npi 35363738 // destination_addr: "5678" 00 00 // esm_class 00 // protocol_id 00 // priority_flag 00 // schedule_delivery_time 00 // validity_period 00 // registered_delivery 00 // replace_if_present_flag 08 // data_coding: UCS2 00 // sm_default_msg_id 0A // sm_length: 10 bytes 06450631 // Mensaje en UCS2 (ej. "مر") 062D0628
Codificación y concatenación
Los mensajes largos se dividen en partes usando UDH (User Data Header). Esto reduce el tamaño máximo de la carga útil:
- GSM 7-bit: 160 → 153 caracteres por parte
- UCS2: 70 → 67 caracteres por parte
Ejemplo de UDH para una parte del mensaje:
05 00 03 CC 02 01 // 05: longitud del encabezado // 00 03: IEI de concatenación // CC: Referencia del mensaje // 02: partes totales // 01: parte actual
Resumen
SMPP ofrece opciones flexibles de codificación a través del campo data_coding
. Una codificación adecuada garantiza la compatibilidad entre redes globales, especialmente al manejar texto multilingüe o datos binarios. Los desarrolladores deben hacer coincidir los tipos de codificación con el contenido y los destinatarios esperados para evitar la corrupción del mensaje.
Referencias
- Especificación SMPP 3.4
- Juego de caracteres GSM 03.38
- Estándar Unicode
More information
- How to configure the SMPP Service Type field
- How to configure the SMPP Phone Number fields
- How to configure the SMPP ESM Class field
- How to configure the SMPP PID field
- How to configure the SMPP Prioirity field
- How to configure the SMPP Scheduled Time field
- How to configure the SMPP Validity Period field
- How to configure the SMPP Registered Delivery field
- How to configure the SMPP Replace if Present field
- How to configure the sm_default_msg_id field
- How to configure the SMPP DCS field
- How to calculate the SMPP SM Length field
- How to put data into the SMPP SM field