Posts tagged HOWTO

HOWTO: Connect Kannel to an SMPP Server

Today I will be covering how to connect Kannel gateway to an SMPP Server.

Following on from my previous post, you should have a wapbox, smsbox and bearerbox binary now compiled on your machine. Just to put your minds at ease, I want to cover some basic architecture of Kannel, so you can understand how your messages flow through the system, and potentially give you an idea of where to start your troubleshooting.

What this diagram indicates is, the bearerbox is the binary with ‘the muscle’, it directs the flow of messaging traffic, and connects to all your upstream SMSC’s, GSM modems, etc.  These upstream SMSC type’s include, by default in Kannel, just to name a few, CIMD2, EMI, SMPP, AT modems, HTTP SMSCs and a few others. Seeing as Kannel is open source with a really flexible license, its easy to write your own custom SMSC’s, but that is way out of the scope of this document :)

So today, we will be focusing on getting the bearerbox, to connect to an SMPP server, seems simple enough!

Before you connect to something, you’ll need some basic details which your SMPP service operator will give you. This will include a system-id (username), password, hostname / ip address. This is what is required at minimum. Some operators will also give you things like default character set, system type and so forth. For todays demo I am going to connect to an SMPP server I have setup on my machine (should be fast! :P ).

So my details for connection (yours to be provided by operator):

  • IP address : internal.smpp.ddj.co.za
  • System-id (username): donsmpp
  • Password: strngpas
  • Port: 9102

So, at this stage my ‘bearerbox’ configuration looks as follows:


group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
log-file = "/tmp/kannel.log"
log-level = 0
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1"

group=smsc
smsc=smpp
smsc-id=internal
interface-version=34
host=internal.smpp.ddj.co.za
port=9102
system-id=donsmpp
smsc-password=strngpas
system-type=default
transceiver-mode=1

group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013
log-level = 0

Now you’re probably wondering where those other config settings came from, I’ll attempt to give you a really quick explanation.

  • group = core, all settings under this group, are related to the core bearerbox configuration, ie which ports to listen on, log level etc, as you can see I have put the log-level on 0 which will give me tons of debugging information which is pretty useful (not recommended for production servers though :) )
  • group = smsbox, this group specifies on which port/ip address to allow inbound connections from smsbox/wapbox/sqlbox/smppbox (see architecture) and isn’t really covered in this post, maybe next time :)
  • So that just leaves our smsc group, which is to connect to our smpp server. I’ll quickly try to explain the non trivial configuration directives.
    • smsc-id – this is a name given to the smsc, which can be used later for routing etc
    • interface-version – This is to tell us what version of SMPP to speak to the server with, I have specified 34 which indicates version 3.4
    • system-type – This is required by Kannel, but its not always required by the server, I have just specified a ‘junk’ value to stop Kannel from complaining.
    • trancseiver-mode – This indicates that I want to bind as a transceiver to the server (as opposed to transmitter / receiver) what this will allow me to do is send AND receive messages over the same connection. This is a SMPP 3.4 specific option.

I’m sure you’re tired of reading now and just want to see ! So let’s start this sucker up. I will start it up from command line, some of you (using Ubuntu, CentOS etc) will start it via init scripts, ie, /etc/init.d/kannel start, I will start it up simply by executing /usr/local/sbin/bearerbox /opt/kannel/etc/my_bbox.conf – this will of course only start the bearerbox, not the smsbox/wapbox, etc. Here we go!


2008-12-05 09:26:08 [28431] [6] DEBUG: Thread 6 (gw/smsc/smsc_smpp.c:io_thread) maps to pid 28431.
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP[internal]: Sending PDU:
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP PDU 0x50dab0 dump:
2008-12-05 09:26:08 [28431] [6] DEBUG: type_name: bind_transceiver
2008-12-05 09:26:08 [28431] [6] DEBUG: command_id: 9 = 0x00000009
2008-12-05 09:26:08 [28431] [6] DEBUG: command_status: 0 = 0x00000000
2008-12-05 09:26:08 [28431] [6] DEBUG: sequence_number: 1 = 0x00000001
2008-12-05 09:26:08 [28431] [6] DEBUG: system_id: "donsmpp"
2008-12-05 09:26:08 [28431] [6] DEBUG: password: "strngpas"
2008-12-05 09:26:08 [28431] [6] DEBUG: system_type: "default"
2008-12-05 09:26:08 [28431] [6] DEBUG: interface_version: 52 = 0x00000034
2008-12-05 09:26:08 [28431] [6] DEBUG: addr_ton: 0 = 0x00000000
2008-12-05 09:26:08 [28431] [6] DEBUG: addr_npi: 0 = 0x00000000
2008-12-05 09:26:08 [28431] [6] DEBUG: address_range: NULL
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP PDU dump ends.
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP[internal]: Got PDU:
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP PDU 0x50dab0 dump:
2008-12-05 09:26:08 [28431] [6] DEBUG: type_name: bind_transceiver_resp
2008-12-05 09:26:08 [28431] [6] DEBUG: command_id: 2147483657 = 0x80000009
2008-12-05 09:26:08 [28431] [6] DEBUG: command_status: 0 = 0x00000000
2008-12-05 09:26:08 [28431] [6] DEBUG: sequence_number: 1 = 0x00000001
2008-12-05 09:26:08 [28431] [6] DEBUG: system_id: "DDJSMPP"
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP PDU dump ends.
2008-12-05 09:26:12 [28431] [6] DEBUG: SMPP[internal]: Sending unbind:
2008-12-05 09:26:12 [28431] [6] DEBUG: SMPP PDU 0x50dab0 dump:
2008-12-05 09:26:12 [28431] [6] DEBUG: type_name: unbind
2008-12-05 09:26:12 [28431] [6] DEBUG: command_id: 6 = 0x00000006
2008-12-05 09:26:12 [28431] [6] DEBUG: command_status: 0 = 0x00000000
2008-12-05 09:26:12 [28431] [6] DEBUG: sequence_number: 2 = 0x00000002
2008-12-05 09:26:12 [28431] [6] DEBUG: SMPP PDU dump ends.
2008-12-05 09:26:12 [28431] [6] DEBUG: SMPP[internal]: io_thread: break and shutting down
2008-12-05 09:26:12 [28431] [6] DEBUG: Thread 6 (gw/smsc/smsc_smpp.c:io_thread) terminates.

Success! Due to the log level, being on debug, we can see almost too much info, but great because our bind was successful! Our bearerbox is now bound to the SMPP server and ready to start sending messages. The great thing about Kannel is, its built in status page, so even if you don’t see this output, you can browse to the local web status page, http://<host>:<port>/status (or http://localhost:13000/status in my case) which will give you an output like this:

Kannel bearerbox version `cvs-20080824′.
Build `Sep 7 2008 12:04:32′, compiler `4.0.1 (Apple Inc. build 5465)’.
System Darwin, release 9.5.0, version Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1/RELEASE_I386, machine i386.
Hostname donald-jacksons-macbook-pro-6.local, IP 192.168.1.82.
Libxml version 2.6.16.
Using OpenSSL 0.9.7l 28 Sep 2006.
Compiled with MySQL 5.0.67, using MySQL 5.0.67.
Using native malloc.

Status: running, uptime 0d 0h 0m 55s

WDP: received 0 (0 queued), sent 0 (0 queued)

SMS: received 0 (0 queued), sent 0 (0 queued), store size -1

SMS: inbound 0.00 msg/sec, outbound 0.00 msg/sec

DLR: 0 queued, using internal storage

No boxes connected

SMSC connections:

    internal    SMPP:internal.smpp.ddj.co.za:9102/9102:donsmpp:default (online 55s, rcvd 0, sent 0, failed 0, queued 0 msgs)

As you can see by this status output, I have no smsbox’s connected and am just demonstrating the bearerbox part. I will probably do a part 3 tutorial which will cover configuring smsbox and sending a few messages.

If you have any questions for me I’ll be happy to answer, even via comments or email. I hope this helps some of you connect your Kannel instances!

Technorati Tags: , , , , ,

HOWTO: Compile Kannel on Ubuntu / Kubuntu 8.04

Hey everyone, I am putting together a multi-part post on how to compile Kannel as well as connect it to an SMPP Server and send a few messages through it. I will be using Kubuntu 8.04 for the tutorial but it should apply to most Linux distro’s.

Step 1 – Satisfying requirements / dependencies

Install CVS client:

sudo apt-get install cvs

Build dependencies:

Install build tools (gcc, mac, g++, etc. Not all necessary but you should have them!)

  • sudo apt-get install build-essential

Install required Kannel dependencies (there are obviously way more, but this is all required on Kubuntu 8.04)

  • sudo apt-get install libxml2-dev

Install optional Kannel dependencies (These are only required if you would like to use SSL enabled servers, alternate DLR storage options etc. For the purposes of this example I will enable our Kannel build for SSL and PostgreSQL DLR storage)

  • sudo apt-get install openssl-dev
  • sudo apt-get install libpq-dev

Step 2 – Getting the source of Kannel.

Option a) Downloading latest stable

Visit the kannel download page and download the source as gzip tarball (or bzip2 tarball if you prefer). In the directory you downloaded execute:

tar zxvf gateway-X.X.X.tar.gz

Option b) Getting the latest CVS (my preferred method)

You will need a CVS client installed.

Log in using the following command (just press Enter when it asks for
a password):

  • cvs -d:pserver:anonymous@cvs.kannel.org:/home/cvs login

Check out the current version of the Kannel gateway:

  • cvs -d:pserver:anonymous@cvs.kannel.org:/home/cvs co -d gateway-cvs gateway

Once the gateway is checked out, it will be in the gateway-cvs directory (as specified above)

Step 3 – Building Kannel

Change directory to the directory you downloaded the source to (gateway-X.X.X or gateway-cvs)

Execute:

  • ./configure –with-pgsql –enable-ssl

This should configure the build correctly with OpenSSL and PostgreSQL support.

Once that’s done, execute:

  • make

This will build the binaries for Kannel, if you want to install them system wide at this point you can by executing:

  • sudo make install 

You now have the Kannel binaries built for your use. These include smsbox, wapbox and bearerbox. You can either consult the Kannel user guide for how to use these or wait for my next post where I will cover setting and starting up Kannel (and some architecture stuff ;) ).

Technorati Tags: , , , ,