Upload
helen-nichols
View
213
Download
0
Embed Size (px)
Citation preview
Device Servers
Prasun Dewan
Department of Computer Science University of North Carolina
2
Issues in Device Servers
Device is just a server.
So what is different?
Network
3
Addressing Devices vs. Traditional Servers
Sever and network is always around - static address
Centralized heavyweight scheme acceptable to give install and give unique addresses to servers
Client expected to know traditional server address imap.cs.unc.edu
Discovery phase possible www.cnn.com logical name to physical
name can be bound dynamically
Devices may be dynamically added on ad-hoc networks - dynamic address
With so many dynamic devices and ad-hoc networks lightweight decentralized scheme needed
Client may not know or care about device server address print to the nearest printer turn off all light bulbs
Implies later binding and thus a discovery phase
4
Communicating with Device vs. Traditional Servers
Client expected to know exact server interface get mail send mail
Client may not know exact server interface palm computer controlling a
VCR it knows nothing about security system composer
substituting Axis camera with Aibot Robot, which may not share an interface
impromptu interoperability implies an interface
(capability) discovery phase
5
Communicating with Device vs. Traditional Servers
Client polls for traditional server changes New mail arrived? Cannot track fast
changing information
Client may wish to notified of device changes current channel changed, so
redisplay it Implies an eventing
mechanism that is distributed can be dynamically
discovered
6
Deploying Remote User Interfaces
Run preloaded client user-interface program xmh netscape
Because of late binding, client UI program may not exist
Implies dynamic user-interface deployment
7
Composing Devices
Traditional servers not composed into a single unit Not the same as
replicas
Composite device may be composed out of multiple devices security system CD
How to support composite and individual device services.
8
UPnP (Universal Plug and Play) Formed in 1999 with 200 vendors
Consumer electronics,Home security, Networking, Mobile devices
Late binding Dynamic Server discovery Dynamic Interface discover Dynamic Event discovery Dynamic UI Deployment Static Service Composition
Language- and OS- Neutral Solution Avoid trojan horses
Ship data rather than code Open Use existing standards
9
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
10
UPNP Examples: Installing a printer
Today Attach it to server PC Load device driver Share printer Manually bind each
client to printer
Vision Just connect printer
to network
11
Installing a device store
Today Attach a new disk
drive to computer
Vision Just connect drive to
network
12
Intelligent Alarm clock
Today Set alarm clock
May vary depending on weekday or weekend
Set thermostat Hope meeting not
missed
Vision Alarm clock tells PC It runs script that
checks schedule and sets thermostat
13
Arriving/leaving homeToday Turn on entrance light Change thermostat Play answering machine
messages Turn on TV Set channel to CNN Raise/lower blinds
depending on before/after sunset
Turn on other lights Reverse steps when
turning off light
Vision Light switch
communicates with PC, which runs script and its inverse
14
Arriving/leaving townToday Manually change
thermostat Change water heater Close/open water valve Hold mail Set vacation message(s) Inform neighbour(s) Throw trash
Vision Push button saying
on vacation Could do it remotely
Must still throw trash
15
Power outageToday Manually set all clocks
Vision They automatically
synchronize with an a networked atomic clock
Script runs periodically or when power comes on
16
Home theater
Script to Turn on DVD Turn on TV Set it to DVD channel Set stereo to Video mode Set stereo volume to theater levels Dim lights
17
Ball game
Mobile device used to: pick up traffic info on road receive commentary at stadium track player statistics order food chat with buddies at game
18
Other apps
Appliance remotely fixed or set Calendars of family members
synchronized Product barcode scanned to order new
instance Presentation displayed on discovered
display devices
19
UPnP Device Architecture
20
Architecture/Terminology
Components Control points
Controller, usually client Device
Controlled,usually server
An actual devicemight containboth functions
DeviceDeviceDeviceDevice
ServiceServiceServiceService
Control PointControl PointControl PointControl Point
Control PointControl PointControl PointControl Point
DeviceDeviceDeviceDevice
ServiceServiceServiceService
21
Architecture
UPnP Enabled Device
UPnP Enabled Device
UPnP Enabled Device
Control Point
Device
Root Device
Embedded Device
Device
Service
Service 2Service 1
Service
Service 2Service 1
Control Point
Service
StateTable
ControlServerEventServer
22
Example Configuration
IP Network
Non-IP Bus/Networks
Control Point(Pocket PC)
Lightweight Device(LonWorks Thermostat)
Non-UPnP Device(X-10 Light)
UPnP Bridge
Native Device(UPnP Alarm Clock)
Control Point(Remote Control)
Native Device(UPnP VCR)
23
Steps to UPnP Networking
0 Control point and device get addresses
1 Control point finds interesting device
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 HTML UI
0 Addressing0 Addressing
1 Discovery1 Discovery
2 Description2 Description
5 Presentation5 Presentation4 Eventing4 Eventing3 Control3 Control
24
Vendor-specific API above
Vendor-specific OS below
UPnP Protocol Stack
UPnP Device ArchitectureUPnP Device ArchitectureUPnP Device ArchitectureUPnP Device Architecture
UDPUDPUDPUDP
IPIPIPIP
HTTPU/MUHTTPU/MUHTTPU/MUHTTPU/MUGENAGENAGENAGENA SSDPSSDPSSDPSSDP SOAPSOAPSOAPSOAP
HTTPHTTPHTTPHTTP
HTTPHTTPHTTPHTTPGENAGENAGENAGENA
TCPTCPTCPTCP
UPnP ForumUPnP ForumUPnP ForumUPnP Forum
UPnP vendorUPnP vendorUPnP vendorUPnP vendor
Multiple http servers
Name Discovery and Events
Capability Discovery
Operation Control
State Events
Schemas (Prog Lang)
Standardized Schema Instances (Types)
URLs, Model, Device # W
ire protocols
25
Steps to UPnP Networking
0* Control point and device get addresses
1 Control point finds interesting device
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 HTML UI
0* Addressing0* Addressing
1 Discovery1 Discovery
2 Description2 Description
5 Presentation5 Presentation4 Eventing4 Eventing3 Control3 Control
26
0 Addressing Control point and device get address
Use a DHCP server Else use Auto IP
What is Auto IP? IETF Draft Automatically Choosing an IP
Address in an Ad-Hoc IPv4 Network What steps does it take?
Pick an address in 169.254/16 range Check to see if it is used (ARP) Periodically check for DHCP server
Could use DNS and include DNS Client
27
Overview -ad hoc
UPnP in action - ad hocUPnP in action - ad hoc
1. DHCP broadcast1. DHCP broadcast
(timeout)(timeout)
2. Assign AutoNet address2. Assign AutoNet address
3. DNS name multicast3. DNS name multicast
4. Announce service4. Announce service
(timeout - wait for requests)(timeout - wait for requests)
5. Discover service5. Discover service
7. Response to discover7. Response to discover
8. Get_HTTP XML8. Get_HTTP XML
9. XML content9. XML content
28
Overview - configured
UPnP in action - configuredUPnP in action - configured
1. DHCP broadcast1. DHCP broadcast
2. Address from DHCP server2. Address from DHCP server
3. Name unicast to DNS server3. Name unicast to DNS server
4. Announce service to listener4. Announce service to listener
6. Directory updated by listener6. Directory updated by listener
5. Listener Get_HTTP XML5. Listener Get_HTTP XML
8. LDAP query directory8. LDAP query directory
7. Device specific negotiation7. Device specific negotiation
Se
rver
29
Steps to UPnP Networking
0 Control point and device get addresses
1* Control point finds interesting device
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 HTML UI
0 Addressing0 Addressing
1* Discovery1* Discovery
2 Description2 Description
5 Presentation5 Presentation4 Eventing4 Eventing3 Control3 Control
30
1 Discovery: Pull (Active) vs. Push (Passive)
Client (Control point) could pull info Servers could be
dynamically added Needs to poll for new
devices Server (Device) could
push advertisement Control points can be
dynamically added Needs to continuously
send info, using network
Client Server
Client Server
31
1 Discovery: Pull (Active) vs. Push (Passive)
SSDP Solution: Hybrid approach Advertisement has
lifetime Can simulate pure
push model HTTP over UDP
What if message gets lost?
Must send UDP message 3 times
Solution over TCP planned
Client Server
Server
32
1 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
33
1 Discovery
Control point finds interesting device
0 get address 1 discover device
Advertise / find typed devices (services)
Guarantee of minimal capabilities
Simple
Devices Advertise when
added Refresh
advertisements (cf. lease)
Cancel advertisements when removed
Control points search as needed Devices respond Control points filter
34
1 Discovery: Protocol Stack
UPnP vendorUPnP vendorUPnP vendorUPnP vendor
UPnP ForumUPnP ForumUPnP ForumUPnP Forum
UPnP Device ArchitectureUPnP Device ArchitectureUPnP Device ArchitectureUPnP Device Architecture
UDPUDPUDPUDP
IPIPIPIP
HTTPMUHTTPMU(multicast)(multicast)
HTTPMUHTTPMU(multicast)(multicast) GENAGENAGENAGENA SSDPSSDPSSDPSSDP HTTPUHTTPU
(unicast)(unicast)
HTTPUHTTPU(unicast)(unicast) SSDPSSDPSSDPSSDP
35
1 Discovery: Advertising Who? Device multicasts When? Added or refresh (cf. lease) What?
1 time / service type with NT == service type 1 time / device type with NT == device type 1 time / device with NT == device UUID 1 time with NT == upnp:rootdeviceupnp:rootdevice
NOTIFY * HTTP/1.1HOST: 239.255.255.250:1900
NOTIFY * HTTP/1.1HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age = seconds until advertisement expiresLOCATION: URL for UPnP description for root deviceNT: search targetNTS: ssdp:aliveUSN: advertisement UUID
Multicast address
Port
36
GENA Notification method format defined by
GENA An event delivery scheme over HTTP Allows subscription
May be used later Will allow it to be not depend on the “largely
non-existent Internet multicast infrastructure”
37
Multicast Scope Entire internet
Idea to find local service Link local
Does not support bridged/routed LANS Local administrative scope
Relative address 239.255.255.250
Relative address vs local scope Relative address allows progressively larger
scopes Based on physical location?
38
Location vs. USN Location needed to send messages USN a unique, location-independent ID
UUID is a USN example Decentralized assignment
Allows services to move Change IP address Change DNS name
39
Byebye message Sent before device ceases to operate NTS = ssdp:byebye NT = service type
40
1 Discovery: Searching Who? Control point multicasts When? Looking for device or service What?
ST one of Service type Device type Device UUID upnp:rootdeviceupnp:rootdevice ssdp:allssdp:all
M-SEARCH * HTTP/1.1HOST: 239.255.255.250:1900
M-SEARCH * HTTP/1.1HOST: 239.255.255.250:1900MAN: "ssdp:discover"MX: seconds to delay responseST: search target
41
Broadcast message Can send message to all devices
ssdp: all Network analysis tool Remote control unit
42
1 Discovery: Responding Who? Device unicasts When? If ST matches an NT What?
1 time for each NT that matches
Very simple matching
HTTP/1.1 200 OKCACHE-CONTROL: max-age = seconds until advertisement expires
HTTP/1.1 200 OKCACHE-CONTROL: max-age = seconds until advertisement expiresLOCATION: URL for UPnP description for root deviceST: search targetUSN: advertisement UUID
43
Network traffic SSDP traffic on recovery after power outage.
Control points will all send discover messages. to find printer
In large companies multicast admin domain will be large Can be entire company
Need a way for SSDP to deactivate before network storms created
Even with directory services, low-level SSDP may activate
44
Bandwidth requirements TP = some time period DR = # of clients sending discovery messages in TP RS = # of devices responding to each discover
message AM = average message size Bandwidth = (DR* 3 + DR*9*RS)*AM/TP
45
E.g. Network traffic 100, 000 hosts 5,000 printers Requests evenly distributed over 30 second period Message size = 512 bytes Bandwidth = 585976 Megabits per second
46
E.g. Network traffic 1000 hosts 50 printers Requests evenly distributed over 30 second period Message size = 512 bytes Bandwidth = 59 Megabits per second
47
Steps to UPnP Networking
0 Control point and device get addresses
1 Control point finds interesting device
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 HTML UI
0 Addressing0 Addressing
1 Discovery1 Discovery
2* Description2* Description
5 Presentation5 Presentation4 Eventing4 Eventing3 Control3 Control
48
2 Description
Control point learns about device capabilities 0 get address 1 discover device
get URL for description
2 retrieve descr get URL for
service description
Declare capabilities
Protocol stack
UPnP vendorUPnP vendorUPnP vendorUPnP vendor
UPnP ForumUPnP ForumUPnP ForumUPnP Forum
UPnP Device ArchitectureUPnP Device ArchitectureUPnP Device ArchitectureUPnP Device Architecture
IPIPIPIP
HTTPHTTPHTTPHTTP
TCPTCPTCPTCP
49
2 Description
Device description
Type Physical
container Logical container
For each service• Type• URL for description• URL for control• URL for eventing
UI Icons URL for presentation
Services Functional units
within devices Service description
Actions State variables Actual (vs.
designed) implementation
Expressed in XML
50
XML Like HTML
Describes a tree Unlike HTML
Describes contents rather than UI Style sheets describe UI
Tags are user-defined Via Schema Language (DDT)
Supported by Web browsers
51
2 Description: XML Sidebar
What is XML? W3C Recommendation Extensible Markup Language "Universal format for structured documents and data on the
Web." Field names in <angle brackets> Field values between names
Defines 24 data types ui1, ui2, ui4, i1, i2, i4, int r4, r8, number, fixed.14.4, float char, string date, dateTime, dateTime.tz, time, time.tz boolean bin.base64, bin.hex uri uuid
52
2 Description: Device (phys)<?xml version="1.0"?><root xmlns="urn:schemas-upnp-org:device-1-0"> <URLBase>base URL for all relative URLs</URLBase>
<device> <friendlyName>short user-friendly title</friendlyName> <manufacturer>manufacturer name</manufacturer> <manufacturerURL>URL to manufacturer site</manufacturerURL> <modelDescription>long user-friendly title</modelDescription> <modelName>model name</modelName> <modelNumber>model number</modelNumber> <modelURL>URL to model site</modelURL> <serialNumber>manufacturer's serial number</serialNumber> <UDN>uuid:UUID</UDN> <UPC>Universal Product Code</UPC> <deviceType>urn:schemas-upnp-org:device:deviceType</deviceType> <serviceList> <service> <serviceType>urn:schemas-upnp-org:service:serviceType:v</serviceType> <serviceId>urn:upnp-org:serviceId:serviceID</serviceId> <SCPDURL>URL to service description</SCPDURL> <controlURL>URL for control</controlURL> <eventSubURL>URL for eventing</eventSubURL> </service> Declarations for other services (if any) go here </serviceList> <deviceList>Description of embedded devices (if any) go here</deviceList> <iconList> <icon> <mimetype>image/format</mimetype> <width>horizontal pixels</width> <height>vertical pixels</height> <depth>color depth</depth> <url>URL to icon</url> </icon> XML to declare other icons, if any, go here </iconList> <presentationURL>URL for presentation</presentationURL>
</device> <specVersion> <major>1</major> <minor>0</minor> </specVersion>
</root>
<?xml version="1.0"?><root xmlns="urn:schemas-upnp-org:device-1-0"> <URLBase>base URL for all relative URLs</URLBase>
<device> <friendlyName>short user-friendly title</friendlyName> <manufacturer>manufacturer name</manufacturer> <manufacturerURL>URL to manufacturer site</manufacturerURL> <modelDescription>long user-friendly title</modelDescription> <modelName>model name</modelName> <modelNumber>model number</modelNumber> <modelURL>URL to model site</modelURL> <serialNumber>manufacturer's serial number</serialNumber> <UDN>uuid:UUID</UDN> <UPC>Universal Product Code</UPC> <deviceType>urn:schemas-upnp-org:device:deviceType</deviceType> <serviceList> <service> <serviceType>urn:schemas-upnp-org:service:serviceType:v</serviceType> <serviceId>urn:upnp-org:serviceId:serviceID</serviceId> <SCPDURL>URL to service description</SCPDURL> <controlURL>URL for control</controlURL> <eventSubURL>URL for eventing</eventSubURL> </service> Declarations for other services (if any) go here </serviceList> <deviceList>Description of embedded devices (if any) go here</deviceList> <iconList> <icon> <mimetype>image/format</mimetype> <width>horizontal pixels</width> <height>vertical pixels</height> <depth>color depth</depth> <url>URL to icon</url> </icon> XML to declare other icons, if any, go here </iconList> <presentationURL>URL for presentation</presentationURL>
</device> <specVersion> <major>1</major> <minor>0</minor> </specVersion>
</root>
53
2 Description: Device (logical)<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0"> <URLBase>base URL for all relative URLs</URLBase> <device> <friendlyName>short user-friendly title</friendlyName> <manufacturer>manufacturer name</manufacturer> <manufacturerURL>URL to manufacturer site</manufacturerURL> <modelDescription>long user-friendly title</modelDescription> <modelName>model name</modelName> <modelNumber>model number</modelNumber> <modelURL>URL to model site</modelURL> <serialNumber>manufacturer's serial number</serialNumber> <UDN>uuid:UUID</UDN> <UPC>Universal Product Code</UPC>
<deviceType>urn:schemas-upnp-org:device:deviceType :v</deviceType> <serviceList> <service> <serviceType>urn:schemas-upnp-org:service:serviceType:v</serviceType> <serviceId>urn:upnp-org:serviceId:serviceID</serviceId> <SCPDURL>URL to service description</SCPDURL> <controlURL>URL for control</controlURL> <eventSubURL>URL for eventing</eventSubURL> </service> Declarations for other services (if any) go here </serviceList> <deviceList>Description of embedded devices (if any) go here</deviceList> <iconList> <icon> <mimetype>image/format</mimetype> <width>horizontal pixels</width> <height>vertical pixels</height> <depth>color depth</depth> <url>URL to icon</url> </icon> XML to declare other icons, if any, go here </iconList> <presentationURL>URL for presentation</presentationURL>
</device> <specVersion> <major>1</major> <minor>0</minor> </specVersion>
</root>
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0"> <URLBase>base URL for all relative URLs</URLBase> <device> <friendlyName>short user-friendly title</friendlyName> <manufacturer>manufacturer name</manufacturer> <manufacturerURL>URL to manufacturer site</manufacturerURL> <modelDescription>long user-friendly title</modelDescription> <modelName>model name</modelName> <modelNumber>model number</modelNumber> <modelURL>URL to model site</modelURL> <serialNumber>manufacturer's serial number</serialNumber> <UDN>uuid:UUID</UDN> <UPC>Universal Product Code</UPC>
<deviceType>urn:schemas-upnp-org:device:deviceType :v</deviceType> <serviceList> <service> <serviceType>urn:schemas-upnp-org:service:serviceType:v</serviceType> <serviceId>urn:upnp-org:serviceId:serviceID</serviceId> <SCPDURL>URL to service description</SCPDURL> <controlURL>URL for control</controlURL> <eventSubURL>URL for eventing</eventSubURL> </service> Declarations for other services (if any) go here </serviceList> <deviceList>Description of embedded devices (if any) go here</deviceList> <iconList> <icon> <mimetype>image/format</mimetype> <width>horizontal pixels</width> <height>vertical pixels</height> <depth>color depth</depth> <url>URL to icon</url> </icon> XML to declare other icons, if any, go here </iconList> <presentationURL>URL for presentation</presentationURL>
</device> <specVersion> <major>1</major> <minor>0</minor> </specVersion>
</root>
54
2 Description: Device (other)<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0"> <URLBase>base URL for all relative URLs</URLBase>
<device> <friendlyName>short user-friendly title</friendlyName> <manufacturer>manufacturer name</manufacturer> <manufacturerURL>URL to manufacturer site</manufacturerURL> <modelDescription>long user-friendly title</modelDescription> <modelName>model name</modelName> <modelNumber>model number</modelNumber> <modelURL>URL to model site</modelURL> <serialNumber>manufacturer's serial number</serialNumber> <UDN>uuid:UUID</UDN> <UPC>Universal Product Code</UPC> <deviceType>urn:schemas-upnp-org:device:deviceType</deviceType> <serviceList> <service> <serviceType>urn:schemas-upnp-org:service:serviceType:v</serviceType> <serviceId>urn:upnp-org:serviceId:serviceID</serviceId> <SCPDURL>URL to service description</SCPDURL> <controlURL>URL for control</controlURL> <eventSubURL>URL for eventing</eventSubURL> </service> Declarations for other services (if any) go here </serviceList> <deviceList>Description of embedded devices (if any) go here</deviceList>
<iconList> <icon> <mimetype>image/format</mimetype> <width>horizontal pixels</width> <height>vertical pixels</height> <depth>color depth</depth> <url>URL to icon</url> </icon> XML to declare other icons, if any, go here </iconList> <presentationURL>URL for presentation</presentationURL> </device> <specVersion> <major>1</major> <minor>0</minor> </specVersion></root>
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0"> <URLBase>base URL for all relative URLs</URLBase>
<device> <friendlyName>short user-friendly title</friendlyName> <manufacturer>manufacturer name</manufacturer> <manufacturerURL>URL to manufacturer site</manufacturerURL> <modelDescription>long user-friendly title</modelDescription> <modelName>model name</modelName> <modelNumber>model number</modelNumber> <modelURL>URL to model site</modelURL> <serialNumber>manufacturer's serial number</serialNumber> <UDN>uuid:UUID</UDN> <UPC>Universal Product Code</UPC> <deviceType>urn:schemas-upnp-org:device:deviceType</deviceType> <serviceList> <service> <serviceType>urn:schemas-upnp-org:service:serviceType:v</serviceType> <serviceId>urn:upnp-org:serviceId:serviceID</serviceId> <SCPDURL>URL to service description</SCPDURL> <controlURL>URL for control</controlURL> <eventSubURL>URL for eventing</eventSubURL> </service> Declarations for other services (if any) go here </serviceList> <deviceList>Description of embedded devices (if any) go here</deviceList>
<iconList> <icon> <mimetype>image/format</mimetype> <width>horizontal pixels</width> <height>vertical pixels</height> <depth>color depth</depth> <url>URL to icon</url> </icon> XML to declare other icons, if any, go here </iconList> <presentationURL>URL for presentation</presentationURL> </device> <specVersion> <major>1</major> <minor>0</minor> </specVersion></root>
55
2 Description: Service (actns)<?xml version="1.0"?><scpd xmlns="urn:schemas-upnp-org:service-1-0"> <actionList> <action> <name>actionName</name> <argumentList> <argument> <name>formalParameterName</name> <direction>in xor out</direction> <retval /> <relatedStateVariable>stateVariableName</relatedStateVariable> </argument> Declarations for other arguments (if any) go here </argumentList> </action> Declarations for other actions (if any) go here </actionList> <serviceStateTable> <stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable datatype</dataType> <defaultValue>default value</defaultValue> <allowedValueRange> <minimum>minimum value</minimum> <maximum>maximum value</maximum> <step>increment value</step> </allowedValueRange> </stateVariable> <stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable data type</dataType> <defaultValue>default value</defaultValue> <allowedValueList> <allowedValue>some value</allowedValue> <allowedValue>some value</allowedValue> </allowedValueList> </stateVariable> Declarations for other state variables (if any) go here </serviceStateTable> <specVersion> <major>1</major> <minor>0</minor> </specVersion>
</scpd>
<?xml version="1.0"?><scpd xmlns="urn:schemas-upnp-org:service-1-0"> <actionList> <action> <name>actionName</name> <argumentList> <argument> <name>formalParameterName</name> <direction>in xor out</direction> <retval /> <relatedStateVariable>stateVariableName</relatedStateVariable> </argument> Declarations for other arguments (if any) go here </argumentList> </action> Declarations for other actions (if any) go here </actionList> <serviceStateTable> <stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable datatype</dataType> <defaultValue>default value</defaultValue> <allowedValueRange> <minimum>minimum value</minimum> <maximum>maximum value</maximum> <step>increment value</step> </allowedValueRange> </stateVariable> <stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable data type</dataType> <defaultValue>default value</defaultValue> <allowedValueList> <allowedValue>some value</allowedValue> <allowedValue>some value</allowedValue> </allowedValueList> </stateVariable> Declarations for other state variables (if any) go here </serviceStateTable> <specVersion> <major>1</major> <minor>0</minor> </specVersion>
</scpd>
56
2 Description: Service (vars)<?xml version="1.0"?><scpd xmlns="urn:schemas-upnp-org:service-1-0"> <actionList> <action> <name>actionName</name> <argumentList> <argument> <name>formalParameterName</name> <direction>in xor out</direction> <retval /> <relatedStateVariable>stateVariableName</relatedStateVariable> </argument> Declarations for other arguments (if any) go here </argumentList> </action> Declarations for other actions (if any) go here </actionList>
<serviceStateTable> <stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable datatype</dataType> <defaultValue>default value</defaultValue> <allowedValueRange> <minimum>minimum value</minimum> <maximum>maximum value</maximum> <step>increment value</step> </allowedValueRange> </stateVariable> <stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable data type</dataType> <defaultValue>default value</defaultValue> <allowedValueList> <allowedValue>some value</allowedValue> <allowedValue>some value</allowedValue> </allowedValueList> </stateVariable> Declarations for other state variables (if any) go here
</serviceStateTable> <specVersion> <major>1</major> <minor>0</minor> </specVersion>
</scpd>
<?xml version="1.0"?><scpd xmlns="urn:schemas-upnp-org:service-1-0"> <actionList> <action> <name>actionName</name> <argumentList> <argument> <name>formalParameterName</name> <direction>in xor out</direction> <retval /> <relatedStateVariable>stateVariableName</relatedStateVariable> </argument> Declarations for other arguments (if any) go here </argumentList> </action> Declarations for other actions (if any) go here </actionList>
<serviceStateTable> <stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable datatype</dataType> <defaultValue>default value</defaultValue> <allowedValueRange> <minimum>minimum value</minimum> <maximum>maximum value</maximum> <step>increment value</step> </allowedValueRange> </stateVariable> <stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable data type</dataType> <defaultValue>default value</defaultValue> <allowedValueList> <allowedValue>some value</allowedValue> <allowedValue>some value</allowedValue> </allowedValueList> </stateVariable> Declarations for other state variables (if any) go here
</serviceStateTable> <specVersion> <major>1</major> <minor>0</minor> </specVersion>
</scpd>
57
2 Description: Service (vars)<?xml version="1.0"?><scpd xmlns="urn:schemas-upnp-org:service-1-0"> <actionList> <action> <name>actionName</name> <argumentList> <argument> <name>formalParameterName</name> <direction>in xor out</direction> <retval /> <relatedStateVariable>stateVariableName</relatedStateVariable> </argument> Declarations for other arguments (if any) go here </argumentList> </action> Declarations for other actions (if any) go here </actionList>
<serviceStateTable> <stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable datatype</dataType> <defaultValue>default value</defaultValue> <allowedValueRange> <minimum>minimum value</minimum> <maximum>maximum value</maximum> <step>increment value</step> </allowedValueRange> </stateVariable>
<stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable data type</dataType> <defaultValue>default value</defaultValue> <allowedValueList> <allowedValue>some value</allowedValue> <allowedValue>some value</allowedValue> </allowedValueList> </stateVariable> Declarations for other state variables (if any) go here </serviceStateTable> <specVersion> <major>1</major> <minor>0</minor> </specVersion>
</scpd>
<?xml version="1.0"?><scpd xmlns="urn:schemas-upnp-org:service-1-0"> <actionList> <action> <name>actionName</name> <argumentList> <argument> <name>formalParameterName</name> <direction>in xor out</direction> <retval /> <relatedStateVariable>stateVariableName</relatedStateVariable> </argument> Declarations for other arguments (if any) go here </argumentList> </action> Declarations for other actions (if any) go here </actionList>
<serviceStateTable> <stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable datatype</dataType> <defaultValue>default value</defaultValue> <allowedValueRange> <minimum>minimum value</minimum> <maximum>maximum value</maximum> <step>increment value</step> </allowedValueRange> </stateVariable>
<stateVariable sendEvents=“yes” xor “no”> <name>variableName</name> <dataType>variable data type</dataType> <defaultValue>default value</defaultValue> <allowedValueList> <allowedValue>some value</allowedValue> <allowedValue>some value</allowedValue> </allowedValueList> </stateVariable> Declarations for other state variables (if any) go here </serviceStateTable> <specVersion> <major>1</major> <minor>0</minor> </specVersion>
</scpd>
58
Steps to UPnP Networking
0 Control point and device get addresses
1 Control point finds interesting device
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 HTML UI
0 Addressing0 Addressing
1 Discovery1 Discovery
2 Description2 Description
5 Presentation5 Presentation4 Eventing4 Eventing3* Control3* Control
59
3 Control
Control point invokes actions on device 0 get address 1 discover device 2 retrieve descr
get URL for control
3 send actions to device
Protocol stack
UPnP vendorUPnP vendorUPnP vendorUPnP vendor
UPnP ForumUPnP ForumUPnP ForumUPnP Forum
UPnP Device ArchitectureUPnP Device ArchitectureUPnP Device ArchitectureUPnP Device Architecture
IPIPIPIP
SOAPSOAPSOAPSOAP
HTTPHTTPHTTPHTTP
TCPTCPTCPTCP
60
3 Control: SOAP Sidebar
What is SOAP? IETF Draft Simple Object Access Protocol "Lightweight, XML-based protocol for
exchange of information in a decentralized, distributed environment." Envelope: defines a framework for
describing what is in a message and how to process it.
Convention: represent remote procedure calls and responses.
61
3 Control: Invoke Action Who? Control point When? To invoke action on device What?
POST path of control URL HTTP/1.1HOST: host of control URL:port of control URLCONTENT-TYPE: text/xml; charset="utf-8"SOAPACTION: "urn:schemas-upnp-org:service:serviceType:v#actionName"
POST path of control URL HTTP/1.1HOST: host of control URL:port of control URLCONTENT-TYPE: text/xml; charset="utf-8"SOAPACTION: "urn:schemas-upnp-org:service:serviceType:v#actionName"
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body>
</s:Body></s:Envelope>
<u:actionName xmlns:u="urn:schemas-upnp-org:service:serviceType:v"> <argumentName>in arg value</argumentName> other in args and their values (if any) go here </u:actionName>
62
3 Control: Action Result Who? Device When? Action completes What?
HTTP/1.1 200 OKCONTENT-TYPE: text/xml; charset="utf-8"
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body>
</s:Body></s:Envelope>
HTTP/1.1 200 OKCONTENT-TYPE: text/xml; charset="utf-8"
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body>
</s:Body></s:Envelope>
<u:actionNameResponse xmlns:u="urn:schemas-upnp-org:service:serviceType:v"> <argumentName>out arg value</argumentName> other out args and their values (if any) go here </u:actionNameResponse>
63
Steps to UPnP Networking
0 Control point and device get addresses
1 Control point finds interesting device
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 HTML UI
0 Addressing0 Addressing
1 Discovery1 Discovery
2 Description2 Description
5 Presentation5 Presentation4* Eventing4* Eventing3 Control3 Control
64
4 Eventing
Control point listens to state changes of device 0 get address 1 discover device 2 retrieve descr
get URL for eventing 4 subscribe to events
from device
Basic push model Simple
Protocol stack
UPnP vendorUPnP vendorUPnP vendorUPnP vendor
UPnP ForumUPnP ForumUPnP ForumUPnP Forum
UPnP Device ArchitectureUPnP Device ArchitectureUPnP Device ArchitectureUPnP Device Architecture
IPIPIPIP
HTTPHTTPHTTPHTTPGENAGENAGENAGENA
TCPTCPTCPTCP
65
4 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
66
4 Eventing: Subscribing
Who? Control point When? Before receiving any events What?SUBSCRIBE publisher path HTTP/1.1
HOST: publisher host:publisher port
SUBSCRIBE publisher path HTTP/1.1HOST: publisher host:publisher portCALLBACK: <delivery URL>NT: upnp:eventTIMEOUT: Second-requested subscription duration
67
4 Eventing: Subscription
Who? Device When? Accepts subscription What?
Device immediately sends a special, initial event to control point with the value of all evented variables
HTTP/1.1 200 OKSID: uuid:subscription-UUID TIMEOUT: Second-actual subscription duration
HTTP/1.1 200 OKSID: uuid:subscription-UUID TIMEOUT: Second-actual subscription duration
68
4 Eventing: Notify Who? Device When? A state variable changes What?
NOTIFY delivery path HTTP/1.1HOST: delivery host:delivery portCONTENT-TYPE: text/xml
NOTIFY delivery path HTTP/1.1HOST: delivery host:delivery portCONTENT-TYPE: text/xmlNT: upnp:eventNTS: upnp:propchangeSID: uuid:subscription-UUIDSEQ: event key
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0"> <e:property> <variableName>new value</variableName> </e:property> Other variable names and values (if any) go here</e:propertyset>
69
Steps to UPnP Networking
0 Control point and device get addresses
1 Control point finds interesting device
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 HTML UI
0 Addressing0 Addressing
1 Discovery1 Discovery
2 Description2 Description
5* Presentation5* Presentation4 Eventing4 Eventing3 Control3 Control
70
5 Presentation
Control point controls device and/or views device status using HTML UI 0 get address 1 discover device 2 retrieve descr
get URL for presentation
5 load presentation page
(Don't constrain implementation)
Protocol stackUPnP vendorUPnP vendorUPnP vendorUPnP vendor
UPnP Device ArchitectureUPnP Device ArchitectureUPnP Device ArchitectureUPnP Device Architecture
IPIPIPIP
HTTPHTTPHTTPHTTP
TCPTCPTCPTCP
71
Example Device (Intel Implementation)
TV Composite Control Service
Volume Power ….
Picture Service Color Tint Contrast ….
72
Example Composition
<?xml version="1.0" ?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<URLBase>http://192.168.0.4:5431</URLBase>
73
Example Composition<device>
<deviceType>urn:schemas-upnp- org:device:tvdevice:1</deviceType>
<friendlyName>UPnP Television Emulator</friendlyName>
<manufacturer>TV Manufacturer Name</manufacturer>
<manufacturerURL>http://www.manufacturer.com</manufacturerURL>
<modelDescription>UPnP Television Device Emulator 1.0</modelDescription>
<modelName>TVEmulator</modelName>
<modelNumber>1.0</modelNumber>
<modelURL>http://www.manufacturer.com/TVEmulator/</modelURL>
<serialNumber>123456789001</serialNumber>
<UDN>uuid:Upnp-TVEmulator-1_0-1234567890001</UDN>
<UPC>123456789</UPC>
74
Example Service Composition<serviceList> <service> <serviceType>urn:schemas-upnp-org:service:tvcontrol:1</serviceType> <serviceId>urn:upnp-org:serviceId:tvcontrol1</serviceId> <controlURL>/upnp/control/tvcontrol1</controlURL> <eventSubURL>/upnp/event/tvcontrol1</eventSubURL> <SCPDURL>/tvcontrolSCPD.xml</SCPDURL> </service> <service> <serviceType>urn:schemas-upnp-org:service:tvpicture:1</serviceType> <serviceId>urn:upnp-org:serviceId:tvpicture1</serviceId> <controlURL>/upnp/control/tvpicture1</controlURL> <eventSubURL>/upnp/event/tvpicture1</eventSubURL> <SCPDURL>/tvpictureSCPD.xml</SCPDURL> </service> </serviceList>
</device>
75
Example Service
<?xml version="1.0" ?> <scpd xmlns="urn:schemas-upnp-org:service-1-0"> <specVersion> <major>1</major> <minor>0</minor> </specVersion>
76
Example Action List
<actionList> <action> <name>PowerOn</name> </action> <action> <name>SetChannel</name>
<argumentList> <argument>
<name>Channel</name> <relatedStateVariable>Channel</relatedStateVariable> <direction>in</direction>
</argument> </argumentList>
</action> ….
<actionList>
77
Example Variables<serviceStateTable> <stateVariable sendEvents="yes"> <name>Power</name> <dataType>Boolean</dataType> <defaultValue>0</defaultValue> </stateVariable> <stateVariable sendEvents="yes"> <name>Channel</name> <dataType>i4</dataType> <allowedValueRange> <minimum>1</minimum> <maximum>100</maximum> <step>1</step> </allowedValueRange> <defaultValue>1</defaultValue> </stateVariable> …..</serviceStateTable>
78
Example Presentation
Described using HTML
79
Example Server CodeObject processMessages (Message message) {
switch (message.kind) case GET_VAR_REQUEST:
switch ((GetVarMessage) message).varName) case “Channel”: message.result = getChannel();
… case ACTION_REQUEST:
actionMessage = (ActionMessage) message.switch (actionMessage.actionName) case “setChannel”: setChannel(parseString(actionMessage.params[0])) …
}int channel;int getChannel () { return curentChannel};void setChannel (int newChannel) { channel = newChannel; UPnP.announce(“Channel”, toString(getChannel());}...
80
Another Example: Composite greater than sum of parts
TV Composite Simply combines services
CD Composite Adds services Record with fields vs Object with instance
variables
81
CD Example
(empty)
disc
(empty)
disc
disc
disc
disc
carousel
disc tray
(empty)
(empty)
disc
disc
disc tray door(closed)
CD Composite
Power
Player
Changer
Audio
•When disc insertion event received play CD• Play random (CD)
82
Elaborate Scenario New DVD player connected to network
Assigns itself an IP address after looking for DHCP several times or Auto-IP
Sends advertisement, possibly multiple times because UDP
Father brings laptop home Assigns address and sends advertisement
Video remote control started Searches for and displays Video devices
83
Elaborate Scenario DVD selected by father
Controller retrieves description/presentation URL
User can choose between using URL or controller UI
Run invoked on DVD Run time of current disc can be queried Clock flashing Retrieves clock synchronizer from disk server Clock synchronizer finds clocks and syncs
them
84
Elaborate Scenario Father prints file Printer out ink message appears on father’s
and son’s computers Son fixes it. Needs printer in room to print HW Disconnects printer
Bye bye message sent and seen by father Moves printer to room
IP assignment and advertisement Mother presses button for mood control
Lights get dimmed, shades down, soft music starts, laptop shuts down
85
Issues raised by UPnP
0 Control point and device get addresses (Auto IP)1 Control point finds interesting device (push/pull multicast,
type)2 Control point learns about device capabilities (XML)3 Control point invokes actions on device (SOAP)4 Control point listens to state changes of device (GENA)5 Control point controls device and/or views device status
using HTML UI
0 Addressing0 Addressing
1 Discovery1 Discovery
2 Description2 Description
5 Presentation5 Presentation4 Eventing4 Eventing3 Control3 Control
86
Issues raised by UPnP
Scaling problem of multicast-based discovery Auto Shut off problem
Simple-minded search Lack of access and concurrency control Static, manual, procedural service composition Device-independent UI No programmer-defined types High programming and maintenance costs
87
Auto-Shutoff
Auto Shut off problem Network storm when devices reboot in sync Combine address discovery and routing
88
Simple-minded Search Facilities
Choices All Service type Device Type Specific
Complex queries Attributes?
89
Lack of Control Ignores access control.
prevents accidents turning on neighbor’s TV
prevents intentional sabotage opening garage door to steal
Classic AC applicable? Ignores concurrency control.
Two remote users concurrently setting thermostat Two users editing VCR settings offline Classic CC applicable? Mobile CC applicable?
90
Static, Manual, Procedural Composition
Dynamic collections e.g. All lamps in a room All services explicitly statically enumerated in UPnP Must create a new description when new service added
to collection new lamp to room
Declarative/automatic composition issue when composite greater than sum of parts low-level procedural code to add functionality in UPnP
play CD when disc inserted set printer output to camera distribute multi-media presentation to audio and video
devices
91
Device-Independent UI
Fixed UI for all devices may wish one specific to interactive computer used
palm computers and laptops have different form factors and I/O capabilities
may wish to show each variable in separate screen. the kind of interactive computer may not be known
when service defined
92
No Programmer-Defined Types XML defines 24 data types
ui1, ui2, ui4, i1, i2, i4, int r4, r8, number, fixed.14.4, float char, string date, dateTime, dateTime.tz, time, time.tz boolean bin.base64, bin.hex uri uuid
93
No Programmer-Defined Types Only supports predefined types
state variables action parameters
No way to model dynamic composites
Dynamic programmer-defined collection
94
High Programming Cost Device developer must:
define the XML-based external representation of the device
translate the client operation-invocation and variable-access requests to local operation-invocations
announce variable change notifications Exporting functionality requires more code than
implementing it in example Intel device not counting UI code
Cost proportional to complexity of type. Reason for not allowing complex types?
95
High Maintenance Cost Information repeated multiple times
operation implementation code action list state variable table message processing code event announcement code
All repetitions must be changed tedious error-prone
Channel -> Current Channel requires 9 changes!
96
Changed Action List<actionList> <action> <name>PowerOn</name> </action> <action> <name>SetCurrentChannel</name> <argumentList> <argument>
<name>CurrentChannel</name> <relatedStateVariable>CurrentChannel</relatedStateVariable>
<direction>in</direction> </argument> </argumentList>
</action> ….
<actionList>
97
Changed State Variable Table<serviceStateTable> <stateVariable sendEvents="yes"> <name>Power</name> <dataType>Boolean</dataType> <defaultValue>0</defaultValue> </stateVariable> <stateVariable sendEvents="yes"> <name>CurrentChannel</name> <dataType>i4</dataType> <allowedValueRange> <minimum>1</minimum> <maximum>100</maximum> <step>1</step> </allowedValueRange> <defaultValue>1</defaultValue> </stateVariable> …..</serviceStateTable>
98
Changed Server CodeObject processMessages (Message message) {
switch (message.kind) case GET_VAR_REQUEST: switch ((GetVarMessage) message).varName) case “CurrentChannel”: message.result = getCurrentChannel();
… case ACTION_REQUEST: actionMessage = (ActionMessage) message. switch (actionMessage.actionName)
case “setCurrentChannel”: setCurrentChannel(parseString(actionMessage.params[0]))
…}int channel;int getCurrentChannel () {return channel};void setCurrentChannel (int newChannel) { channel = newChannel; UPnP.announce(“CurrentChannel”, toString(getCurrentChannel());}...
99
Ideal Developer Effort
int getChannel () { return channel};void setChannel (int newChannel) { channel = newChannel;}...
100
Issues raised by UPnP
Scaling problem of multicast-based discovery Auto Shut off problem
Simple-minded search Lack of access and concurrency control Static, manual, procedural service composition Device-independent UI No programmer-defined types High programming and maintenance costs