Posts tagged Kannel
Kannel presentation to GeekDinner
Oct 3rd
Apologies for the delay as I promised to have this up the day after GeekDinner
Thanks to all those involved with organizing these events, they are really enjoyed by all. Thanks to the sponsors Delheim for providing the wine for the event.
Anyway, without further ado here is the presentation I gave on Kannel at GeekDinner on Monday the 28th of September 2009.
I hope it provides some insight into the gateway
Technorati Tags: Kannel, GeekDinner
Kannel for Windows – Some Cygwin Binaries
Apr 8th
A customer of mine recently asked me for a windows version of Kannel. Prior to this I had no experience with Cygwin/Windows development at all. It was actually extremely simple to build Kannel using Cygwin (thanks to the Kannel developers for being, well, pretty cool
).
Obviously it’s not the easiest thing in the world for non-developers so I thought I would make it easy for everyone to just simply download some binaries of Kannel and get going.
So with that said, I have built two installers for Kannel to run on windows. I have built against the stable release 1.4.3 and then I have done a CVS snapshot build against CVS dated 2009-04-07.
If you are interested in these, please navigate to my kannel for windows page which I will keep up to date as more stable releases get done.
Just a bit of background of how to build your own versions on Cygwin below:
- Download latest version of Cygwin
- Install, making sure you select the development packages (gcc, automake, libxml2-devel, openssl-devel, etc)
- Download and extract the source of Kannel from www.kannel.org
- Change directory to the extracted source
- Run ./configure
- Run make
- Then if you wish, run make install to install (need privileges unless alternative –prefix was specified)
Easy !
Just as a final note, Kannel on windows should NOT be treated as a production ready piece of software, so this should be used strictly for convenience, testing, development, etc.
As always, if you have any questions, leave a comment or mail me via blog@ddj.co.za
Technorati Tags: Kannel, Windows, Cygwin

Extracting meta-data from SMPP TLV’s with Kannel
Mar 15th
I have been relatively quiet the past few weeks with various operations going on, but seeing as I have a few minutes to spare I thought I would do a quick post explaining how to extract SMPP TLV’s using the new Kannel meta data features which are in the current CVS branch.
These are scheduled for the 1.5.0 stable release of Kannel, so for now you’ll need to do a CVS checkout of the main branch (as described in my previous posts).
I will be demonstrating how to set a test TLV and then extracting this data when a reply is received. Once you have setup your ‘smpp-tlv’ group, you simply need to specify an additional parameter in your smsbox request. This parameter is named ‘meta-data’. The format for this variable is ‘?<bind_type>?<dataset>’ currently the only supported bind type is ‘smpp’ but it was done this way to allow future support.
The dataset argument, is a URL encoded key/value pair string. So for these tests I have configured a smpp-tlv group called ‘my-custom-var’. In order to set this, I need to build a string like this for meta-data purposes.
?smpp?my-custom-var=This+is+a+cool+var
As you can see my-custom-var is set as a URL encoded variable, this will still need to be URL-encoded for submission in the meta-data parameter sent to smsbox.
So just to demonstrate, using PHP how you would build this string, you would use.
$bind_type = "smpp";
$my_custom_var = "This is a cool var";
$meta_data = "?".$bind_type."?my-custom-var=".urlencode($my_custom_var);
/* Now we need to urlencode this string */
$meta_data = urlencode($meta_data);
/* So URL would look like */
/* cgi-bin/sendsms?to=...&from=...&meta-data=$meta_data */
So now, when you set this to smsbox, it will be sent via the smpp bind as a TLV. Easy!
Now on the converse, if your smpp bind returns a TLV in a deliver_sm or other PDU, this will also passed to your URL (if you have configured it. Here below is a basic function for parsing the meta data out of this string.
/* This function will take the meta-data string and return an associative array */
function parse_metadata($var) {
$pos = strpos($var, "?", 1) + 1;
/* Simply stripping out bind type 'smpp', this can be modified if you need it
*/
$var = substr($var, $pos);
$data = parse_str($var, $out);
return $out;
}
/* Example: */
$meta_data = parse_metadata($_GET['meta-data']);
echo "My custom var = ".$meta_data['my-custom-var'];
I hope this helps you with your SMPP TLV requirements. Good luck, don’t forget to email me if you need any assistance with Kannel/SMS, etc and I will do my best to help you as best I can.
Technorati Tags: Kannel, SMPP, TLV, Kannel Support
Kannel Web Configuration Tool v0.1 available
Jan 5th
Hi everyone,
I have ‘released’ version 0.1 of the Kannel Web Configuration tool. I have created somewhat of a home page for it here for those who are interested.
It is available as ‘donation-ware’ with full source code. Admittedly it was done in a hurry so hopefully later releases will see some code enhancements.
I am more than happy to provide assistance wherever necessary on this project.
Enjoy!
Technorati Tags: Kannel, Web Configuration, SMS
Kannel Web Configuration Tool
Dec 18th
Following on with my previous themes of making Kannel easier to use for everyone, I have spent some time creating a tool which I think makes it easier to configure Kannel. It is a web based configuration tool which edits Kannel configuration files directly (doesn’t rely on any third party databases etc). I wrote it in PHP to keep it simple.
Current features
- Edit existing configuration files
- Add new configuration groups (smsc’s, smsbox-route, sendsms-user, etc)
- Based on the cfg.def from Kannel CVS 1.4.2 as of 2008/12/18
Features in progress
- Live updates to Kannel without restart for SMPP/EMI and smsbox-route’s (patch of Kannel CVS required)
Coming soon
- User authentication
- Kannel analytics and monitoring
- Audit trails of changes
- Other live updates
I am looking for feedback on the tool and when I believe it is stable enough and usable enough I will release it. You can see the beta of this tool here: http://www.ddj.co.za/kannel-config/web/
Enjoy! Please comment on the blog or email me at kwc@ddj.co.za with feedback.
Technorati Tags: Kannel, Web, Configuration, SMPP
HOWTO: Connect Kannel to an SMPP Server
Dec 5th
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!
).
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: Kannel, SMPP, Architecture, Smsbox, Bearerbox, SMS
HOWTO: Compile Kannel on Ubuntu / Kubuntu 8.04
Nov 3rd
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
).
