Chinaunix首页 | 论坛 | 博客
  • 博客访问: 604753
  • 博文数量: 263
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 2555
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-26 11:20
文章分类

全部博文(263)

文章存档

2011年(10)

2010年(19)

2009年(170)

2008年(64)

我的朋友

分类: 系统运维

2011-05-09 17:25:52

Build a WAP gateway On Linux

Basic steps for setting up a WAP gateway

Manas Behera (), Software engineer, ConvergeLabs Software Technologies

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

Comments:   0 (View | Add comment - Sign in)

Average rating 4 stars based on 35 votes Average rating (35 votes)
Rate this article

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.

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.

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.)

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)

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.

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.

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).

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.

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.



#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

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.



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.


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.

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 .

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 ), 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 .

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

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

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.

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.

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


  • Explore for all information on the open source WAP gateway.

  • Read through the to find out more about the RedHat Package Manager.

  • The RPM HOWTO provides more information on .

  • You can find the Gnome XML library at the .

  • Find more resources for Linux developers in the Linux technology zone.

  • You can use the , which is downloadable and available in a Windows format.

  • Browse for books on these and other technical topics.

  • Visit the for all the details on WAP Technology.

  • Get familiar with the various .
阅读(514) | 评论(0) | 转发(0) |
0

上一篇:Install Kannel SMS gateway in Centos 5

下一篇:没有了

给主人留下些什么吧!~~