SMPP Protocol Tutorial- SMPP Client – SMPP server.

SMPP or Short Message Peer to Peer protocol is an open standard protocol that uses TCP/IP protocol for the transport of protocol messages. Earlier to 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 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 TLV based encoding for parameters and messages, 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 was exposing HTTP or another form of APIs to the bulk SMS providers. API format was depending on the SMSC vendor of an MNO.

This was making 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, which is 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 bind transceiver SMPP message to the peer.
3. ESME Send Submit SM, message to send a text to 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 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 or receiving or both messages from a peer node.

Submit Sm/Submit Sm Response:

When a text needs to send to SMSC, for sending 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 in 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 that 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 an Enquire Link Response is not received by the sending entity for a sent enquire link, Then the SMPP connection is marked as inactive. The SMPP layer disconnects the TCP connection. If the application is a TCP client then it tries to connect again with the peer.

SMPP Connection Parameters:

After two peers have been decided that they will 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.