Kannel Document Configuration Steps
Kannel Document Configuration Steps
Kannel Document Configuration Steps
on Kannel
Parichaya Bimlendu Thakur
The document describes a detail information on how
kannel is setup in any linux system, its configuration and its
monitoring to get the actual information with SMSC
gateway.
+91-8800889959
16-Nov-17
KANNEL DOCUMENT CONFIGURATION
STEPS
Table of Contents
Kannel Installation ........................................................................................................................................ 4
Installing Kannel from RPM Packages ....................................................................................................... 4
Installing Kannel .................................................................................................................................... 4
Upgrading Kannel .................................................................................................................................. 4
Removing Kannel .................................................................................................................................. 4
Installing Kannel from DEB Packages ........................................................................................................ 5
Installing or upgrading Kannel from Debian or Kannel repository ....................................................... 5
Installing or upgrading Kannel from a file ............................................................................................. 5
Removing Kannel .................................................................................................................................. 5
Kannel Information ....................................................................................................................................... 7
Access Logs: .............................................................................................................................................. 7
BIND REQ:.............................................................................................................................................. 7
HANDSHAKE RESPONSE FROM SMSC GATEWAY:................................................................................. 7
SMS NOT DELIVERED TO CUSTOMER:................................................................................................... 7
SMS DELIVERED TO CUSTOMER:........................................................................................................... 7
Details on Request-Response Parameters ................................................................................................ 8
Kannel Logs ............................................................................................................................................... 9
Sample Kannel Log: ............................................................................................................................... 9
DLR Responses List .................................................................................................................................. 10
Kannel Configurations ................................................................................................................................. 11
Basic Structure of a Kannel: A Logical Structure ..................................................................................... 11
GSM SMS CALL FLOW MO/MT................................................................................................................ 11
Sample Configuration file............................................................................................................................ 12
Running and Stopping Kannel ..................................................................................................................... 16
Start a Kannel .......................................................................................................................................... 16
Bearer-Box .......................................................................................................................................... 16
SMS-Box .............................................................................................................................................. 16
Path of Scripts to Run/Stop Kannel ..................................................................................................... 16
Stop a Kannel .......................................................................................................................................... 16
Kill all instances at one glance ............................................................................................................ 16
Kill Single instance............................................................................................................................... 17
Glossary & References: ............................................................................................................................... 18
Kannel Installation
Before you install Kannel, check that you have libxml2 installed on your system:
rpm -q libxml2
Installing Kannel
1. Download the binary RPM packet from the Kannel web site.
2. Install the RPM package:
Command Used: rpm -ivh kannel-VERSION.i386.rpm
Upgrading Kannel
1. Download the binary RPM packet from the Kannel web site.
2. Upgrade the RPM package:
Command Used: rpm -Uvh kannel-VERSION.i386.rpm
Removing Kannel
1. Remove the RPM package:
Command Used: rpm -e kannel
After you have installed Kannel from the RPM packages you should now be able to run the Kannel init.d
script that will start Kannel as a WAP gateway. Run the script as root.
Command Used: /etc/rc.d/init.d/kannel start
To stop the gateway just run the same script with the stop parameter.
Command Used: /etc/rc.d/init.d/kannel stop
If Kannel is already running and you just want to quickly stop and start the gateway,e.g.to set a new
configuration option, run the script with the restart parameter.
Command Used: /etc/rc.d/init.d/kannel restart
If you want Kannel to run as a daemon, you need to add a symbolic link to the Kannel script from the run
level you want Kannel to run in. E.g. to run Kannel in runlevel 5 add symbolic links to /etc/rc.d/rc5.d/.
Command Used:
cd /etc/rc.d/rc5.d/
ln -s ../init.d/kannel S91kannel
ln -s ../init.d/kannel K91kannel
To run Kannel as a SMS gateway you need to edit the configuration file which is at
/etc/kannel/kannel.conf. In Kannel's documentation directory (/usr/share/doc/kannel) there is an
example file called examples/smskannel.conf. It has some basic examples of the configuration groups
needed to run Kannel as a SMS gateway. For more detailed information please see
examples/kannel.conf in the same directory for a commented complete example, and read the section
"SMS gateway configuration" later in this same document.
The logging is disabled by default and you can enable it from the kannel.conf file. Just add the log-file
option to the group of which box you want to log.
Removing Kannel
1. Log in as root:
2. Remove the package keeping configuration files:
Command Used: dpkg --remove kannel
3. Remove the package completely:
Command Used: dpkg --purge kannel
After you have installed Kannel from the DEB packages you should now be able to run the Kannel init.d
script that will start Kannel as a WAP gateway. Run the script as root.
To stop the gateway just run the same script with the stop parameter.
Command Used: /etc/init.d/kannel stop
If Kannel is already running and you just want to quickly stop and start the gateway,e.g.to set a new
configuration option, run the script with the restart parameter.
Command Used: /etc/init.d/kannel restart
If you want to restore Kannel running as a daemon, you need to add a symbolic link to the Kannel script
from the runlevel you want Kannel to run in. E.g. to run Kannel in default runlevel, just run:
Command Used: update-rc.d kannel defaults
Kannel package starts by default with a wapbox daemon. To activate smsbox or select which box you
want to start, edit /etc/default/kannel and comment/uncomment START_xxxBOX.
To run Kannel as a SMS gateway you need to edit the configuration file which is at
/etc/kannel/kannel.conf. In /usr/share/docs/kannel/examples/ there are example files. They have some
basic examples of the configuration groups needed to run Kannel as a SMS gateway. For more detailed
information please read the section "SMS gateway configuration" later in this same document.
Kannel Information
In the Kannel configuration file, mapping of paths like where the log files needs to be kept is also
mentioned. One can customize these paths depending upon the required. We have kept log path for
kannel as in below path;
Path:
Note: servicename: This signifies name of the service associated with the service that is configured. Eg:
access_gamezone.log, kannel_gamezone.log
Below are snippets of sample log format and individual logs of both access and kannel logs.
Example:
Access Logs:
BIND REQ:
2017-02-10 14:41:41 Sent SMS [SMSC:smsc3] [SVC:tester] [ACT:] [BINF:] [FID:2300267715]
[META:?smpp?PARTNER+ROLE+ID=103&PRICEPOINT=340645&PRODUCT=745&?smpp_resp?]
[from:92070] [to:96896733976] [flags:-1:0:-1:-1:15] [msg:101:You have succesfully subscribed to Games
Zone at 1 OMR/Week. To unsubscribe, send UNSUB VGZ to 92070.] [udh:0:]
PDU Log
2017-11-07 17:00:30 [26805] [6] DEBUG: SMPP PDU 0x7f4614000a10 dump:
2017-11-07 17:00:30 [26805] [6] DEBUG: type_name: submit_sm
2017-11-07 17:00:30 [26805] [6] DEBUG: command_id: 4 = 0x00000004
2017-11-07 17:00:30 [26805] [6] DEBUG: command_status: 0 = 0x00000000
2017-11-07 17:00:30 [26805] [6] DEBUG: sequence_number: 144 = 0x00000090
2017-11-07 17:00:30 [26805] [6] DEBUG: service_type: NULL
2017-11-07 17:00:30 [26805] [6] DEBUG: source_addr_ton: 1 = 0x00000001
2017-11-07 17:00:30 [26805] [6] DEBUG: source_addr_npi: 0 = 0x00000000
2017-11-07 17:00:30 [26805] [6] DEBUG: source_addr: "92070"
2017-11-07 17:00:30 [26805] [6] DEBUG: dest_addr_ton: 1 = 0x00000001
2017-11-07 17:00:30 [26805] [6] DEBUG: dest_addr_npi: 0 = 0x00000000
2017-11-07 17:00:30 [26805] [6] DEBUG: destination_addr: "96893136666"
2017-11-07 17:00:30 [26805] [6] DEBUG: esm_class: 3 = 0x00000003
2017-11-07 17:00:30 [26805] [6] DEBUG: protocol_id: 0 = 0x00000000
2017-11-07 17:00:30 [26805] [6] DEBUG: priority_flag: 0 = 0x00000000
2017-11-07 17:00:30 [26805] [6] DEBUG: schedule_delivery_time: NULL
2017-11-07 17:00:30 [26805] [6] DEBUG: validity_period: NULL
2017-11-07 17:00:30 [26805] [6] DEBUG: registered_delivery: 1 = 0x00000001
2017-11-07 17:00:30 [26805] [6] DEBUG: replace_if_present_flag: 0 = 0x00000000
2017-11-07 17:00:30 [26805] [6] DEBUG: data_coding: 241 = 0x000000f1
2017-11-07 17:00:30 [26805] [6] DEBUG: sm_default_msg_id: 0 = 0x00000000
2017-11-07 17:00:30 [26805] [6] DEBUG: sm_length: 104 = 0x00000068
2017-11-07 17:00:30 [26805] [6] DEBUG: short_message:
2017-11-07 17:00:30 [26805] [6] DEBUG: Octet string at 0x7f4614001190:
2017-11-07 17:00:30 [26805] [6] DEBUG: len: 104
2017-11-07 17:00:30 [26805] [6] DEBUG: size: 105
2017-11-07 17:00:30 [26805] [6] DEBUG: immutable: 0
2017-11-07 17:00:30 [26805] [6] DEBUG: data: 59 6f 75 72 20 73 75 62 73 63 72 69 70 74 69 6f Your subscriptio
2017-11-07 17:00:30 [26805] [6] DEBUG: data: 6e 20 74 6f 20 47 61 6d 65 73 20 5a 6f 6e 65 20 n to Games Zone
2017-11-07 17:00:30 [26805] [6] DEBUG: data: 68 61 73 20 62 65 65 6e 20 72 65 6e 65 77 65 64 has been renewed
2017-11-07 17:00:30 [26805] [6] DEBUG: data: 20 61 74 20 31 20 4f 4d 52 2f 57 65 65 6b 2e 20 at 1 OMR/Week.
2017-11-07 17:00:30 [26805] [6] DEBUG: data: 54 6f 20 75 6e 73 75 62 73 63 72 69 62 65 2c 20 To unsubscribe,
2017-11-07 17:00:30 [26805] [6] DEBUG: data: 73 65 6e 64 20 55 4e 53 55 42 20 56 47 5a 20 74 send UNSUB VGZ t
2017-11-07 17:00:30 [26805] [6] DEBUG: data: 6f 20 39 32 30 37 30 2e o 92070.
2017-11-07 17:00:30 [26805] [6] DEBUG: Octet string dump ends.
2017-11-07 17:00:30 [26805] [6] DEBUG: PARTNER ROLE ID: "103"
2017-11-07 17:00:30 [26805] [6] DEBUG: PRICEPOINT: "340645"
2017-11-07 17:00:30 [26805] [6] DEBUG: PRODUCT: "745"
2017-11-07 17:00:30 [26805] [6] DEBUG: SMPP PDU dump ends.
DLR Responses List
Sample Kannel file looks very much similar to below configuration block. It comprises of few important
key-value parameters configuration steps and details of these are shared as we move along further
ahead. Without these below groups your Kannel will not work properly.
group = core
admin-port = 13000
wapbox-port = 13002
admin-password = bar
wdp-interface-name = "*"
log-file = "/var/log/bearerbox.log"
log-level = 1
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1"
………………………………
Example: Sample Kannel Configuration
group = core
admin-port = 15096
smsbox-port = 15098
admin-password = bar
log-file = "/usr/local/log/kannel_gamezone.log" Note 1: Core Group
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1"
access-log = "/usr/local/log/access_gamezone.log"
group = smsc
smsc = smpp
host = 185.127.160.2
port = 15529
transceiver-mode = 1
access-log = "/usr/local/log/access_gamezone.log"
unified-prefix= "-,+;-,+"
smsc-username = "103"
smsc-password = "V1e6C"
system-type = ""
address-range = ""
smsc-id=smsc3
max-pending-submits = 10
system-type = smpp
interface-version = 34 Note 2: SMSC Group
throughput = 60
smsc-id = smsc3
keepalive = 30
wait-ack = 30
alt-charset = utf-8
alt-addr-charset = "GSM"
wait-ack-expire=0x03
msg-id-type = 0x00
source-addr-ton = 0x01
source-addr-npi = 0x00
dest-addr-ton = 0x01
dest-addr-npi = 0x00
max-pending-submits = 10
alt-dcs=yes
group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 15097
Note 3: SMSBOX Group
sms-length = 500
smsbox-id = mysmsc
mo-recode = true
group = sendsms-user
username = tester
password = foobar
max-messages=6
Note 4: SENDSMS-USER
concatenation = trueaccess-log = "/usr/local/log/access_gamezone.log"
unified-prefix= "-,+;-,+"
dlr-url =
"http://205.147.98.6/async/omanTimweBillCb?id=%F&reportValue=%d&reply=%A
&mdn=%p&shortcode=%P"
group = smsbox-route
smsbox-id = mysmsc
smsc-id = smsc3
Note 5: SMS-ROUTE
shortcode = 92070
group = sms-service
keyword-regex = .*
catch-all = yes
omit-empty = true Note 6: SMS-SERVICE
max-messages = 0
get-url =
"http://205.147.98.6/async/omanTimweMO?Origin=%p&Text=%a&shortcode=%P"
group = smpp-tlv
name = PRICEPOINT
tag = 0x1400
Note 7: SMPP-TLV
type = integer
length = 4
smsc-id=smsc3
group = smpp-tlv
name = (TLV NAME)
tag = 0x1401 Note 8:If any more SMPP-
type = integer TLV are required
length = 4
smsc-id=smsc3
Running and Stopping Kannel
Start a Kannel
Kannel instance can be started post running the smsbox and bearbox scripts and by passing your kannel
configuration file as parameter in these scripts.
Once a kannel is installed in the system there are two major script files which are used to start/stop any
kannel.
Bearer-Box
The communication link between bearerbox and smsbox has been designed for the purpose of load-
balancing via random assignment. Which means, bearerbox holds all smsc connections and passes
inbound message to one of the connected smsboxes. So you have a determined route for outbound
messages, but no determined route for inbound messages.The bearer box is the engine that handles all
the donkey work. It establishes connections listens for smsc etc.
SMS-Box
The SMS box handles sending and receiving sms. It is like your hands. There's another box called the wap
box which deals with wap etc.
/usr/local/sbin/smsbox /etc/<kannelconfigurationfile>.conf
Stop a Kannel
Below are commands which are used to kill all or single instances of any kannel.
Commands:
killall smsbox
killall bearerbox
Kill Single instance
Commands:
2) Kill -9 <pid>
a. This command will kill the instance which you need to kill.
b. To kill any instance of any kannel, you need to kill both smsbox and bearerbox instances.
Glossary & References:
http://www.kannel.org/download/1.4.4/userguide-1.4.4/userguide.html
Acronyms
MO
o Mobile Originated - a SMS from mobile to application
MT
o Mobile Terminated - a SMS from application to mobile