Design and Implementation of a WAP Gateway A

  • Slides: 45
Download presentation
Design and Implementation of a WAP Gateway A Master’s thesis by Lars Wirzenius CSCI

Design and Implementation of a WAP Gateway A Master’s thesis by Lars Wirzenius CSCI 5939. 02 – Independent study Fall 2002 Presented by: Obaidullah Khan 1

Chapter 1: Introduction w w Catching up with science fiction: Star treck, Imperial Earth

Chapter 1: Introduction w w Catching up with science fiction: Star treck, Imperial Earth Evolution of mobile phone, laptop, and then palmtops Vision of mobile phone as web browsers WAP technology enable mobile phone acts as hypertext browsers 2

What is covered in this master’s thesis w Kannel – an open source WAP

What is covered in this master’s thesis w Kannel – an open source WAP gateway n n Problems Design Technical issues Project management issues w Kannel project started in June 1999, by Wapit Ltd 3

Chapter 2: Problems in Implementing Services for Mobile Phones 4

Chapter 2: Problems in Implementing Services for Mobile Phones 4

Technical issues n n n Low battery capacity Small screen and keyboard Limited bandwidth

Technical issues n n n Low battery capacity Small screen and keyboard Limited bandwidth and high error rate 5

Business issues n n n Leverage on existing mobile phone networks Must be adaptable

Business issues n n n Leverage on existing mobile phone networks Must be adaptable to future mobile networks Standardized for interoperability and mass market Allows easy user interface Allow billing 6

Pre-WAP solution w Normal voice calls w Short textual messages (SMS) n n These

Pre-WAP solution w Normal voice calls w Short textual messages (SMS) n n These two works fine in current networks and billing infrastructure exists. Fetching normal HTTP pages on GSM phone – simply not feasible. 7

Chapter 3: The Wireless Application Protocol w History of WAP w The goals of

Chapter 3: The Wireless Application Protocol w History of WAP w The goals of WAP w Introduction to WML and WMLScript w Current status of WAP 8

WAP and WAP Forum w History n n n WAP Forum founded in June

WAP and WAP Forum w History n n n WAP Forum founded in June 1997 by Nokia, Ericsson, Motorola, and Unwired Planet 1. 0 specification in April 1998, but not implemented 1. 1 specification in July 1999, first to be implemented in phones 9

WAP and WAP Forum (cont’d) w Goals n n Develop an open, freely licensed

WAP and WAP Forum (cont’d) w Goals n n Develop an open, freely licensed specification The specification not tied to any network technology or any specific device 10

The WAP architecture Figure 3. 1. WAP architecture 11

The WAP architecture Figure 3. 1. WAP architecture 11

The WAP architecture (cont’d) w WAP Protocol n n In binary and compressed form

The WAP architecture (cont’d) w WAP Protocol n n In binary and compressed form Reduces the protocol overheads w WAP Gateway n n Protocol translation between phone and server Compresses WML pages to save bandwidth 12

WML and WMLScript w WML n n A simple mark up language defined in

WML and WMLScript w WML n n A simple mark up language defined in XML A page is a deck of cards w WMLScript n n n Based on ECMAScript or Java. Script Makes WAP more dynamic Provides libraries for controlling phone functionalities 13

WML and WMLScript (cont’d) WML pages at content server textual form Source code WAP

WML and WMLScript (cont’d) WML pages at content server textual form Source code WAP Gateway binary form Phone 14

The WAP protocol stack w Consist of three layers n n n Wireless Datagram

The WAP protocol stack w Consist of three layers n n n Wireless Datagram Protocol (WDP) Wireless Transaction Protocol (WTP) Wireless Session Protocol (WSP) 15

The WAP protocol stack (cont’d) Figure 3. 2. A representative WAP session 16

The WAP protocol stack (cont’d) Figure 3. 2. A representative WAP session 16

The duties of a WAP gateway w Implement WAP protocol stack w User authentication

The duties of a WAP gateway w Implement WAP protocol stack w User authentication and billing w Optimize WAP usage – keep cost down while utilizing bandwidth wisely 17

Chapter 4: The Kannel Open Source WAP Gateway This section covers the design and

Chapter 4: The Kannel Open Source WAP Gateway This section covers the design and implementation of Kannel WAP gateway 18

Introduction and status of the project w Why it was started? n Wapit needed

Introduction and status of the project w Why it was started? n Wapit needed a gateway w When? n July 1999 at WAP Forum in San Francisco 19

Introduction and status of the project (cont’d) w Goals? n n n A technically

Introduction and status of the project (cont’d) w Goals? n n n A technically good enough gateway for small operator / service providers Serve thousand of concurrent users at reasonable price Kannel to be a WAP gateway as well as an SMS gateway Be scalable Crash or failure of one node should not affect others 20

Gateway architecture w Discusses requirements w Division of gateway duties to processes - bearer,

Gateway architecture w Discusses requirements w Division of gateway duties to processes - bearer, wap, sms boxes w Duties of each process 21

Gateway architecture (cont’d) w External interface of the gateway n n n SMS center,

Gateway architecture (cont’d) w External interface of the gateway n n n SMS center, using various protocols HTTP servers, to fetch WAP / SMS content WAP phones, using WAP protocol stack Figure 4. 1. External interfaces of Kannel 22

Gateway architecture (cont’d) w SMS protocol essentials n n n Client logs into SMS

Gateway architecture (cont’d) w SMS protocol essentials n n n Client logs into SMS center sends a message as it arrives, client should acknowledge it Client send a request for message and SMS center acknowledge it When client is done, it logs out Only one connection to an account at a time 23

Gateway architecture (cont’d) w HTTP protocol essentials n n Client connect to server Client

Gateway architecture (cont’d) w HTTP protocol essentials n n Client connect to server Client sends a request Server respond and complete transaction Multiple request over same connection are possible 24

Gateway architecture (cont’d) w Achieve maximum throughput n n By Multitasking internally By using

Gateway architecture (cont’d) w Achieve maximum throughput n n By Multitasking internally By using internal queues w Reliability problem n What if Kannel crashes when there are request in internal queues? w Solution n Kannel should keep the lists on disc, but it does not do so 25

Gateway architecture (cont’d) w Division of duties to processes: the boxes n n n

Gateway architecture (cont’d) w Division of duties to processes: the boxes n n n The bearerbox: Implements the WDP layer, and connect to SMS center The smsbox: Implements the SMS gateway The wapbox: Implements the WAP stack 26

Gateway architecture (cont’d) Figure 4. 2. Boxes of Kannel n n n Only one

Gateway architecture (cont’d) Figure 4. 2. Boxes of Kannel n n n Only one bearerbox but multiple smsboxses & wapboxes Each box is internally multithreaded Static thread structure 27

Gateway architecture (cont’d) w Heartbeats n n Each box sends “I am still alive”

Gateway architecture (cont’d) w Heartbeats n n Each box sends “I am still alive” messages The bearerbox keeps track of heartbeats of all boxes Bearerbox closes connection, if heartbeat is not receives for long time Heartbeat serves as load factor, which helps bearerbox in routing packets among boxes 28

The Bearer Box w What it does? n n n Receives UDP messages from

The Bearer Box w What it does? n n n Receives UDP messages from phones Send these messages to wapboxes Receives reply from wapboxes Sends the UDP message back to phones Only UDP bearer for WDP is supported 29

The Bearer Box (cont’d) Figure 4. 3. Bearerbox architecture 30

The Bearer Box (cont’d) Figure 4. 3. Bearerbox architecture 30

The Bearer Box (cont’d) w Bearerbox routes the UDP packets to wapboxes w Phones

The Bearer Box (cont’d) w Bearerbox routes the UDP packets to wapboxes w Phones are allocated IP dynamically w All messages from same IP are sent to same wapbox w The bearerbox must know when a session or transaction finishes w Multiple queues within the bearerbox w Bearerbox balance the load among wapboxes using load factor 31

The WAP Box w What it does? n n n Wapbox reads messages from

The WAP Box w What it does? n n n Wapbox reads messages from bearerbox, maintains internal states for each client, and makes HTTP requests for clients Only WTP and WSP are implemented WTLS is not implemented in this thesis 32

The WAP Box (cont’d) Figure 4. 4. Wapbox thread structure 33

The WAP Box (cont’d) Figure 4. 4. Wapbox thread structure 33

The WAP Box (cont’d) w WAP protocol stack layer is implemented in its thread

The WAP Box (cont’d) w WAP protocol stack layer is implemented in its thread w Communication between threads is via message queues w Each layer exposes only event data structures: simplified code, execution is faster w Static thread structure: starts at program startup and keeps running w Each layer extracts the event, process it, and sends other events to other layers w Locking is needed only when accessing the event queue for each layer 34

Implementation of protocol state machine w WTP and WSP ( connection mode) are implemented

Implementation of protocol state machine w WTP and WSP ( connection mode) are implemented in term of state machine w Macro language ( the C processor) is used to describe state machine in source code 35

Efficient implementation of HTTP request w WAP gateway must implement HTTP request efficiently at

Efficient implementation of HTTP request w WAP gateway must implement HTTP request efficiently at high usage level w Implementing each HTTP request in a separate thread would be expensive w Implement HTTP as a static number of threads – for performance 36

Efficient implementation of HTTP request (cont’d) w Basic steps in HTTP request: n n

Efficient implementation of HTTP request (cont’d) w Basic steps in HTTP request: n n n IP number look-up for the HTTP server: delay in DNS query Open a TCP connection: may takes some time if network is congested or due to slow server Write the request: if the request is large it may takes more than one TCP packet Read the reply: it can takes several seconds Close the connection: this should be fast 37

Efficient implementation of HTTP request (cont’d) w More than one thread requires scheduling, and

Efficient implementation of HTTP request (cont’d) w More than one thread requires scheduling, and context switching at wake-up w Having one thread eliminate context switching overhead w Unix system call select and poll are used, in single thread mode, to wait for input from several sources 38

Efficient implementation of HTTP request (cont’d) w What a thread does? n n Wait

Efficient implementation of HTTP request (cont’d) w What a thread does? n n Wait until there is something to read Read it into a connection specific buffer If the buffer has a complete HTTP reply, return it to whoever made the request Repeat forever 39

Making concurrent domain name lookups w DNS maps textual domain name into IP number

Making concurrent domain name lookups w DNS maps textual domain name into IP number w Problem n The gethostbyname function in C does not support concurrency w Solution n Implement DNS protocol within gateway Or Run sub-processes to do gethostbyname calls Single calls at a time, but multiple sub-processes provides concurrency w Security risk 40

Converting WML and WMLScript to binary w Used two simple application of complier theory

Converting WML and WMLScript to binary w Used two simple application of complier theory for conversion to binary form w Compiler gets as input the WML source code and character set from HTTP header w Return a binary form of WML deck or error message w WML complier utilizes a string table to compress the output w WMLScript compiler parse the input, form a parse tree, optimize the tree, then generate byte code, and optimize again 41

Chapter 5: Experiences From this Implementation w Subjective evaluation n n First installation in

Chapter 5: Experiences From this Implementation w Subjective evaluation n n First installation in Sep. 1999, with some bugs to fix Fixing the bugs slowed the development but improved the quality Sufficient quality in order to succeed Setup a ‘nag’ script successfully: compile remotely and report errors to developers Automatic test cases, added later 42

Experiences From this Implementation (cont’d) w Effect of open source project n n n

Experiences From this Implementation (cont’d) w Effect of open source project n n n Ever changing group of developers More varied testing: more compatible More people doing debugging Simple source code and program structure More time spent on email communication 43

Chapter 6: Plans for the Future w New features n n n WAP security

Chapter 6: Plans for the Future w New features n n n WAP security layer (WTLS) WAP push technology Using SMS messages as a bearer for WAP 44

Plans for the Future (cont’d) w Better quality n n n Improved security, reliability,

Plans for the Future (cont’d) w Better quality n n n Improved security, reliability, and speed Over feeding of data causes it to run out of memory and crash Store SMS messages in persistent memory Should allow push feature Migrating job between SMS box or WAP box might improve performance 45