Intro to SMPP
Short Message Peer-to-Peer (SMPP) is one of the most commonly used protocols for exchanging text messages outside the SS7 network. While it is common to have other SMS endpoints and delivery mechanisms, ITSPs and the like often request SMPP support, which can be implemented with Kannel, openBTS, or other applications as interfaces.
mod_smpp in FreeSWITCH
The FreeSWITCH module for SMPP, mod_smpp, exposes a basic subset of SMPP functionality. It is currently available in source, and will soon be available via packages. I wrote the module using an account with nexmo https://www.nexmo.com/product/messaging/ for interop testing. Nexmo documentation is available here: https://docs.nexmo.com/index.php/smpp-acccess
Configuring mod_smpp
On a Debian Jessie server, download and install the SMPP library:
cd /usr/src/
git clone git://git.osmocom.org/libsmpp34
cd libsmpp34
autoreconf -i
./configure && make && make install
ldconfig
From your FreeSWITCH source directory, pull the latest master, then rebuild with mod_smpp:
./bootstrap.sh
# update modules.conf
event_handlers/mod_smpp
./configure && make && make install
In your FreeSWITCH install config directory, update autoload_configs/modules.conf:
<load module="mod_sms"/>
<load module="mod_smpp"/>
Set up a gateway in autoload_configs/smpp.conf.xml
<configuration name="smpp.conf" description="SMPP client and server Gateway">
<gateways>
<gateway name="nexmo">
<params>
<param name="host" value="smpp0.nexmo.com"/>
<param name="port" value="8000"/>
<param name="debug" value="1"/>
<param name="system_id" value="[username]"/>
<param name="password" value="[password]"/>
<param name="system_type" value="nexmo"/>
</params>
</gateway>
</gateways>
</configuration>
Restart FreeSWITCH.
Managing mod_smpp
Debugging is enabled by default, and if the gateway connection is successful, the FreeSWITCH console will periodically display PDU indications:
2015-07-03 15:58:18.649771 [INFO] mod_smpp_utils.c:41 PDU
command_length [00000010] - [16]
command_id [00000015] - [ENQUIRE_LINK]
command_status [00000000] - [ESME_ROK]
sequence_number [000042FB] - [17147]
2015-07-03 15:58:18.649771 [INFO] mod_smpp_utils.c:41 PDU
command_length [00000010] - [16]
command_id [80000015] - [ENQUIRE_LINK_RESP]
command_status [00000000] - [ESME_ROK]
sequence_number [00000049] - [73]
To disable debugging, toggle the debug param in autoload_configs/smpp.conf.xml from 1 to 0.
<param name="debug" value="0"/>
Then in fs_cli:
reloadxml
status
reload mod_smpp
Sending and Receiving Messages
Update the chatplan for inbound and outbound SMS, where 12065551234 represents your nexmo account DID and 1001 represents an extension registered to a Yealink deskphone.
<context name="default">
<extension name="smpp34_demo_in">
<condition field="to_user" expression="^12065551234$"/>
<condition field="from_user" expression="^(\d{11})$">
<action application="set" data="to=1001@[local_fs_ip]"/>
<action application="set" data="from=$1@[local_fs_ip]"/>
<action application="set" data="proto="/>
<action application="set" data="dest_proto=sip"/>
<action application="set" data="final_delivery=1"/>
<action application="info"/>
<action application="send"/>
</condition>
</extension>
</context>
<context name="public">
<extension name="smpp34_demo_out">
<condition field="from_user" expression="1001"/>
<condition field="to_user" expression="^(\d{11})$">
<action application="set" data="from_user=12065551234"/>
<action application="set" data="final_delivery=1"/>
<action application="info"/>
<action application="smpp_send" data="nexmo"/>
</condition>
</extension>
</context>
Reload xml from fs_cli
reloadxml
Send a message from a cell phone (represented by 13605556789) to a registered phone by simply composing a text to your 11 digit DID (represented by 12065551234) and send as usual. This will be received by 1001 according to the chatplan.
freeswitch@Quentus68594> 2015-07-03 15:41:41.649814 [INFO] mod_smpp_utils.c:41 PDU
command_length [0000003E] - [62]
command_id [00000005] - [DELIVER_SM]
command_status [00000000] - [ESME_ROK]
sequence_number [000042C9] - [17097]
service_type []
source_addr_ton [01] - [TON_International]
source_addr_npi [01] - [NPI_ISDN_E163_E164]
source_addr [13605556789]
dest_addr_ton [01] - [TON_International]
dest_addr_npi [01] - [NPI_ISDN_E163_E164]
destination_addr [12065551234]
esm_class [01] - [1]
protocol_id [00] - [0]
priority_flag [00] - [0]
schedule_delivery_time []
validity_period []
registered_delivery [00] - [0]
replace_if_present_flag [00] - [0]
data_coding [00] - [0]
sm_default_msg_id [00] - [0]
sm_length [07] - [7]
short_message [from cell to yealink]
2015-07-03 15:41:41.649814 [INFO] mod_smpp_gateway.c:294 Received message[5]:
Event-Name: [MESSAGE]
Core-UUID: [d28d64a0-21d3-11e5-be4a-b5497df8f7c0]
FreeSWITCH-Hostname: [Quentus68594]
FreeSWITCH-Switchname: [Quentus68594]
FreeSWITCH-IPv4: [172.18.101.161]
FreeSWITCH-IPv6: [2601:603:c01:97f0:64d4:31ff:fed7:6b51]
Event-Date-Local: [2015-07-03 15:41:41]
Event-Date-GMT: [Fri, 03 Jul 2015 22:41:41 GMT]
Event-Date-Timestamp: [1435963301649814]
Event-Calling-File: [mod_smpp_message.c]
Event-Calling-Function: [mod_smpp_message_decode]
Event-Calling-Line-Number: [126]
Event-Sequence: [752]
endpoint: [mod_smpp]
sequence_number: [17097]
command_status: [0]
command_id: [5]
smpp_gateway: [nexmo]
proto: [smpp]
source_addr_ton: [1]
source_addr_npi: [1]
from_user: [13605556789]
dest_addr_ton: [1]
dest_addr_npi: [1]
to_user: [12065551234]
data_coding: [0]
profile: [default]
Content-Length: 7
from cell to yealink
2015-07-03 15:41:41.649814 [INFO] mod_smpp_utils.c:41 PDU
command_length [00000011] - [17]
command_id [80000005] - [DELIVER_SM_RESP]
command_status [00000000] - [ESME_ROK]
sequence_number [000042C9] - [17097]
message_id []
2015-07-03 15:41:41.649814 [INFO] mod_sms.c:336 Processing text message 13605556789->12065551234 in context default
2015-07-03 15:41:41.649814 [INFO] mod_sms.c:463 CHANNEL_DATA:
Event-Name: [MESSAGE]
Core-UUID: [d28d64a0-21d3-11e5-be4a-b5497df8f7c0]
FreeSWITCH-Hostname: [Quentus68594]
FreeSWITCH-Switchname: [Quentus68594]
FreeSWITCH-IPv4: [172.18.101.161]
FreeSWITCH-IPv6: [2601:603:c01:97f0:64d4:31ff:fed7:6b51]
Event-Date-Local: [2015-07-03 15:41:41]
Event-Date-GMT: [Fri, 03 Jul 2015 22:41:41 GMT]
Event-Date-Timestamp: [1435963301649814]
Event-Calling-File: [mod_smpp_message.c]
Event-Calling-Function: [mod_smpp_message_decode]
Event-Calling-Line-Number: [126]
Event-Sequence: [752]
endpoint: [mod_smpp]
sequence_number: [17097]
command_status: [0]
command_id: [5]
smpp_gateway: [nexmo]
source_addr_ton: [1]
source_addr_npi: [1]
from_user: [13605556789]
dest_addr_ton: [1]
dest_addr_npi: [1]
to_user: [12065551234]
data_coding: [0]
profile: [default]
max_forwards: [70]
DP_MATCH: [13605556789]
to: [1001@172.18.101.161]
from: [13605556789@172.18.101.161]
dest_proto: [sip]
Content-Length: 7
from cell to yealink
Send a message from the Yealink 1001 extension to the cell phone by going to Menu->Message->Text Message->New Message. Enter message, then set To: [mobile_number]
2015-07-03 15:42:04.009785 [INFO] mod_sms.c:336 Processing text message 1001->13605556789 in context public
2015-07-03 15:42:04.009785 [INFO] mod_sms.c:463 CHANNEL_DATA:
Event-Name: [MESSAGE]
Core-UUID: [d28d64a0-21d3-11e5-be4a-b5497df8f7c0]
FreeSWITCH-Hostname: [Quentus68594]
FreeSWITCH-Switchname: [Quentus68594]
FreeSWITCH-IPv4: [172.18.101.161]
FreeSWITCH-IPv6: [2601:603:c01:97f0:64d4:31ff:fed7:6b51]
Event-Date-Local: [2015-07-03 15:42:04]
Event-Date-GMT: [Fri, 03 Jul 2015 22:42:04 GMT]
Event-Date-Timestamp: [1435963324009785]
Event-Calling-File: [sofia_presence.c]
Event-Calling-Function: [sofia_presence_handle_sip_i_message]
Event-Calling-Line-Number: [4883]
Event-Sequence: [755]
login: [sip:mod_sofia@172.18.101.161:5060]
proto: [sip]
to_proto: [sip]
from: [1001@172.18.101.161]
from_host: [172.18.101.161]
to_user: [13605556789]
to_host: [172.18.101.161]
from_sip_ip: [172.18.101.78]
from_sip_port: [5060]
to: [13605556789@172.18.101.161]
subject: [SIMPLE MESSAGE]
context: [public]
type: [text/plain]
from_full: ["1001" <sip:1001@172.18.101.161:5060>;tag=749800051]
sip_profile: [internal]
dest_proto: [sip]
max_forwards: [70]
DP_MATCH: [13605556789]
from_user: [12065551234]
final_delivery: [1]
Content-Length: 6
from yealink to cell
2015-07-03 15:42:04.009785 [INFO] mod_smpp_message.c:76 Creating message from event:
Event-Name: [MESSAGE]
Core-UUID: [d28d64a0-21d3-11e5-be4a-b5497df8f7c0]
FreeSWITCH-Hostname: [Quentus68594]
FreeSWITCH-Switchname: [Quentus68594]
FreeSWITCH-IPv4: [172.18.101.161]
FreeSWITCH-IPv6: [2601:603:c01:97f0:64d4:31ff:fed7:6b51]
Event-Date-Local: [2015-07-03 15:42:04]
Event-Date-GMT: [Fri, 03 Jul 2015 22:42:04 GMT]
Event-Date-Timestamp: [1435963324009785]
Event-Calling-File: [sofia_presence.c]
Event-Calling-Function: [sofia_presence_handle_sip_i_message]
Event-Calling-Line-Number: [4883]
Event-Sequence: [755]
login: [sip:mod_sofia@172.18.101.161:5060]
proto: [sip]
to_proto: [sip]
from: [1001@172.18.101.161]
from_host: [172.18.101.161]
to_user: [13605556789]
to_host: [172.18.101.161]
from_sip_ip: [172.18.101.78]
from_sip_port: [5060]
to: [13605556789@172.18.101.161]
subject: [SIMPLE MESSAGE]
context: [public]
type: [text/plain]
from_full: ["1001" <sip:1001@172.18.101.161:5060>;tag=749800051]
sip_profile: [internal]
dest_proto: [sip]
max_forwards: [70]
DP_MATCH: [13605556789]
from_user: [12065551234]
final_delivery: [1]
Content-Length: 6
from yealink to cell
2015-07-03 15:42:04.009785 [INFO] mod_smpp_utils.c:41 PDU
command_length [00000040] - [64]
command_id [00000004] - [SUBMIT_SM]
command_status [00000000] - [ESME_ROK]
sequence_number [00000018] - [24]
service_type [SMS]
source_addr_ton [01] - [TON_International]
source_addr_npi [01] - [NPI_ISDN_E163_E164]
source_addr [12065551234]
dest_addr_ton [01] - [TON_International]
dest_addr_npi [01] - [NPI_ISDN_E163_E164]
destination_addr [13605556789]
esm_class [01] - [1]
protocol_id [00] - [0]
priority_flag [00] - [0]
schedule_delivery_time []
validity_period []
registered_delivery [00] - [0]
replace_if_present_flag [00] - [0]
data_coding [00] - [0]
sm_default_msg_id [00] - [0]
sm_length [06] - [6]
short_message [from yealink to cell]
2015-07-03 15:42:04.089785 [INFO] mod_smpp_utils.c:41 PDU
command_length [00000021] - [33]
command_id [80000004] - [SUBMIT_SM_RESP]
command_status [00000000] - [ESME_ROK]
sequence_number [00000017] - [23]
message_id [040000006946E822]
Conclusion
This module should allow FreeSWITCH users to set up an account with an SMPP provider like nexmo to send and receive messages. The original JIRA can be found here: https://freeswitch.org/jira/browse/FS-7730, and you can learn more about SMS in a previous post: sms-support-in-freeswitch