SMPP Protocol Tutorial- SMPP Client – SMPP server.


Short Message Peer to Peer (SMPP) protocol is an open standard protocol that uses TCP/IP protocol to transport protocol messages. Before SMPP, ss7 was the standard protocol for messaging over the GSM network. USSD and SMS both can use SMPP. A messaging application can be developed using SMPP.

The app can be a bulk SMS gateway, which connects to many mobile operators over SMPP on one side, and on another side, can expose HTTP-based bulk SMS APIs. 

For example, a voting app connects to a mobile operator’s SMSCs and can receive all messages for a shortcode.

Benefits of SMPP:

  1. SMPP is an open standard. Two peers can develop applications independently.

2. It is easy to get an SMPP connection than the legacy ss7 protocol.

3. Uses tag Length Value(TLV-based) encoding for parameters and messages, with no need for an ASN.1 compiler to decode/encode. So reduces the cost of messaging or USSD application development.

4. Two mobile operators can exchange SMS if they don’t have an SS7-level roaming agreement. For example, if MNO1 wants to send an SMS to the subscriber of MNO2. MNO1 sends the text to SMSC of MNO2 over SMPP.

5. Easy to develop an SMS gateway for bulk SMS providers. Earlier to SMPP, each mobile operator exposed HTTP or another form of API to the bulk SMS providers. API format depended on the SMSC vendor of an MNO.

This made it difficult for bulk SMS providers to connect with many mobile operators. With SMPP, no change/development is required for connecting a new mobile operator.

6. Uses TCP/IP protocol stack, available on each operating system now, and is a reliable connection-oriented protocol.

SMPP Startup sequence : 

This example shows the message sequence used by an ESME to connect to an SMSC for sending and receiving text messages.

1. ESME connects to SMPP over TCP/IP. This involves a TCP connection setup with a peer by the three-way handshake.
2. ESME binds with SMSC by sending a bind transceiver SMPP message to the peer.
3. ESME Send Submit SM message to text a mobile device.
4. SMSC sends a deliver-sm to the ESME for sending a text received from a mobile device.
 

Protocol Messages:

BIND Receiver /Bind Received Response : 

SMPP entity (e.g., ESME) binds itself with a peer entity for receiving messages only. E.g., a short code entity that is used for voting.

BIND Transmitter/Bind Transmitter Response : 

SMPP entity (e.g., ESME) binds itself with a peer entity for receiving messages only. E.g., a short code entity that is used for voting.

Bind Transmitter/ Bind Transmitter Response :

An entity uses this message if it will send messages only.

Bind Transceiver/Bind Transceiver Response:

For both send and receive.

Unbind/Unbind Response: 

An entity uses this message to remove itself from sending, receiving, or both messages from a peer node.

Submit Sm/Submit Sm Response:

When a text needs to send to SMSC to send an SMS to the destination mobile, the text is sent in submit sm message. If the receiving side accepts the message, then a Submit sm response will have success else. An error code is returned to the sending entity.

Deliver Sm/Deliver Sm Response:

When a text needs to send from SMSC to an ESME, the text is sent inside the deliver sm message. If the receiving side accepts the message, then a Submit sm response will have success else. An error code is returned to the SMSC. E.g., when a text is sent to a shortcode from a mobile device. On the GSM network, it reaches SMSC as MO-SMS. Then, SMSC will send a text to the shortcode handling application.

Query Sm/Query Sm Response:

An ESME sends this message to SMSC for an already submitted SMS. The short message state (unknown, en route, etc.) is returned to the ESME by the SMSC in Query SM Response.

Cancel Sm /Cancel Sm Response:

ESME sends this message to cancel an already submitted message. This might be because the message is no longer valid, and ESME doesn’t want to send this SMS anymore.

Enquire Link/ Enquire Link Response:

This is an optional message. Runs periodically in both directions from peer to peer. If the sending entity does not receive an Enquire Link Response for a sent enquire link, Then the SMPP connection is marked inactive. The SMPP layer disconnects the TCP connection. If the application is a TCP client, it tries to connect again with the peer.

SMPP Connection Parameters:

After two peers decide to talk to each other over SMPP, both should set up a connection before sending or receiving a text. For example, a bulk SMS provider wants to connect to a mobile operator’s SMSC. SMSC will work in server mode, and bulk SMS providers will act as ESME. The mobile operator will create an SMPP account for the SMS provider and share the server details. 

SMPP account details are given to bulk SMS providers.

  1. Host: This is the IP  or URL of SMSC.
  2. SMPP Port, a TCP port, can be the default SMPP port 2775 or other.
  3. System_Id, a string value.
  4. Password, a string value.
  5. System Type, string, and an optional value.

Message Format:

Each SMPP message has a fixed header and a variable message section. The message section depends on the message type.

SMPP Header: 

The header has the following parameters:

  1. Command Length is the total length of the message, including the header.
  2. Command Id, every message type in SMPP has an integer value called the command id.
  3. Command Status, this field has significance in a response message of a command id.
  4. A sequence number is a unique value assigned by the originator of each SMPP PDU.