Skip to main content

Build a WAP gateway On Linux

Basic steps for setting up a WAP gateway

Manas Behera (manasb@convergelabs.com), Software engineer, ConvergeLabs Software Technologies
The author is a software engineer at ConvergeLabs, and has been working in Linux for several years. His primary interests are C, wireless and Linux. He can be contacted at manasb@convergelabs.com

Summary:  The hottest technology for implementing mobile services is the Wireless Application Protocol (WAP). This article discusses the advantages of working with the open source gateway for WAP, which performs the protocol conversion between a Web server and a mobile phone.

Date:  08 Jun 2004
Level:  Introductory
Activity:  3655 views

The WAP gateway works by letting a telephone act as a simple Web browser with optimized markup language, scripting language, and the transmission protocols for wireless-over-the-air use. It talks to the phone using the WAP protocol stack and translates the requests it receives to normal HTTP. Therefore, content providers can use any HTTP server and utilize existing know-how about HTTP service implementation and administration.

In addition to protocol translations, the gateway also compresses the WML (Wireless Markup Language) pages into a more compact form, which saves bandwidth on the air and further reduces the phone's processing requirements. It also compiles WMLScript programs into a bytecode format.

There are various commercial WAP gateways available on the market that are quite expensive. Kannel, on the other hand, is an open source gateway; you don't need to pay for it, you can edit the source code yourself, and you can construct your own customized gateway. Because Kannel is being developed on Linux systems (RedHat and Debian), it can be smoothly ported to other UNIX-like operating systems. However, in this article, I illustrate building the gateway for these two Linux systems only.

Kannel gateway architecture

The gateway divides the processing load between the following two hosts:

  • The bearer box, which connects to the SMS (Short Message Service) centers and CSD (Circuit Switched Data) routers, providing a unified interface to them for the wapbox. The bearer box does this by implementing the WDP (Wireless Datagram Protocol) layer of the WAP stack.
  • The wapbox, which hosts the upper layers of the WAP stack. Each session and its transactions are handled by the same wapbox.

Working of the system

The bearer box receives UDP (User Datagram Protocol) packets from CSD routers, inspects them to see whether they are WAP packets, and then routes them to the WAP box. This simple design allows the bearer box to do a minimum of processing per packet. The bearer box also sends the UDP packets that the other boxes generate, which adds some more routing processing. The wapboxes implement the WTP (Wireless Transaction Protocol) and WSP (Wireless Session Protocol) layers. These take HTTP-like requests from the phones and make the actual HTTP requests to content servers, compress the responses, and send them back to the terminals. (Sessions are maintained to make as much use of the limited radio bandwidth as possible.)


Basic software and hardware requirements

Before constructing the gateway, you must have the following basic setup:

  • C compiler (CC or GCC), development libraries, and related tools
  • The Gnome XML library (known as gnome-xml and libxml), Version 2.2.5 or later (see Resources for a link)
  • GNU Make
  • Posix thread libraries (pthread.h)

Setting up the gateway

There are two ways to build the gateway. The first way is to get the source code, compile it yourself, and install it. The second way is to have the precompiled binary RPM (RedHat Package Manager) and get it installed. The RPM is a program designed to build and manage packages of software, including the source and binaries. It is also portable and can be run on different platforms. See Resources for more information on RPM.

First, you need to install the Kannel source code by downloading it from Kannel's Web site (see Resources). Once the download is complete, compile the source code by entering the following commands from a command line:

./configure


make

Ideally, you should be able to compile the code without any problems. If all the libraries mentioned above are present, the code compiles easily. To install the gateway, enter the following command: make bindir=/usr/local/bin install.

You can substitute the /usr/local/bin directory with any other path where the gateway should be installed. The gateway is now installed on your system. The executables can now be found in the /gw directory named bearerbox, wapbox.

Installing the pre-compiled binaries

Check that you have the libxml2 XML library installed in your system by typing the following command: rpm -q libxml2.

This XML library is required to install and compile the gateway. Download the binary RPM file of Kannel from the site. Log in as root, and enter the following command to install it. If you have sufficient permission, you might not require the superuser mode.


rpm -ihv kannel_VERSION.i386.rpm

This completes the installation. The _VERSION attribute is the version number of the Kannel binaries.


Working with the gateway

Now study the basic steps for using the gateway and testing it with a WAP-enabled mobile phone simulator. Essentially, you'll be dealing with the bearerbox and the wapbox (the executables you've just created).

Configuring the gateway

The bearerbox and wapbox are the main working modules of the gateway, and must be configured before configuring the gateway. These two modules are controlled by a configuration file that has wapbox and bearerbox groups.

A configuration file consists of groups of configuration variables. Groups are separated by empty lines, with each variable defined on its own line (each group in Kannel configuration is distinguished with a group variable). Lines beginning with a hash mark (#) are comments and should be ignored.

A variable definition line has the name of the variable, the equal sign (=), and the value of the variable. The name of the variable can contain any character except white spaces and equal signs. The value of the variable is a string, with or without quotation marks around it. Quotation marks are needed if the variable begins or ends with a white space or contains special characters. A normal C escape character syntax works inside quotation marks.

Working with configuration files

I'm including an example of the configuration file that I used for this project; it is the basic file with which the gateway runs. There is, however, a list of other attributes available to control the gateway. You can learn about them by referring to the Kannel User Guide.


Listing 1. Sample configuration file for the gateway
#The sample.conf file which is the core configuration file
#for running the WAP Gateway
#Start of Configuration File

group = core
admin-port = 13000
admin-port-ssl = false
admin-password = rose123
status-password = rose123
admin-deny-ip = "205.158.62.76"
admin-allow-ip = "*.*.*.*"
wapbox-port = 13002
box-deny-ip = "205.158.62.76"
box-allow-ip = "*.*.*.*"
udp-deny-ip = "205.158.62.76"
udp-allow-ip = "*.*.*.*"
wdp-interface-name = "*"
log-file = "my_kannel.log"
log-level = 1

#The wapbox group for WAP gateway configuration
group = wapbox
bearerbox-host = localhost
timer-freq = 1
log-file = "my_wap.log"
log-level = 1
#End of Configuration File

Understanding the various attributes given in the sample configuration file

A group contains the ID of the group to which it relates. If the ID is core, then it's the bearerbox configuration; otherwise, a wapbox ID is for the wapbox configuration. The admin-port identifies the port through which the HTTP administration is to be done. The various other attributes of the group bearerbox and wapbox are described in Tables 2 and 3. The mandatory fields are denoted by an m, o is optional, and c is conditional.


Table 1. Configuration file attributes for the bearerbox
VariableValueDescription
group (m)core This is a mandatory variable.
admin-port (m)port-numberThe port number in which the bearerbox listens to HTTP administration commands. It can reach any port and must be over 1023.
admin-port-ssl (o)boolIf set to true, an SSL-enabled administration HTTP server is used instead of the default nonsecure plain HTTP server. Default is 'no'.
admin-password (m)stringPassword for HTTP administration commands.
status-passwordstringPassword to request Kannel status. If not set, no password is required; if set, either this or admin-password can be used.
admin-deny-ipIP-listThese lists can be used to prevent connection from the specified IP addresses.
admin-allow-ipIP-listCan be used as a wild card.
wapbox-port (c)port-numberPort for wapbox connections. If not set, Kannel cannot handle WAP traffic.
box-deny-ipIP-listThese lists can be used to prevent box connections from the specified IP addresses.
box-allow-ipIP-listSame as admin. It allows IP.
udp-deny-ipIP-listDenying UDP packets from a given IP.
udp-allow-ipIP-listAllowing UDP packets from an IP.
wdp-interface-name(c)IP or *If this is set, Kannel listens to WAP UDP packets incoming to ports 9200 through 9208, bound to given IP. If no specific IP is needed, use just an asterisk (*).
log-filefilenameA file in which to write a log. This is in addition to stdout and any log file defined in the command line. Log-file in core group is only used by the bearerbox.
log-levelnumber 0..5Minimum level of logfile events logged. 0 is for debug, 1 for info, 2 for warning, 3 for error and 4 for panic.

Table 2. Configuration file attributes for the wapbox
VariableValueDescription
group (m)wapboxThis is a mandatory variable.
bearerbox-host (m)hostnameThe machine hosting the bearerbox.
timer-freqvalue-in-secondsThe frequency with which timers are checked out. Default is 1.
log-filefilenameAs with bearerbox "core" group.
log-level number0 through 5Meaning same as in bearerbox.

Starting the gateway

Once you have compiled Kannel and edited the configuration file to your specifications, it is time for the final step. For basic work, you can copy and paste the text shown in Listing 1, save it with any name, and use it as your configuration file. In order to start the gateway, you must first start the bearerbox, followed by the wapbox. Because the bearerbox is the essential part of the gateway, it must be started first.

Start the bearerbox with the following command: ./bearerbox -v 1 <conf_file>.

The -v 1 sets the logging level to INFO. In this option you won't see a large amount of debugging output (the default is DEBUG <conf_file>), where conf_file is the name of the configuration file you are using with Kannel. The basic distribution packet comes with the sample configuration file wapkannel.conf (in the /gw subdirectory), which is for setting up WAP Kannel. You can edit those configuration files to set up your own specialized system. After the bearer box, the wapbox must be started. Start it by typing the following command: ./wapbox -v 1 <conf_file> .

For more command-line options, you must review the Kannel User Guide.


Administering the gateway through an HTTP interface

Kannel can be administered via an HTTP interface. All commands are given as normal HTTP queries, so they can easily be given from command lines like this one:


% lynx -dump http://localhost:12345/shutdown?password=bar

In the command above, "12345" is set as the admin-port in the configuration file. For most commands, an admin-password is required as an argument as shown here. Shutdown is for shutting down the gateway. The other commands available are:

  • Status, to get the current status of the gateway. No password is required if status-password is not set.
  • Suspend, to set Kannel as suspended. A password is required.
  • Resume, to set the Kannel state as running. A password is required.

Testing with a WAP-enabled mobile phone simulator

I'll provide you with some simple steps with which to test the gateway and access the WML pages from the Internet through a mobile phone simulator. You need two machines, one running a Windows® operating system, and the other the Linux gateway, preferably connected through a LAN. The Linux machine must be connected to the Internet, either directly or indirectly.

  • You can use the Nokia 7210 Content Authoring SDK (see Resources), which is available for a Windows system.
  • Install it in a Windows system.
  • Do a little configuring and set the gateway address to the IP address of the Linux machine running the gateway.
  • Now type any Web site address serving WML pages from the simulator and you are done!

You must be able to access the pages and navigate through the simulator.


In conclusion

This project describes the most inexpensive and easiest method for building a WAP gateway -- one that can be customized to any extent.


Resources

About the author

The author is a software engineer at ConvergeLabs, and has been working in Linux for several years. His primary interests are C, wireless and Linux. He can be contacted at manasb@convergelabs.com

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=11398
ArticleTitle=Build a WAP gateway On Linux
publish-date=06082004
author1-email=manasb@convergelabs.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers