11a. Networking and Mobile Devices

31
Mobiiliohjelmointi Mobiiliohjelmointi Kevät 2009 Kevät 2009 1 11a. Networking and 11a. Networking and Mobile Devices Mobile Devices Introduction Introduction Problems Problems Patterns and considerations Patterns and considerations Sample techniques Sample techniques Mobile Java and web services Mobile Java and web services Symbian OS and Bluetooth Symbian OS and Bluetooth Maemo and WLAN Maemo and WLAN Summary Summary

description

11a. Networking and Mobile Devices. Introduction Problems Patterns and considerations Sample techniques Mobile Java and web services Symbian OS and Bluetooth Maemo and WLAN Summary. Introduction. Fundamentally, mobile devices liberate from the restrictions associated with a location - PowerPoint PPT Presentation

Transcript of 11a. Networking and Mobile Devices

Page 1: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

11

11a. Networking and Mobile 11a. Networking and Mobile DevicesDevices

• IntroductionIntroduction• ProblemsProblems• Patterns and considerationsPatterns and considerations• Sample techniquesSample techniques

– Mobile Java and web servicesMobile Java and web services– Symbian OS and BluetoothSymbian OS and Bluetooth– Maemo and WLANMaemo and WLAN

• SummarySummary

Page 2: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

22

IntroductionIntroduction• Fundamentally, mobile devices liberate from the restrictions Fundamentally, mobile devices liberate from the restrictions

associated with a locationassociated with a location– Physical distributionPhysical distribution

• Basic laws of distributed systems development applyBasic laws of distributed systems development apply• Can be taken as yet another resource whose accessing can be Can be taken as yet another resource whose accessing can be

slowerslower– E.g. memoryE.g. memory

• Special issuesSpecial issues– Basic connectivity; associated with numerous different technologiesBasic connectivity; associated with numerous different technologies

• Proxies, bridges, and gatewaysProxies, bridges, and gateways– Statefulness vs. statelessness; associated with restricted bandwidthStatefulness vs. statelessness; associated with restricted bandwidth

• Each station can have its own state vs. no stored stateEach station can have its own state vs. no stored state• Testing related complicationsTesting related complications• Stateless can implement stateful by carrying all state information in Stateless can implement stateful by carrying all state information in

transmissionstransmissions– Infrastructure assisted or ad-hoc between peers via e.g. Bluetooth Infrastructure assisted or ad-hoc between peers via e.g. Bluetooth

connectionconnection• Servers and registry components vs. dynamic service discovery and Servers and registry components vs. dynamic service discovery and

formationformation

Page 3: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

33

From Fixed to Wireless:From Fixed to Wireless:Proxy approachProxy approach

Station 1

Station 2

WirelessStation

Proxy

Fixeddomain

Wirelessdomain

Page 4: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

44

Example Proxy: Wireless CorbaExample Proxy: Wireless Corba

GIOP

GTP

Adaptationand

transport

object

Terminal

GTP

Adaptationand

transport

IIOP

TCP

GIOP

IIOP

TCP

objectCorba invocations

Access bridge Other ORBwireless fixed

Page 5: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

55

Example Proxy: WAPExample Proxy: WAP

WAP device

WAE

WSP

WTP

WTLS

WDP

Bearer

WAP gateway

WSP

WTP

WTLS

WDP

Bearer

Web server

WAE

HTTP

SSL

TCP

IP

HTTP

SSL

TCP

IP

Page 6: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

66

WAP Stack in DeviceWAP Stack in Device

Application layer: Wireless application environment (WAE)(includes WML and WMLScript)

Session layer: Wireless session protocol (WSP)

Transaction layer: Wireless transaction protocol (WTP)

Security layer: Wireless transport layer security (WTLS)

Transport layer: Wireless datagram protocol (WDP)

Bearers (SMS, CSD, GPRS,...)

byp

assing

app

s

Page 7: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

77

Content and goalsContent and goals

• IntroductionIntroduction• ProblemsProblems• Patterns and considerationsPatterns and considerations• Sample techniquesSample techniques

– Mobile Java and Web ServicesMobile Java and Web Services– Symbian OS and BluetoothSymbian OS and Bluetooth– Maemo and WLANMaemo and WLAN

• SummarySummary

Page 8: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

88

Special characteristics induce Special characteristics induce some fundamental problemssome fundamental problems

• Bandwidth restrictions (GPRS, WCDMA, WLAN, …)Bandwidth restrictions (GPRS, WCDMA, WLAN, …)• Communication packet travel timesCommunication packet travel times

– Different gateways etc. lead to an extended travel times in Different gateways etc. lead to an extended travel times in communicationcommunication

• Lack of an established specialized standardLack of an established specialized standard– Internet technologies copied, adapted, extended, etc.Internet technologies copied, adapted, extended, etc.– Telecommunications originated technologies evolving to different Telecommunications originated technologies evolving to different

directions, different contexts, and adapting properties from Internet directions, different contexts, and adapting properties from Internet communications communications

– Different devices implement a different set of features, so Different devices implement a different set of features, so implementing a system that works in all combinations is hardenedimplementing a system that works in all combinations is hardened

• Cost of connection and passing informationCost of connection and passing information– MoneyMoney– EnergyEnergy

• Service providers not interested in implementing numerous Service providers not interested in implementing numerous versions of the same serviceversions of the same service– Special tools for automatically configuring a serviceSpecial tools for automatically configuring a service

Page 9: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

99

Content and goalsContent and goals

• IntroductionIntroduction• ProblemsProblems• Patterns and considerationsPatterns and considerations• Sample techniquesSample techniques

– Mobile Java and Web ServicesMobile Java and Web Services– Symbian OS and BluetoothSymbian OS and Bluetooth– Maemo and WLANMaemo and WLAN

• SummarySummary

Page 10: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

1010

Restrictions and disclaimersRestrictions and disclaimers

• We will mostly be looking inside mobile devices, not We will mostly be looking inside mobile devices, not to to – Network architecturesNetwork architectures– Individual protocolsIndividual protocols– Related consequencesRelated consequences

• Optimizations that are only available for a device Optimizations that are only available for a device manufacturer (or its subcontractors) are overlookedmanufacturer (or its subcontractors) are overlooked– In other words, these should not be something whose use In other words, these should not be something whose use

can be restrictedcan be restricted

• Focus on what an application developer can do when Focus on what an application developer can do when composing a networking applicationcomposing a networking application

Page 11: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

1111

GoalsGoals

• Be prepared to hide long loading times; preserve the Be prepared to hide long loading times; preserve the feeling of being in control from the user’s perspectivefeeling of being in control from the user’s perspective– Proactiveness when applicableProactiveness when applicable

• Take into account adaptation needs associated with Take into account adaptation needs associated with the facilities of a particular devicethe facilities of a particular device– Installation base?Installation base?

• Always let the user know what is taking place Always let the user know what is taking place regarding communicationsregarding communications– Cost, no response, etc.Cost, no response, etc.

• Fail with style!Fail with style!

Page 12: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

1212

Design idioms and patternsDesign idioms and patterns

• Use a networking wrapper that can be reimplemented Use a networking wrapper that can be reimplemented if communication techniques/requirements changeif communication techniques/requirements change– Porting requirementsPorting requirements

• Treat networking features as yet another resourceTreat networking features as yet another resource– Resource management and explict allocationResource management and explict allocation– May not be always available, so certain dynamic May not be always available, so certain dynamic

characteristics must be built incharacteristics must be built in• Allocate responsibility for networking operations to a Allocate responsibility for networking operations to a

some particular unit of the systemsome particular unit of the system– Async networking library may do this for you automaticallyAsync networking library may do this for you automatically– Manually: One thread for the network, one for UIManually: One thread for the network, one for UI

• Stateless vs. stateful applicationsStateless vs. stateful applications– Often predetermined by the requirements that originate from Often predetermined by the requirements that originate from

assumed user groupassumed user group

Page 13: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

1313

ConsiderationsConsiderations

• Telephony or data communications?Telephony or data communications?– TelephonyTelephony

• SMS, MMSSMS, MMS• Commonly rapid connections (something may be taking place Commonly rapid connections (something may be taking place

behind the curtains however)behind the curtains however)• Network push is okNetwork push is ok

– Data communicationsData communications• GPRS, 3G, WLANGPRS, 3G, WLAN• Long connection timeLong connection time• How to make a network initated operation?How to make a network initated operation?

• Push or pull?Push or pull?• Connection speed?Connection speed?• Cost?Cost?

Page 14: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

1414

Content and goalsContent and goals

• IntroductionIntroduction• ProblemsProblems• Patterns and considerationsPatterns and considerations• Sample techniquesSample techniques

– Mobile Java and web servicesMobile Java and web services– Symbian OS and BluetoothSymbian OS and Bluetooth– Maemo and WLANMaemo and WLAN

• SummarySummary

Page 15: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

1515

Web Services OverviewWeb Services Overview

device

UDDI

Web service

servicelookup

WSDL

servicedescription

serviceuse

Page 16: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

1616

Web Service (Cont’d)Web Service (Cont’d)

• Application modelApplication model– No particular model; offers independent servicesNo particular model; offers independent services

• Finding web servicesFinding web services– UDDIUDDI– WS Dynamic DiscoveryWS Dynamic Discovery

• Service useService use– Acts as a service, not as an objectActs as a service, not as an object

• BearersBearers– SOAPSOAP– Fundamentally bearer independent, practical Fundamentally bearer independent, practical

implementations commonly use HTTPimplementations commonly use HTTP

Page 17: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

1717

MIDP Java and Web ServicesMIDP Java and Web Services

LocalApplication

Stub

Service ProviderInterface

Local Client

1

2

3

4 NetworkDevice

RemoteServices

1. Application calls stub2. Stub calls WB via SPI3. SPI opens a connection to remote WS4. Remote computer serves the request

Page 18: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

1818

APIs and ToolsAPIs and Tools

• Java API for XML processing (JAXP)Java API for XML processing (JAXP)– Non-validating parser intended to parse incoming Non-validating parser intended to parse incoming

XML documentsXML documents

• Java API for XML-based RPC (JAX-RPC)Java API for XML-based RPC (JAX-RPC)– Implementation of RPCImplementation of RPC

• Service Provider Interface (SPI)Service Provider Interface (SPI)– Stub generation in a compatible fashionStub generation in a compatible fashion

• Stub GeneratorStub Generator– Generation of client-side proxy that can be called Generation of client-side proxy that can be called

by the application to make calls to WSby the application to make calls to WS

Page 19: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

1919

ArchitectureArchitecture

<<interface>>java.rmi.Remote

<<interface>>Service Interface

<<interface>>javax.xml.rpc.Stub

<<interface>>java.rmi.Remote

<<interface>>Service Interface

Stub

Application

javax.microedition.xml.rpc.*

javax.xml.rpc.JAXRPCException

javax.xml.namespace.QName

Vendor-specific JAX-RPC classes

Page 20: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

2020

Content and goalsContent and goals

• IntroductionIntroduction• ProblemsProblems• Patterns and considerationsPatterns and considerations• Sample techniquesSample techniques

– Mobile Java and web servicesMobile Java and web services– Symbian OS and Bluetooth Symbian OS and Bluetooth – Maemo and WLANMaemo and WLAN

• SummarySummary

Page 21: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

2121

Bluetooth ArchitectureBluetooth Architecture

Physical connection (USB/UART/I2C...)

BT HWHost Controller Interface Driver

Baseband controller

Link manager

BT HOST (Laptop, MCU)

L2CAP

Host Controller Interface Driver

RFCOMM SDP

app1

app2

PPP

UDP/TCPIP

Page 22: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

2222

Bluetooth (Cont’d)Bluetooth (Cont’d)

• Application modelApplication model– No particular model; offers independent servicesNo particular model; offers independent services– Bluetooth profiles define different applicationsBluetooth profiles define different applications

• Finding BT servicesFinding BT services– SDPSDP

• Service useService use– RFCOMM, serial port emulating protocol, can be used as a RFCOMM, serial port emulating protocol, can be used as a

bearer for more complex protocolsbearer for more complex protocols– Other protocols for using certain standardized services (e.g. Other protocols for using certain standardized services (e.g.

OBEX)OBEX)

• BearersBearers– Own radio technology (frequency 2,4000-2,4835GHz)Own radio technology (frequency 2,4000-2,4835GHz)

Page 23: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

2323

Symbian Bluetooth FacilitiesSymbian Bluetooth Facilities

• Service DatabaseService Database– Hosts information that can be used by other devicesHosts information that can be used by other devices– Used via Database Server API (RSdp), actual database Used via Database Server API (RSdp), actual database

characterized by RSdpDatabasecharacterized by RSdpDatabase

• Service discoveryService discovery– Used to find devices, services and service attributesUsed to find devices, services and service attributes– Discovery agent (CSdpAgent) for configuring and starting Discovery agent (CSdpAgent) for configuring and starting

the searchthe search– Notifier interface (MSdpAgentNotifier) for callbacksNotifier interface (MSdpAgentNotifier) for callbacks

• Service useService use– E.g. socket communicationE.g. socket communication

Page 24: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

2424

CBTApp RSdp RSpdDatabase

Connect()

Open()

CreateServiceRecordL()

UpdateAttributeL()

UpdateAttributeL()

UpdateAttributeL()

UpdateAttributeL()

Service record creationService record creation

Page 25: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

2525

Framework CBTApp CSdpAgent

NewL()

SetRecordFilterL()

ListServicesL()

NextRecordRequestL()NextRecordRequestComplete()

AttributeRequestL()AttributeRequestResult()

AttributeRequestComplete()NextRecordRequestL()

. . .

Bluetooth service discoveryBluetooth service discovery

Page 26: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

2626

Content and goalsContent and goals

• IntroductionIntroduction• ProblemsProblems• Patterns and considerationsPatterns and considerations• Sample techniquesSample techniques

– Mobile Java and Web ServicesMobile Java and Web Services– Symbian OS and BluetoothSymbian OS and Bluetooth– Maemo and WLANMaemo and WLAN

• SummarySummary

Page 27: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

2727

InfrastructureInfrastructure

• When active WLAN is visible to apps as When active WLAN is visible to apps as network accessnetwork access– No need for further complications when the No need for further complications when the

system is up and runningsystem is up and running– Selection of the framework and actions taken Selection of the framework and actions taken

when something changes to be definedwhen something changes to be defined

• Framework for selecting the correct network Framework for selecting the correct network and managing the existence of the accessand managing the existence of the access

Page 28: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

2828

On Connection EventOn Connection Event

// Define events that will occur as changes occur in networking conditions. // Define events that will occur as changes occur in networking conditions. static void on_connection_event(ConIcConnection *connection,static void on_connection_event(ConIcConnection *connection,

ConIcConnectionEvent *event,ConIcConnectionEvent *event,gpointer user_data) gpointer user_data)

{{

switch(con_ic_connection_event_get_status(event)) {switch(con_ic_connection_event_get_status(event)) { case CON_IC_STATUS_CONNECTED:case CON_IC_STATUS_CONNECTED: connected = TRUE;connected = TRUE; break;break; case CON_IC_STATUS_DISCONNECTED:case CON_IC_STATUS_DISCONNECTED: case CON_IC_STATUS_DISCONNECTING:case CON_IC_STATUS_DISCONNECTING: default:default: connected = FALSE;connected = FALSE; break;break; }}}}

Page 29: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

2929

Initialize networkingInitialize networking// Initializes networking functionality. If a non-zero value is returned, the// Initializes networking functionality. If a non-zero value is returned, the// operation is considered successfull, otherwise a failure is assumed.// operation is considered successfull, otherwise a failure is assumed.ConIcConnection * InitializeNetworking() {ConIcConnection * InitializeNetworking() {

ConIcConnection *myConnection = con_ic_connection_new();ConIcConnection *myConnection = con_ic_connection_new(); if(myConnection) {if(myConnection) {

g_signal_connect(G_OBJECT (myConnection), g_signal_connect(G_OBJECT (myConnection), "connection-event","connection-event", G_CALLBACK (on_connection_event),G_CALLBACK (on_connection_event), NULL);NULL);

g_object_set(myConnection, "automatic-connection-events", TRUE, NULL);g_object_set(myConnection, "automatic-connection-events", TRUE, NULL); con_ic_connection_connect(myConnection,CON_IC_CONNECT_FLAG_NONE);con_ic_connection_connect(myConnection,CON_IC_CONNECT_FLAG_NONE); }} return myConnection; // The return value is simply used as a boolean value.return myConnection; // The return value is simply used as a boolean value.}}

Page 30: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

3030

Content and goalsContent and goals

• IntroductionIntroduction• ProblemsProblems• Patterns and considerationsPatterns and considerations• Sample techniquesSample techniques

– Mobile Java and Web ServicesMobile Java and Web Services– Symbian OS and BluetoothSymbian OS and Bluetooth– Maemo and WLANMaemo and WLAN

• SummarySummary

Page 31: 11a. Networking and Mobile Devices

MobiiliohjelmointiMobiiliohjelmointiKevät 2009Kevät 2009

3131

SummarySummary

• Network resources form yet another layer of Network resources form yet another layer of facilities and resources for applicationsfacilities and resources for applications– Longish travel-through timesLongish travel-through times– Restricted support for handovers can sometimes Restricted support for handovers can sometimes

cause problems (e.g. IP address change)cause problems (e.g. IP address change)– Firewalls, etc.Firewalls, etc.

• Number of design patterns that apply to the Number of design patterns that apply to the design of the applications relying on the use design of the applications relying on the use of networkof network– Interactivity is a key goal!Interactivity is a key goal!