Payday Loans Payday Loan
Home > WAP and SMS > Kannel: Compile, Install, and Configure Open Source WAP and SMS Gateway

Kannel: Compile, Install, and Configure Open Source WAP and SMS Gateway

I have recently worked an application where we needed to send and receive SMS messages. The application will receive a sms message, and return some business values to the client. It will also periodically push message to clients and update the status of their transactions. It become obvious that we need a gateway that could handle sms message between our applications and client’s handheld devices.

The application would be part of platform which includes asterisks(Open source PBX) and other great open source products. We needed to have an open source sms gateway to include the platform and that was one we came across the kannel. Kannel is a compact and very powerful open source WAP and SMS gateway, used widely across the globe both for serving trillions of short messages (SMS), WAP Push service indications and mobile internet connectivity. ”

I am going to layout the steps that I have followed to install, configure, and run some real world scenarios:

Compiling and Installation:

To compile and install the latest version of kannel on ubuntu 10.04 LTS follow these steps:

  $ cd  ~Download
  $ wget http://www.kannel.org/download/1.4.3/gateway-1.4.3.tar.gz
  $ cd ..
  $ mkdir src
  $ tar xfz ../Downloads/gateway-1.4.3.tar.gz 
  //congures kannel to be installed on   /opt/kannel
  $ configure --prefix=/opt/kannel   
  //In my case after running the above command, it complain not finding one of the required library libxml12. 
  //I have downloaded and installed (compiled the src and installed) plus the following command
 // sudo apt-get install libxml2-dev
  $ make 
  $ make install

Configuration
Like any great server application, for-example apache http, and Asterisk, comping and isntalling is the easy part. In order to use the system in a usefull way you need to tell the system how you want it to work and behave.
In kannel, there are several configuriton files that you need to understand and modify. you can find them /opt/kannel/gw/ (if you have followed my steps). If they are not already there, check “gw” folder with the following files
modems.conf, other_smskannel.conf, other_smskannel.conf, other_smskannel.conf, smskannel-ssl.conf, smskannel-ssl.conf in the compilation directory(~src/gateway-1.4.3/gw) and copy to /opt/kannel/gw

Most of the server softwares that comes with configuration, you can run and the system would run smoothlly but it may not behave as you expected. As you I have said before you need to modify the configuration files with your needs.
I usually runt they system with the default configurations and later tweak with my needs. Kannel comes with a test program which acts like SMSC. It is a fake SMSC. Fake SMSC is a simple protocol to test out Kannel. It is not a real SMS center, and cannot be used to send or receive SMS messages from real phones. So, it is ONLY used for testing purposes.

$ ls  /opt/kanne/sbin/
bearerbox  run_kannel_box  smsbox  wapbox

After you have compiled Kannel and edited configuration file for your taste, you can either run Kannel from command line or use supplied start-stop-daemon and run_kannel_box programs to use it as a daemon service.
Let us just test the system without any modification to the configuration files and use the fake SMSC for sending and receiving messages:

//starting the gateway
/opt/kannel$ sudo ./sbin/bearerbox  gw/smskannel.conf

//after the bearerbox, you can start either smsbox or wapbox
/opt/kannel$ sudo ./sbin/smsbox  gw/smskannel.conf

you need to start the bearer box before the other boxes. After that we can start the fake SMSC (please see the manual for details http://www.kannel.org/download/1.4.3/userguide-1.4.3/userguide.html)

test/fakesmsc -i 0.1 -m 100 "100 200 text nop" "100 300 text echo this"

With the above steps completed, you have a working system and sending/receiving messages between bearerbox, smsbox, and fakesmsc.
Let us now modify gw/smskannel.conf and configure the kannel to work with out GSM modem and interact with a web application.


Core configuration

The core part of the file does the basic configuration of bearbox and it does what we want

group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
#status-password = foo
#admin-deny-ip = ""
#admin-allow-ip = ""
#log-file = "/tmp/kannel.log"
#log-level = 0
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1"
#unified-prefix = "+358,00358,0;+,00"
#access-log = "/tmp/access.log"
#store-file = "kannel.store"
#ssl-server-cert-file = "cert.pem"
#ssl-server-key-file = "key.pem"
#ssl-certkey-file = "mycertandprivkeyfile.pem"

You can change any uncommented parameters given that the value is correct. Log levels range from 0 (debuging and development) to 4 (errors/critical information). Uncomment security parameters if you want to run kannel in a secure/ssl environment(consult with the user guide)

Next we are going to congure SMSC connections which handle sms protocol and message delivering. This will enable to receive and send message from/to handset devices. We are going to configure GSM modem as virtual SMSCs

#group = smsc
#smsc = fake
#smsc-id = FAKE
#port = 10000
#connect-allow-ip = 127.0.0.1

#SMSC modem gsm
group = smsc
smsc = at
host = 127.0.0.1
port = 13012
modemtype=huawei_e620_00
#modemtype=auto 
device = /dev/ttyUSB2
sim-buffering = true

Run $ls /dev command before connecting and after connecting your modem to the box and compare. The will give you the ports that your modem is mapped to (eg, /devttyUSB2). My modem is mapped to /devttyUSB0, /devttyUSB1, and /devttyUSB3. I have set device parameter to /dev/ttyUSB0 but it didn’t work smoothly for me. If you modem is mapped to several ports for whatever reason, try to test all of them until you get one that works for you.
sim-buffering is set to true, in order to receive message and delete from the SMSCs(Modem). you can set modemtype to auto or the name of you modem (eg, modemtype =huawei_e620_00 or #modemtype=auto ). check gw/modems.conf for modem configurations. The default file have several modem configuration and you can either change one of the existing modem configuration, use the generic modem modem, or add your modem’s configuration.

group = modems
id = huawei_e620_00
name = "Huawei E620"
detect-string = "huawei"
init-string = "AT+CNMI=2,1,2,2,0"
message-storage = sm
speed = 460800


The smsbox Group

The smsbox group helps configure the part of the system that dispatches SMSes received by the core SMS or receives SMSes before they’re sent out.

#---------------------------------------------
# SMSBOX SETUP
#
# Smsbox(es) do higher-level SMS handling after they have been received from
# SMS centers by bearerbox, or before they are given to bearerbox for delivery

group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013
global-sender = 13013
#sendsms-chars = "0123456789 +-"
#log-file = "/tmp/smsbox.log"
#log-level = 0
#access-log = "/tmp/access.log"

The global-sender is the out going number of you GSM modem and your modem will functional as SMSC.

You need to have the following configuration if you want to send sms from your application to mobile devices. Basically it is push sms messages and your application has to at least supply the following parameters to smsbox:

group = sendsms-user
username = tester
password = foobar
#user-deny-ip = ""
#user-allow-ip = ""

You use the following url to send an sms message from your application to destination via http request. http://kannel.machine:13013/cgi-bin/sendsms?username=tester&password=foobar&to=1234567&text=Hello World

Messages to your application

The sms-service group configures messages to your application. You can configure several several services and use “keyword” to route the message to the appropriate application or destination.

group = sms-service
keyword = nop
text = "You asked nothing and I did it!"

# There should be always a 'default' service. This service is used when no
# other 'sms-service' is applied.


group = sms-service
keyword = default
text = "No service specified"

group = sms-service
keyword = complex
catch-all = yes
accept-x-kannel-headers = true
max-messages = 3
concatenation = true
get-url = "http://localhost:8080/SMPPServer/?phone=%p&text=%a"

The above services will return responses to the sender based on received request content. The last service will forward the request to a get-url web applciation which will return a response to the sms sender through kannel. You can also configure the service to send post messages. Again, you can use the following url in order to initiate a message from your application to a hand held device or another destination.
http://kannel.machine:13013/cgi-bin/sendsms?username=tester&password=foobar&to=1234567&text=Hello World

That is it, you have all the configuration to send and receive sms messages. you can refer to the manual to see more configuration options and setting different values . You can also register and ask help in kannel forum http://kannel.com/

Categories: WAP and SMS Tags: , , ,
  1. Kedyr
    January 21st, 2011 at 17:56 | #1

    Thanks a lot, it was a great help.
    I am having an issue with implementing the ‘test/fakesmsc’
    I wanted to edit the kannel.config but I can’t find it. (followed all the instructions upto ‘test/fakesmsc

  2. promish
    August 15th, 2011 at 23:21 | #2

    It was great note . But i am using redhat5 in virtual box and setting up and had installed kannel. But when connecting my nokia phone into USB port i cannot find out .
    Please help me with this.

  1. No trackbacks yet.