(Disclaimer: Title might not make sense to everyone depending on your spoken language, but you should be able to consume the contents nonetheless
)
From time to time you’ve probably felt the need to reach out to your devices via SMS. Either for providing info to the user, or more nefarious purposes like wiping, etc. I’ve also mentioned previously that some MDM use SMS as their primary vehicle for managing devices – and if you’re using one of those solutions you may be happy with what you’ve got. If you are using an MDM platform which does not rely on SMS you may still want to leverage SMS from time to time. Hey, maybe you’re not running any MDM at all, and just want to send SMS from your computer.
There are a multitude of different solutions out there that will ley you do this. If you cradle your Windows Mobile device Jeyo Mobile Extender will help you out. My mobile operator provides a plug-in for Outlook, and so do many other operators. But if you want to send a larger amount of SMS messages, send binary messages, and do so on a server level the de facto standard is an open-source solution called Kannel. This will let you run your own SMS and/or WAP gateway, and send the messages either through dedicated SMS modems, mobile phones, or commercial SMS gateways. (Many of the gateway providers will let you interface to them in a number of ways, but Kannel acts as a layer of abstraction so you can switch gateway provider, and not have to hard code the interfaces in your code.) You also get functionality like queuing, load balancing, receiving, etc. So running with that idea I’ll start off installing Kannel on a box of my own.
Kannel is an open-source effort aimed primarily at *nix boxes, but it will happily run on Windows as well. If you compile the source code yourself that is. Thankfully it’s not as hard as you might think
Kannel will work on both Windows XP/Vista and Windows Server. I’ve done it on a virtual XP machine primarily because it’s lightweight and got Visual Studio installed (for dev stuff later on). If you will be using it in a server setting you should probably run it on a server level OS. I’ve tested it on 32-bit, but see no reason it shouldn’t work on 64-bit. If you are running 2K8 R2 RC 64-bit that might be a few too many unknowns currently, so 2K3 may be a safer bet for the moment being
It doesn’t require installation after the compile and config is done so you can just copy the files from one box to another for that matter (maybe not between x86 and x64 mind you).
You’ll need two things to start with:
Download Kannel from www.kannel.org (download the zip source).
Download Cygwin from www.cygwin.org. This is the tool you need to compile the source to something that works under Windows.
Unzip the Kannel source in a directory of your choosing.
Run the setup.exe you downloaded from Cygwin. It’s pretty much next, next, next. Just make sure you check some additional developer packages:
Gcc-core
Gcc-g++
Gdb
Libxml2
Libxml2-devel
Make
After installing Cygwin you can fire up a bash cmd line. Change to the directory where your Kannel source is located, in my case the command is “cd /cygdrive/c/install/Kannel/gateway”. (You remember the MS-DOS days, right?)
Now you can return to Windows. The Kannel dir contains a lot of files – you don’t need them all.
![]()
Create a new directory, and copy the following files:
Bearerbox.exe
Smsbox.exe
Wapbox.exe
In addition you need some dlls from the cygwin/bin dir:
cygwin1.dll
cygz.dll
cygiconv-2.dll
cygxml2-2.dll
And you’ll end up with something like this:
![]()
Kannel comes “unconfigured” out of the box (there are after all a lot of different setups out there), Fire up your Notepad and create a file called “kannel.conf”. I’ve provided a minimum config below (obviously with some “faked” fields mind you):
# SEND-SMS USER group = sendsms-user username = dummy password = passw0rd max-messages = 100 concatenation = true default-sender = 12345678 # BEARERBOX SETUP group = core admin-port = 13001 smsbox-port = 13002 admin-password = yadayada box-deny-ip = "*.*.*.*" box-allow-ip = "127.0.0.1" # SMSBOX SETUP group = smsbox bearerbox-host = localhost sendsms-port = 13000 # Generic modem description group = modems id = generic name = "generic" init-string = "AT" # SMPP SMSC group = smsc smsc-id = mySMSC preferred-smsc-id = mySMSC smsc = smpp host = 192.168.0.1 port = 30002 receive-port = 30002 smsc-username = dummy smsc-password = passw0rd system-type = "gw0" address-range = "" source-addr =
For a closer explanation of these configuration options you should check out the Kannel documentation online.
I have an account with a gateway provider, and I’ll be using an SMPP interface for the communication. You’ll obviously need to find out what suit your needs the best, and configure accordingly
Finding out all the details can be a challenge, but if you are using a commercial provider they might be able to help you out with the necessary details.
After saving the conf-file fire up two command prompts. Change to the Kannel dir, and run “bearerbox” in the first, and “smsbox” in the second. In that order. Yes, I know – you’ll either want to run them as services, or create a batch file. But for an initial test this is a quicker approach.
By default you can use HTTP posts to send SMS messages. So since we’re stil in a test mode, start up your browser and enter the following url in the address bar (changing the to field to an actual phone number, and depending on how/where you pass the messages through include the country prefix as necessary):
“http://localhost:13000/cgi-bin/sendsms?user=dummy&pass=passw0rd&to=12345678&text=Hello+World”
You’ll hopefully get a “0: Accepted for delivery” feedback. If not – you are due for some troubleshooting. (Look for clues in the command prompt windows.) I had some fun getting the details right for the smsc. Tip: passwords may not be longer than 8 characters with SMPP.
Now this doesn’t seem too impressive I’ll grant you that. I’ve just spent a whole lot of time on something I could have achieved in seconds on my device, or a matter of minutes installing a small app on my computer. But it lays the groundwork for doing more “fancy” stuff later. Which I will be covering another day


Andreas, you are off the chart in the mobility world. Awesome post. I’m sure NowSMS are really pleased with your post. NOT. I’m now waiting for the post “How to build your own SMPP gateway.
Cheers Wayne
Airloom
Andreas, you are off-the-chart in the mobility world. Awesome post. I am sure NowSMS are really pleased with your solution. NOT. I’m now waiting for your next post “How to build your own SMPP gateway.
Cheers Wayne
Airloom
Thank you Wayne. I believe there is an add-on module for Kannel – smppbox so you can run your own gateway. Not sure if it costs money or it’s also free. But obviously it would still require some work getting “direct access” to the mobile operators network for sending the stuff through
(So might have to wait a little while for this post to surface.)
But I will be exploring some scenarios, and will probably post more articles as to what can be done with this Kannel box
Your post is awesome. I spend a couple of days searching how to do this freaky thing.
thanks.
i try to run bearerbox and smsbox, but after a few minutes, there’s an error [panic] mutex error blablabla, and then smsbox shut down…
i’ve tried this procedure several times, and those error always occured, can u help me, whats the problem here… Thanks Before
Yup, there is a bug in Kannel.
Hopefully this fix would apply to your installation as well:
You need to edit a file – gateway-1.4.1\gwlib\thread.c
Comment out the following lines:
if (mutex->owner == gwthread_self())
panic(0, “%s:%ld: %s: Managed to lock the mutex twice! (Called from %s:%ld:%s.)”, \
__FILE__, (long) __LINE__, __func__, file, (long) line, func);
And you’ll have to re-compile too. I’ve only seen this on Windows XP, not on Windows Server so it might be something related to the OS as well.
Hi,
It’s probably worth mentioning that Cygwin is unfortunately not stable enough under load to allow Kannel under Cygwin to be production stable.
I’ve done quite a bit of work with Kannel running under Cygwin on Windows (both W7 and Server 2003) in recent weeks. When subjecting Kannel to 30,000 messages Cygwin will just crash. Both the Bearer Box and the SMS Box services have to be restarted.
The Kannel user-group have confirmed that Cygwin’s p-threads are the issue.
But as a test environment Kannel under Cygwin is great.
30.000 messages is certainly a slightly more demanding environment than my test setup
I have customers running Cygwin-based Kannel on both Windows Server 2003 and Windows Server 2008 R2, but it’s nowhere near that amount of messages (it’s in MDM deployments, where sending SMS is just a support function), and while there are some random crashes it works quite nicely all in all for those setups.
Of course – it’s great that there are people testing the more demanding scenarios as well
I would assume that setting up a dedicated Kannel box on something *nix-based would scale better for a load like that.
i have entered ./configure and again make . I have done everything.but i cannot find out kannel.conf file.
Not sure I get what your issue is Akash.
The kannel.conf is not created by compile & make. You have to create it manually.
I have created a sample above, but you will need some details from your SMS provider to get the config correct for your environment. If you have access to a SMPP SMSC the config should work (of course providing a proper username, IP address, etc). If you’re not using SMPP you will need a different config, and it might be a little tricky to get working.
Many SMS providers are familiar with Kannel though, so they might be able to help you out with the settings needed.
svp j’ai pas compris la dernière étape aprés de Lancer mon Bloc-notes et créez un fichier appelé “kannel.conf”
est ce que le code en dessous je l’écris dans le bloc note ???et aprés je fais quoi ??? merciii
fifi,
You can copy the contents of the kannel.conf I have provided above. But you will need to get the correct config for your sms gateway – which could be smpp/http/something. You sms provider might be able to help you out.
Once you have a kannel.conf file just save the file in the same directory as the dll files you compiled and start the bearerbox and smsbox services.
merci pour votre réponse Andreas j’ai copié la configuration dans mon bloc note (moi aussi j’utilise smpp) ma question est ou je place mon bloc note et comment faire exécuter bearbox et sms box et ect ce que mon bloc note est le fichier kannel.conf ?????? merccciii
bonjour svp quels sont les paquets manquants
(j’utilise postgresql)
$ ./configure
Configuring for Kannel gateway version 1.4.3 …
Running system checks …
checking build system type… i686-pc-cygwin
checking host system type… i686-pc-cygwin
checking for gcc… gcc
checking for C compiler default output file name… a.exe
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables… .exe
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
checking for gcc option to accept ISO C99… -std=gnu99
checking for a BSD-compatible install… /usr/bin/install -c
checking for ranlib… ranlib
checking for bison… bison -y
checking for flex… flex
checking lex output file root… lex.yy
checking lex library… -lfl
checking whether yytext is a pointer… yes
checking for ar… ar
checking for convert… /cygdrive/c/Windows/system32/convert
checking for perl… /usr/bin/perl
checking for inline… inline
checking for special C compiler options needed for large files… no
checking for _FILE_OFFSET_BITS value needed for large files… no
checking how to run the C preprocessor… gcc -std=gnu99 -E
checking for grep that handles long lines and -e… /usr/bin/grep
checking for egrep… /usr/bin/grep -E
checking for ANSI C header files… yes
checking for sys/types.h… yes
checking for sys/stat.h… yes
checking for stdlib.h… yes
checking for string.h… yes
checking for memory.h… yes
checking for strings.h… yes
checking for inttypes.h… yes
checking for stdint.h… yes
checking for unistd.h… yes
checking size of short… 2
checking size of int… 4
checking size of long… 4
checking size of long long… 8
checking for log in -lm… yes
checking for accept in -lsocket… no
checking for inet_ntoa in -lnsl… no
checking for inet_ntop in -lresolv… yes
checking for inet_ntop in -lbind… no
checking for pthread_exit in -lpthread… yes
checking for libiconv in -liconv… yes
checking for ANSI C header files… (cached) yes
checking sys/ioctl.h usability… yes
checking sys/ioctl.h presence… yes
checking for sys/ioctl.h… yes
checking sys/time.h usability… yes
checking sys/time.h presence… yes
checking for sys/time.h… yes
checking for sys/types.h… (cached) yes
checking for unistd.h… (cached) yes
checking sys/poll.h usability… yes
checking sys/poll.h presence… yes
checking for sys/poll.h… yes
checking pthread.h usability… yes
checking pthread.h presence… yes
checking for pthread.h… yes
checking getopt.h usability… yes
checking getopt.h presence… yes
checking for getopt.h… yes
checking syslog.h usability… yes
checking syslog.h presence… yes
checking for syslog.h… yes
checking iconv.h usability… yes
checking iconv.h presence… yes
checking for iconv.h… yes
checking zlib.h usability… yes
checking zlib.h presence… yes
checking for zlib.h… yes
checking execinfo.h usability… no
checking execinfo.h presence… no
checking for execinfo.h… no
checking for stdlib.h… (cached) yes
checking sys/socket.h usability… yes
checking sys/socket.h presence… yes
checking for sys/socket.h… yes
checking sys/sockio.h usability… no
checking sys/sockio.h presence… no
checking for sys/sockio.h… no
checking netinet/in.h usability… yes
checking netinet/in.h presence… yes
checking for netinet/in.h… yes
checking for net/if.h… yes
checking for gettimeofday… yes
checking for select… yes
checking for socket… yes
checking for strdup… yes
checking for getopt_long… yes
checking for localtime_r… yes
checking for gmtime_r… yes
checking for backtrace… no
checking for srandom… yes
checking for getopt… yes
checking for gethostbyname_r… no
checking for gethostbyname… yes
checking for socklen_t in … yes
checking for getopt in … no
checking for getopt in … yes
checking regex.h usability… yes
checking regex.h presence… yes
checking for regex.h… yes
checking for regcomp… yes
Checking for POSIX threads support …
checking for working pthreads… yes
checking for pthread_spinlock support… yes
checking for pthread_rwlock support… yes
checking for sem_init in -lrt… yes
checking for semaphore support… yes
Checking for libxml2 support …
checking for xml2-config… /usr/bin/xml2-config
checking libxml version… 2.7.8
Configuring for PCRE support …
checking whether to compile with PCRE support… disabled
Configuring DocBook support …
checking for jade… jade
checking for jadetex… jadetex
checking for pdfjadetex… pdfjadetex
checking for dvips… dvips
checking for fig2dev… fig2dev
checking for convert… /cygdrive/c/Windows/system32/convert
checking for /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh/html/docbook.dsl… no
checking for /usr/lib/sgml/stylesheets/nwalsh-modular/html/docbook.dsl… no
checking for /usr/share/sgml/docbook/dsssl-stylesheets-1.*/html/docbook.dsl… no
checking for /usr/share/sgml/docbook/dsssl-stylesheets/html/docbook.dsl… yes
checking for /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh/print/docbook.dsl… no
checking for /usr/lib/sgml/stylesheets/nwalsh-modular/print/docbook.dsl… no
checking for /usr/share/sgml/docbook/dsssl-stylesheets-1.*/print/docbook.dsl… no
checking for /usr/share/sgml/docbook/dsssl-stylesheets/print/docbook.dsl… yes
Documentation will be built as well.
Configuring parameters …
checking which malloc to use… native malloc
enabling local time
enabling cookies
enabling HTTP/1.1 keep-alive
Configuring OpenSSL support …
checking whether to compile with SSL support… trying /usr/lib /usr/include/openssl
checking for openssl… /usr/bin/openssl
checking for CRYPTO_lock in -lcrypto… yes
checking for SSL_library_init in -lssl… yes
checking for SSL_connect in -lssl… yes
checking openssl/x509.h usability… yes
checking openssl/x509.h presence… yes
checking for openssl/x509.h… yes
checking openssl/rsa.h usability… yes
checking openssl/rsa.h presence… yes
checking for openssl/rsa.h… yes
checking openssl/crypto.h usability… yes
checking openssl/crypto.h presence… yes
checking for openssl/crypto.h… yes
checking openssl/pem.h usability… yes
checking openssl/pem.h presence… yes
checking for openssl/pem.h… yes
checking openssl/ssl.h usability… yes
checking openssl/ssl.h presence… yes
checking for openssl/ssl.h… yes
checking openssl/err.h usability… yes
checking openssl/err.h presence… yes
checking for openssl/err.h… yes
checking openssl/hmac.h usability… yes
checking openssl/hmac.h presence… yes
checking for openssl/hmac.h… yes
checking whether the OpenSSL library is multithread-enabled… yes
checking whether to compile with SSL support… yes
Configuring DB support …
checking whether to compile with MySQL support… disabled
checking whether to compile with LibSDB support… disabled
checking whether to compile with SQLite2 support… disabled
checking whether to compile with SQLite3 support… disabled
checking whether to compile with Oracle support… disabled
checking whether to compile with PostgresSQL support… disabled
Generating output files …
configure: creating ./config.status
config.status: creating gwlib/gw_uuid_types.h
config.status: creating Makefile
config.status: creating gw-config.h
config.status: gw-config.h is unchanged