01.01.2015 Views

Device

Device

Device

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Ubiquitous Computing

Dynamic service architectures

Olivier Liechti

University of Applied Sciences of Western Switzerland (HEIG-VD)

Summer 2007


Agenda

> The problem

– Dynamic service discovery

> Approach 1: mobile data (UPnP)

– Overview & concepts

– Examples

– Getting started with UPnP

> Approach 2: mobile code (Jini)

– Overview & concepts

– Examples

– Getting started with Jini


The Problem


Ubiquitous computing & dynamic services

> The environment is dynamic

– As people move in the physical world, they encounter all sorts of devices.

– While they doe not know these devices beforehand, they should be able to

interact with them.

Devices that happen to be at the same location should be able to interact

with each other. (discovery, self description, interoperability, etc.)

> The environment is full of service producers and service consumers

– Many devices provide services (printer, lamp, television set, etc.).

– Many devices offer a an interface to access services

– Some services are "close", others are "far away"

> Question

– What kind of software infrastructure (middleware & protocols) do we need to

realize this vision


Mobile data with UPnP


What is Universal Plug and Play Technology

> Provides invisible home networking

> Architectural framework for self-configuring, self-describing devices

– Leverages existing Internet technologies

– Enables dynamic peer-to-peer networking

> Key to making the connected home experience

– Affordable, mainstream reality for users

– Significant opportunity for the industry

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


UPnP Audio & Video Example

CDs, DVDs, Flash Cards

1. Discovery of devices and services

2. Browsing of content

3. Selection of streaming protocols

4. Streaming and Playback (out of band*)

TV

Picture Frame

Internet

Content



Local

Content

End User Benefits:





Media Server

Discover A/V content on all UPnP devices and PCs and share across home network

Stream content easily from any device to any device on home network

Control point offers rich, easy to use interface for creating and managing media

Supports DVD, CD, play list, photo album, live broadcast, etc

Manufacturer and Service Provider Benefits:



UPnP devices added to

network and discovers

media content

Stereo

Remote

Control

Highly extensible – any data type, any transfer protocol, any combination of server, render,

and control point

Highly scalable – ultra low resource devices (cameras, EPF) up to high-end servers (PCs,

media servers, Internet, broadcasts, PVR).

* Out of band = not UPnP Constrained


UPnP Imaging Example

Plug Printer/Scanner

directly into any available

network port

Imaging devices are

discovered and can

immediately be used (no

drivers or setup needed)

UPnP Network



End User Benefits



No need to install or share printer on the PC or and manually connect all devices to the

network (no networking knowledge needed)

Automatically discover printer/scanner and no need to search for new imaging devices

added to the network.

Manufacturer and Retailer Benefits



WiFi (802.11b)

New wireless devices

enter network and have

instant access to

printer/scanner

Reduce customer and service support with driver questions and how to network printer

on home network

Ability to print and scan from an extended range of devices not support previously

(Pocket PCs, Cell Phones, Web Tablets)


UPnP Automation Example

HVAC Unit

Thermostat

Synchronize temperature settings

with Outlook, the Internet (a weather

web site) or other UPnP devices

(UPnP alarm clock)

UPnP Network



End User Benefits





Customizable and easy control of heating, venting, AC unit, motion sensors, lighting and

security (personal environment presets)

Save money on energy bills (set temperature automatically from occupancy or depending on

outside temperature)

Synchronize home settings with PC programs (Outlook calendar, Internet weather)

Enable secure remote access into the home via the Internet and control UPnP devices.

Manufacturer and Retailer Benefits



UPnP bridge

connects non-UPnP

devices to network

Use wireless device

(Pocket PC) to control

HVAC system from

anywhere in the home

UPnP enabled automation systems add much more functionality over existing proprietary

control panels (more desirable over existing technology)

New opportunities for manufacturers to extend additional features available to the PC, Internet,

or other devices (more revenue with new business models, software and service offerings)


UPnP Control Point vs. Device


Three Classes of UPnP Entity



User Control Point

Controlled Device

Non-UPnP

Device

● Bridge Controlled

User Control

Point

Device

• User Control Point

• Controlled Device

• Bridge

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


UPnP Strategy

> Just send data over the network

– No executables

– Minimize version issues

– Minimize security issues

> Agree on meaning / format of data

– Choose substrate of proven protocols

– Define device (service) specific protocols in a Forum

> Allows implementation to be platform & vendor specific

– Be agnostic about programming language, OS

– Update implementation without affecting interoperability

– Improve performance

– Reduce footprint

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


UPnP Tactics

> Start simple

– Build in only universal things that everybody needs (and can live with)

– Add as needed

> Minimize requirements

– Basic IP network connectivity

– Common HTTP protocol stack

> Leverage existing standards

– HTTP, XML

http://www.upnp.org/download/

UPnP_Device_Architecture_Generic_20000710.ppt


Devices, services & control points

> Describe the protocols for communication

between

– Control points

Devices & services

> One device may offer several services.

> The same hardware component may be at

the same time a Control Point and a Device.

Control Point

Device

Service

Control Point

Device

Service

http://www.upnp.org/download/

UPnP_Device_Architecture_Generic_20000710.ppt


Steps to UPnP Networking

0 Addressing

3 Control

2 Description

1 Discovery

4 Eventing

5 Presentation

0 Control point and device obtain an address to participate in the network

1 Control point finds all devices and device advertises its availability

2 Control point learns about device capabilities

3 Control point invokes actions on device

4 Control point listens to state changes of device

5 Control point controls device and/or views device status using an HTML UI

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Discovery: SSDP

1 Discovery

0 Addressing

3 Control

2 Description

4 Eventing

5 Presentation

UPnP Network

Search

Request

Device

Reply

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Discovery: SSDP

1 Discovery

0 Addressing

3 Control

2 Description

4 Eventing

5 Presentation

UPnP Network

Device

Advertisement

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Discovery: SSDP Sidebar

> What is SSDP

– IETF Draft Simple Service Discovery Protocol

> Key design principles

– Administratively-scoped multicast

– Unicast responses

– UDP

– Very simple advertisements

– Very simple search

http://www.upnp.org/download/

UPnP_Device_Architecture_Generic_20000710.ppt


Discovery: Advertising

> Who Device multicasts

> When Added or refresh (cf. lease)

> What

NOTIFY * HTTP/1.1

HOST: 239.255.255.250:1900

CACHE-CONTROL: max-age = seconds until advertisement expires

LOCATION: URL for UPnP description for root device

NT: search target

NTS: ssdp:alive

USN: advertisement UUID

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Discovery: Searching

> Who Control point multicasts

> When Looking for device or service

> What

M-SEARCH * HTTP/1.1

HOST: 239.255.255.250:1900

MAN: "ssdp:discover"

MX: seconds to delay response

ST: search target

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Discovery: Responding

> Who Device unicasts

> When If ST matches an NT

> What

HTTP/1.1 200 OK

CACHE-CONTROL: max-age = seconds until advertisement expires

LOCATION: URL for UPnP description for root device

ST: search target

USN: advertisement UUID

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Description: XML

1 Discovery

0 Addressing

3 Control

2 Description

4 Eventing

5 Presentation

Device Description

XML Document

Get

Description

UPnP Network

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Description: Device (physical)



base URL for all relative URLs


short user-friendly title

manufacturer name

URL to manufacturer site

long user-friendly title

model name

model number

URL to model site

manufacturer's serial number

uuid:UUID

Universal Product Code

urn:schemas-upnp-org:device:deviceType



urn:schemas-upnp-org:service:serviceType:v

urn:upnp-org:serviceId:serviceID

URL to service description

URL for control

URL for eventing


Declarations for other services (if any) go here


Description of embedded devices (if any) go here



image/format

horizontal pixels

vertical pixels

color depth

URL to icon


XML to declare other icons, if any, go here


URL for presentation



1 0



Description: Device (logical)



base URL for all relative URLs


short user-friendly title

manufacturer name

URL to manufacturer site

long user-friendly title

model name

model number

URL to model site

manufacturer's serial number

uuid:UUID

Universal Product Code

urn:schemas-upnp-org:device:deviceType :v



urn:schemas-upnp-org:service:serviceType:v

urn:upnp-org:serviceId:serviceID

URL to service description

URL for control

URL for eventing


Declarations for other services (if any) go here


Description of embedded devices (if any) go here


image/format

horizontal pixels

vertical pixels

color depth

URL to icon


XML to declare other icons, if any, go here


URL for presentation



1 0



Description: Device (other)



base URL for all relative URLs


short user-friendly title

manufacturer name

URL to manufacturer site

long user-friendly title

model name

model number

URL to model site

manufacturer's serial number

uuid:UUID

Universal Product Code

urn:schemas-upnp-org:device:deviceType



urn:schemas-upnp-org:service:serviceType:v

urn:upnp-org:serviceId:serviceID

URL to service description

URL for control

URL for eventing


Declarations for other services (if any) go here


Description of embedded devices (if any) go here



image/format

horizontal pixels

vertical pixels

color depth

URL to icon


XML to declare other icons, if any, go here


URL for presentation



1 0



Description: Service (actions)





actionName



formalParameterName

in xor out


stateVariableName


Declarations for other arguments (if any) go here



Declarations for other actions (if any) go here




variableName

variable datatype

default value


minimum value

maximum value

increment value




variableName

variable data type

default value


some value

some value



Declarations for other state variables (if any) go here



1 0



Description: Service (state variables)





actionName



formalParameterName

in xor out


stateVariableName


Declarations for other arguments (if any) go here



Declarations for other actions (if any) go here




variableName

variable datatype

default value


minimum value

maximum value

increment value




variableName

variable data type

default value


some value

some value



Declarations for other state variables (if any) go here



1 0



Control: SOAP

1 Discovery

0 Addressing

3 Control

2 Description

4 Eventing

Action Result

5 Presentation

VCR

Turns On

Action:

SetPowerOn

UPnP Network

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Control: Invoke Action

> Who Control point

> When To invoke action on device

> What

POST path of control URL HTTP/1.1

HOST: host of control URL:port of control URL

CONTENT-TYPE: text/xml; charset="utf-8"

SOAPACTION: "urn:schemas-upnp-org:service:serviceType:v#actionName"




in arg value

other in args and their values (if any) go here




Control: Action Result

> Who Device

> When Action completes

> What

HTTP/1.1 200 OK

CONTENT-TYPE: text/xml; charset="utf-8"




out arg value

other out args and their values (if any) go here




Eventing: GENA

1 Discovery

0 Addressing

3 Control

2 Description

4 Eventing

5 Presentation

UPnP Network

Subscribe

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Eventing: GENA

0 Addressing

Action:

SetPowerOn

3 Control

2 Description

1 Discovery

4 Eventing

5 Presentation

VCR

Turns On

UPnP Network

Notify:

PowerOn = True

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Eventing: GENA Sidebar

> What is GENA

– IETF Draft General Event Notification Architecture

– "Send and receive notifications using HTTP over TCP/IP and

administratively-scoped multicast UDP."

> SUBSCRIBE to notifications

> UNSUBSCRIBE

> NOTIFY

– Of device availability

– Of state variable changes

http://www.upnp.org/download/

UPnP_Device_Architecture_Generic_20000710.ppt


Eventing: Subscribing

> Who Control point

> When Before receiving any events

> What

SUBSCRIBE publisher path HTTP/1.1

HOST: publisher host:publisher port

CALLBACK:

NT: upnp:event

TIMEOUT: Second-requested subscription duration

http://www.upnp.org/download/

UPnP_Device_Architecture_Generic_20000710.ppt


Eventing: Subscription

> Who Device

> When Accepts subscription

> What

HTTP/1.1 200 OK

SID: uuid:subscription-UUID

TIMEOUT: Second-actual subscription duration

> Device immediately sends a special, initial event to control point with the value

of all evented variables

http://www.upnp.org/download/

UPnP_Device_Architecture_Generic_20000710.ppt


Eventing: Notify

> Who Device

> When A state variable changes

> What

NOTIFY delivery path HTTP/1.1

HOST: delivery host:delivery port

CONTENT-TYPE: text/xml

NT: upnp:event

NTS: upnp:propchange

SID: uuid:subscription-UUID

SEQ: event key



new value


Other variable names and values (if any) go here


Presentation: HTML

Web

Browser

1 Discovery

0 Addressing

3 Control

2 Description

Get

Presentation

4 Eventing

UPnP Network

HTML UI

5 Presentation

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Anatomy of a UPnP Device


Networking stack

Control & Eventing




Discovery server

Description server

Presentation server

Discovery

Presentation

Description


Control & Eventing

Services

HTTPMU

UDP

HTTP

TCP

IP

http://www.upnp.org/download/Compressed-

UPnP_Forum_Mktg_Presentation.zip


Getting started with UPnP

> Check the UPnP Forum website

– http://www.upnp.org

> Study the UPnP architecture document

– http://www.upnp.org/specs/arch/UPnP-DeviceArchitecture-v1.0-20060720.pdf

> Get a SDK and start developing devices & control points

– http://www.upnp.org/resources/sdks.asp


UPnP SDK: CyberLink

> http://www.cybergarage.org/net/upnp/java/

> Documentation:

http://sourceforge.net/project/showfiles.phpgroup_id=75638&package_id=7617

2&release_id=330743


Mobile code with Jini


What is Jini

> Jini technology is a service oriented architecture that defines a

programming model which both exploits and extends Java technology to

enable the construction of secure, distributed systems consisting of federations

of well-behaved network services and clients.

> Jini technology can be used to build adaptive network systems that are

scalable, evolvable and flexible as typically required in dynamic computing

environments.

> Jini is designed to help developers deal with The Eight Fallacies of Distributed

Computing. Jini offers a number of powerful capabilities such as service

discovery and mobile code.

> The term Jini refers to both a set of specifications and an implementation;

the latter is referred to as the Jini Starter Kit. Both the specifications and the

Starter Kit have been released under the Apache 2.0 license and have been

offered to the Apache Software Foundation's Incubator.

http://jini.org - what is Jini


The Eight Fallacies of Distributed Computing

> The network is reliable.

> Latency is zero.

> Bandwidth is infinite.

> The network is secure.

> Topology doesn't change.

> There is one administrator.

> Transport cost is zero.

> The network is homogeneous.

Peter Deutsch


Jini: functional overview

> Think about how we use Yellow Pages:

– A traveler arrives in a city. (he's our client)

– He's looking for a doctor (i.e. someone who provides medical services)

– Using a Yellow Pages (i.e. a directory), he can find references to the doctors

in the city (i.e. to the service providers).

> Jini enables this kind of interaction for network services:

– The user arrives at some place with a laptop and connects it to the network.

– Wishing to print a document, he first looks for a service directory.

– He then searches for a "print" service in the directory.

– If at least one printer has previously registered its capacity to offer the

"print" service, the user will get a reference to the service.

– Finally, the print service can be invoked.


Jini: technical overview

> A key feature of the Java platform is that it supports mobile code:

– Remember applets .class and .jar files are loaded across the network

and executed on the client.

– Remote Method Invocation (RMI): methods can be invoked on objects that

"live" in other virtual machines.

> Jini builds upon this feature:

– Protocols are defined for finding and interacting with service registries (a

service provider can register its service, a client can lookup a service)

– An API provides abstractions are provided for dealing with service

descriptions, leasing, security, remote events, transactions,

configuration.


The components of a Jini system

> An infrastructure

– The components that support the execution, discovery and interaction with

services.

> A programming model

– The abstractions, classes & interfaces that you use to create the services.

> Services

– The components that offer facilities to other components in the system.

"While these pieces are separable and distinct, they are interrelated, which

can blur the distinction in practice. The components that make up the Jini

technology infrastructure make use of the Jini programming model; services that

reside within the infrastructure also use that model; and the programming model

is well supported by components in the infrastructure."

Jini Technology Architectural Overview, January 1999


The components of a Jini system

Jini Technology Architectural Overview, January 1999


Infrastructure components

> The discovery/join protocol

– allows services to discover, become part of, and advertise supplied

services to the other members of the federation.

– Both unicast and broadcast discovery are supported.

> The lookup service

– serves as a repository of services. Entries in the lookup service are objects

in the Java programming language; these objects can be downloaded as part

of a lookup operation and act as local proxies to the service that placed the

code into the lookup service.

> A distributed security system

– defines how entities are identified and how they get the rights to perform

actions on their own behalf and on the behalf of others.

Jini Technology Architectural Overview, January 1999


Infrastructure components

Jini Technology Architectural Overview, January 1999


Infrastructure components

Jini Technology Architectural Overview, January 1999


Infrastructure components

Jini Technology Architectural Overview, January 1999


Infrastructure components

Jini Technology Architectural Overview, January 1999


net.jini.core.lookup.ServiceItem

> Items are stored in and retrieved from the lookup service using instances of this

class.

> public ServiceItem(ServiceID serviceID, Object service,

Entry[] attrSets)

– serviceID - service ID, or null if registering for the first time

– service - service object

– attrSets - attribute sets


net.jini.core.lookup.ServiceRegistrar

> Object lookup(ServiceTemplate tmpl)

– Returns the service object (i.e., just ServiceItem.service) from an item

matching the template, or null if there is no match.

– If multiple items match the template, it is arbitrary as to which service object

is returned.

> ServiceRegistration register(ServiceItem item, long

leaseDuration)

– Returns the service object (i.e., just ServiceItem.service) from an item

matching the template, or null if there is no match.

– If multiple items match the template, it is arbitrary as to which service object

is returned.


net.jini.core.discovery.LookupLocator

> A utility class that performs unicast discovery, using version 1 of the unicast

discovery protocol.

> LookupLocator(String host, int port)

– Construct a new LookupLocator object, set to perform unicast discovery to

the input host and port.

> ServiceRegistrar getRegistrar()

– Perform unicast discovery and return the ServiceRegistrar object for the

given lookup service.


net.jini.core.discovery.LookupLocator

LookupLocator lookup = null;

ServiceRegistrar registrar = null;

System.setSecurityManager(new RMISecurityManager());

try {

lookup = new LookupLocator("jini://localhost");

} catch(java.net.MalformedURLException e) {

System.err.println("Lookup failed: " + e.toString());

System.exit(1);

}

try {

registrar = lookup.getRegistrar();

} catch (java.io.IOException e) {

System.err.println("Registrar search failed: " + e.toString());

System.exit(1);

} catch (java.lang.ClassNotFoundException e) {

System.err.println("Registrar search failed: " + e.toString());

System.exit(1);

}

System.out.println("Registrar found");


net.jini.discovery.LookupDiscovery

> This class is a helper utility class that encapsulates the functionality required of

an entity that wishes to employ multicast discovery to find lookup services.

> LookupDiscovery(String[] groups)

– Construct a new lookup discovery object, set to discover the given set of

groups.

> void addDiscoveryListener(DiscoveryListener l)

– Register a listener as interested in receiving DiscoveryEvent notifications.


net.jini.discovery.LookupDiscovery

public MulticastRegister() {

System.setSecurityManager(new java.rmi.RMISecurityManager());

LookupDiscovery discover = null;

try {

discover = new LookupDiscovery(LookupDiscovery.ALL_GROUPS);

} catch(Exception e) {

System.exit(1);

}

discover.addDiscoveryListener(this);

}

public void discovered(DiscoveryEvent evt) {

ServiceRegistrar[] registrars = evt.getRegistrars();

for (int n = 0; n < registrars.length; n++) {

ServiceRegistrar registrar = registrars[n];

try {

System.out.println("found a service locator");

} catch(RemoteException e) {

e.printStackTrace();

}

}

}


Getting started with Jini

> Get in touch with the community and get access to resources

– http://www.jini.org

> Get the Jini starter kit

– https://starterkit.dev.java.net/

> Learn how to use the technology

– Jan Newmarch's tutorial: http://jan.newmarch.name/java/jini/tutorial/Jini.xml

– Sing Li's course: http://www.javapassion.com/jini/

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!