presentation

Download Report

Transcript presentation

INF245 Mobile Applications
Networking
H 2007
Ola Bø
Molde University College INF 245 Fall 2007
OBø
1
Introduction

Connection to the wired internet is gaining
interest




Access to mobile content
Augments computing and storage capacities
Local applications are less attractive
Pan networking may also be interesting


What for?
Viruses?
Molde University College INF 245 Fall 2007
OBø
2
Challenges








Intermittent connections
Low bitrate
Inpredictable bitrate
Considerable latency
Price
Need for offline operation
Limited support for
protocols
Finding device TCPIP


No fixed TCP/IP?
Now way to ask for own IP
address using J2ME


Communications uses
battery
A range of WWAN data
bearer technologies







WAP data calls
GPRS
EDGE
3G
WLAN is also a bearer
BT may also be a bearer
Bearer independence a
good idea
Molde University College INF 245 Fall 2007
OBø
3
Architectural choices
(source Tommi Mikkonen 2007)

Infrastructure network
WAP
 HTTP
Server/device work
distribution?

Peer to peer network



Registering the device?
BT
Self organizing,
decentralized and
dynamic




Support for standard
services part of device
preinstalled service
Custom services offered
by device may be
developed
Molde University College INF 245 Fall 2007
OBø
4
Architectural choices

Push vs pull

Pull is initiated by the device




To know that a message from the network is waiting
you have to poll – send periodic messages asking if
new message to fetch –
consumes battery and bandwith - money
Traditional solution on the internet
Push is initiated by the network

Traditional solution in telecoms
Molde University College INF 245 Fall 2007
OBø
5
Statefull and stateless
systems (source Tommi Mikkonen 2007)




Stateful systems remember
past operations and internal
state – supports a session –
a series of related
operations
More complex
HTTP statefullness can be
implemented using cookies
or hidden fields
With .net and jsp/servlet
technology statefullness is
easily implemented using a
session construct

Stateless systems
generates output based on
input not dependent on
previous communications

HTTP is stateless
Molde University College INF 245 Fall 2007
OBø
6
MIDP 1.0 Communication

Device must implement
a HTTP 1.1 client
interface
 Transport is not
necessarily over
TCP/IP

Other protocols may be
supported in MIDP 1.0

The use of other
protocols is transparent
to the programmer
Molde University College INF 245 Fall 2007
OBø
7
Networking using GCF

Need a more compact solution, than the standard libraries

GCF: General Connection Framework is the answer

In GCF all protocols can be specified using an URL-approach:
Connector.open("<protocol>://<address>:<parameters>")


But no network protocol is mandatory in CLDC
What protocol can actually be used depend on the device and
the profile
Examples

Connector.open("http://www.sis.pitt.edu/mwap/test.html")
Connector.open("file://pictures/picture12.jpg")
Connector.open("comm://9600:18N")
Molde University College INF 245 Fall 2007
OBø
8
The Generic Connection
Framework
Connection is made by calling a static method in
javax.microediton.io.Connector
 Parameter is a Connection String



Example: http://gjedde.himolde.no/karpefisk.png
<scheme>:
Return value is an implementation of an interface
Molde University College INF 245 Fall 2007
OBø
9
javax.microedition.io.Connector
Molde University College INF 245 Fall 2007
OBø
10
HTTP-Connection

HTTP 1.1 only protocol with mandatory
support in MIDP 1.0 – why?



HTTP normally used between server and webbrowser to transport HTML and HTML form-data



Less problems with firewalls blocking protocol
Supported by web-servers
But HTTP is really a protocol for file transfer
To leverage existing support in web-servers, emulating the
server-browser exchange may be a good idea
Only a subset of HTTP 1.1 supported


GET, POST, HEAD
In MIDP 2.0 HTTPS also mandatory
Molde University College INF 245 Fall 2007
OBø
11
HTTP-Review
–
HTTP is a requestresponse protocol
–
Phases
●
●
●
●
Setup: Request header
and body information is
assembled
Connected: Request is
sent and response
possibly received
Response header and
body information may be
read
Closed
Molde University College INF 245 Fall 2007
OBø
12
HTTP Parameters and methods


Clients can send parameters to servers
Parameters are name=value


Parameters are coded




space is converted to +
a-z, A-Z, 0-9, .-*_ is unchanged
all other characters is converted into %xy, where xy is
hexadecimal
Method can be




f. example: code=in932&name=mobile+wireless+apps
GET -fetch a given document, parameters added to URL
POST -fetch a given document, parameters sent in message
body
HEAD - like GET but only header of response is returned
Demo of HTML-form
Molde University College INF 245 Fall 2007
OBø
13
Making a Connection with
HTTP-Get
1. Use Connector Open with the URL
2. Use the returned HTTPConnection as an
InputConnection to read the data
 Parameters must be encoded and added to
the URL


http://gjedde.himolde.no/example?name=Peter+S
mart&address=2323+Idea+drive
http://gjedde.himolde.no/example?name=Daniel+
Düsentrieb&address=2323+Idea+drive
Molde University College INF 245 Fall 2007
OBø
14
Sample code


Purpose: fetch and display a text from a
server
Midlet with life-cycle methods


Instantiates and displays a form
Form HTTP-communication



Commands to Connect and Exit
Items Gauge and StringItem
Thread for communication
Molde University College INF 245 Fall 2007
OBø
15
Molde University College INF 245 Fall 2007
OBø
16
Molde University College INF 245 Fall 2007
OBø
17
Molde University College INF 245 Fall 2007
OBø
18
More advanced techniques

Passing parameters


Implementing statefulness using Cookies


See Li and Knudsen pp149-152
See Li and Knudsen pp 152-157
Registering for PUSH notifications

See Li and Knudsen pp 160-163
Molde University College INF 245 Fall 2007
OBø
19
JSR172 MIDP Java and Web
Services (source Tommi Mikkonen 2007)





The basis of many networking
applications on the Internet
Client/Server Infrastructure
based networking technology
Service is described using
Web Service Description
Language (WSDL) and
accessed using Simple Object
Access Protocol (SOAP) over
HTTP.
SOAP Request and response
are encoded in XML
Stub, Service Provider
Interface and Local Client are
implemented from the web
service description using tools
Molde University College INF 245 Fall 2007
OBø
1.
2.
3.
4.
ordinary method call
Stub calls via platform
independent interface
SPI calls local Client
Local client calls
remote service using
SOAP
20
JSR82 Java API for Bluetooth
Wireless Technology (JABWT)

Two different APIs

Java API for Bluetooth
 Access to PAN Networking
 Discovering other bluetooth
devices
 Discovering the services other
devices has to offer
 Using and offering bluetooth
services

Java API for OBEX (Object
Exchange)
 Can be implemented using IR,
Bluetooth, IP, ..
 Can be used to exchange contact
information vCard, scheduling
vCalendar, ...
 Protocol similar to HTTP
Source Li and Knudsen (2005) ch 12.
Molde University College INF 245 Fall 2007
OBø
21
Midlet that can discover and
find the services of bt-devices
Molde University College INF 245 Fall 2007
OBø
22
The code for the whole MIDlet is available on kursinfo in the code subfolder
Molde University College INF 245 Fall 2007
OBø
23
References



Mikkonen, Tommi (2007) Programming
Mobile Devices – An Introduction for
Practitioners, Wiley ISBN 978-0-470-05738-4
JSR 118 Expert Group. (2006) Mobile
Information Device Profile for Java™ 2 Micro
Edition Version 2.1
Li and Knudsen (2005) Beginning J2ME
From Novice to Professional
Molde University College INF 245 Fall 2007
OBø
24