Article title: Tutorial: Build a WAP gateway on Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The most popular technology for implementing mobile services is Wireless Application Protocol (WAP ). The open-source gateway for WAP implements protocol conversion between Web servers and mobile phones. This article discusses its advantages.
The working principle of the WAP gateway is to use the most optimized markup language, scripting language, and transmission protocol for wireless over-the-air, make the phone a simple Web browser. It uses the WAP protocol stack to communicate with the phone and converts the requests it receives to common HTTP. In this way, content providers can use any HTTP server and use existing knowledge about HTTP service implementation and management.
In addition to protocol conversion, the Gateway also compresses the WML (Wireless Markup Language, Wireless Markup Language) page into a more compact format, which saves bandwidth in the air, and further reduced the demand for telephone processing. It also compiles the WMLScript program into the byte code format.
There are multiple available commercial WAP gateways on the market, which are expensive. On the other hand, Kannel is an open-source gateway. you do not need to pay for it. you can edit the source code and create your own custom gateway. Because Kannel is developed on Linux (RedHat and Debian), it can be smoothly transplanted to other UNIX-like operating systems. However, in this article, I only show how to build a gateway on these two Linux systems.
Kannel gateway architecture The Gateway divides the processing workload into the following two locations:
Bearer box connects to the SMS (Short Message Service) Center and CSD (circuit switching number) router, providing a unified interface for wapbox. The Messenger unit completes this work by implementing the WDP (Wireless Datagram Protocol (WDP) layer of the WAP stack.
The higher layer in the wapbox and WAP stack is located in this unit. Each session and its transactions are processed by the same wapbox.
How the system works
The Messenger unit receives UDP (User Datagram Protocol) packets from the CSD router, checks whether they are WAP packets, and routes them to the WAP unit. This simple design minimizes the processing of each packet by the Messenger unit. The Messenger unit also sends UDP data packets generated by other units, which adds some route processing. Wapbox implements the WTP (Wireless transfer Protocol, Wireless Transaction Protocol) and WSP (Wireless Session Protocol, Wireless Session Protocol) layers. They get requests similar to HTTP from the phone, send real HTTP requests to the content server, compress the response, and send them back to the terminal. (The session is maintained to limit the wireless bandwidth as much as possible .)
Basic software and hardware requirements Before creating a gateway, you must have the following basic conditions:
C compiler (CC or GCC), development library and related tools
Gnome XML Library (also called gnome-xml and libxml), version 2.2.5 or updated
GNU Make
Posix Thread Library (pthread. h)
Build a Gateway There are two ways to build a gateway. The first way is to obtain the source code, compile and install it on your own. The second approach is to get the pre-compiled binary RPM (RedHat Package Manager) and install it. RPM is a program designed to compile and manage source code and binary software packages. It is also portable and can run on different platforms.
First, you need to download the Kannel source code from the Kannel Web site for installation. After the download is complete, enter the following command in the command line to compile the source code:
./Configure
Make
Ideally, you can compile the code without any problem. If all the databases mentioned above exist, compilation is very easy. To install the gateway, enter the following command: make bindir =/usr/local/bin install.
You can replace the/usr/local/bin directory with any path to which the Gateway will be installed. The Gateway has been installed on your system. The executable file can now be found in the/gw Directory, named bearerbox and wapbox.
Install pre-compiled binary Run the following command to check whether the libxml2 XML Library is installed in your system: rpm-q libxml2.
This XML Library is required to install and compile the gateway. Download the binary RPM file of Kannel from the website. Log on as root and enter the following command for installation. If you have sufficient permissions, you may not need to enter the superuser mode.
Rpm-ihv kannel_VERSION.i386.rpm
This completes the installation. The _ VERSION attribute is the number of Kannel binary versions.
Use gateway Now we will study the basic steps to use and test the gateway using a mobile phone simulator that supports WAP. Essentially, you will involve bearerbox and wapbox (the executable file you just created ).
Configure Gateway Bearerbox and wapbox are the main modules of the Gateway and must be configured before configuring the gateway. These two modules are controlled by a configuration file, including the wapbox group and bearerbox group.
The configuration file consists of configuration variables. Groups are separated by empty rows, and each variable is defined in its own row (each group in the Kannel configuration is identified by the group variable ). The line starting with # is a comment and should be ignored.
A variable definition includes the variable name, equal sign (=), and variable value. Variable names can contain any character except spaces and equal signs. The value of a variable is a string that can be enclosed in quotation marks or without quotation marks. If the variable starts or ends with a space or contains special characters, use quotation marks. The normal C escape character is valid in quotation marks.
Use the configuration file I have referenced an example of a configuration file for this project. it is the basic file required for running the gateway. However, there are a series of other variables that can be used to control the gateway. You can refer to the Kannel User Guide to learn about them.
List 1. Sample gateway configuration file
# The sample. conf file which is the core configuration file
# For running the WAP Gateway
# Start of Configuration File
# 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
Measure the test taker's understanding about the attributes in the configuration file. The group contains the ID of the group associated with it. If the ID is core, it is the bearbox configuration. In addition, the wapbox ID represents the wapbox configuration. The admin-port Identifier specifies the port through which HTTP management is completed. Other attributes of bearerbox and wapbox are described in table 2 and Table 3. The required fields are represented by m, the o field is an optional field, and the c field is a conditional field.
Table 1. bearerbox configuration file attribute variable value description
Table 2. wapbox configuration file attributes
Start Gateway Once the Kannel is compiled and the configuration file is edited according to your specifications, you can proceed to the last step. For basic work, you can copy and paste the text in listing 1, save it with any name, and use it as your configuration file. To start the gateway, you must first start bearerbox and then start wapbox. Bearerbox is the basic part of the Gateway and must be started first.
Run the following command to start bearerbox:./bearerbox-v 1.
-V 1 sets the log level to INFO. With this option, you will not see a lot of debugging output (the default is DEBUG), and conf_file is the name of the configuration file used by your Kannel. The basic release package comes with the sample configuration file wapkannel. conf (in the/gw subdirectory) for building WAP Kannel. You can edit the configuration files to build your own specialized systems. After sending a cell, you must start wapbox. Run the following command to start it:./wapbox-v 1.
To learn more about the command line options, you must review the Kannel User Guide.
Manage the gateway through an HTTP interface You can use an HTTP interface to manage Kannel. All commands are provided as HTTP requests, so you can easily give them through the command line. for example, this one:
% Lynx-dump http: // localhost: 12345/shutdown? Password = bar
In the preceding command, "12345" is the admin-port set in the configuration file. For most commands, an admin-password is required as the parameter, as shown in. Shutdown is used to disable the gateway. Other available commands are:
Status to obtain the current Status of the Gateway. If status-password is not set, no password is required.
Suspend, set the Kannel to the suspended state. A password is required.
Resume, set the status of the Kannel to run. A password is required.
Test with a mobile phone simulator that supports WAP
I will provide some simple steps to test the gateway through the mobile phone simulator and access the WML page from the Internet. You need to have two machines, one running the Windows operating system and the other running the Linux gateway. it is best to connect them with a LAN. Linux machines must be connected to the Internet, either directly or indirectly.
You can use the Nokia 7210 Content Authoring SDK, which can be used in Windows.
Install it in the Window system.
Make some small configurations and set the Gateway address to the IP address of the Linux machine running the gateway.
Enter the Web site address that provides the WML page service in the simulator!
You can
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.