Docstoc

app-upnp

Document Sample
app-upnp Powered By Docstoc
					Device Servers

         Prasun Dewan

Department of Computer Science
 University of North Carolina
       dewan@unc.edu
   Issues in Device Servers
                      Device is just a
                       server.
                      So what is
                       different?
Network




                                          2
              Addressing Devices vs.
                Traditional Servers
   Sever and network is always      Devices may be dynamically
    around - static address           added on ad-hoc networks -
   Centralized heavyweight           dynamic address
    scheme acceptable to give         With so many dynamic devices
    install and give unique           and ad-hoc networks lightweight
    addresses to servers               decentralized scheme needed
   Client expected to know
                                     Client may not know or care
    traditional server address
                                      about device server address
       imap.cs.unc.edu
                                       print to the nearest printer
   Discovery phase possible
                                       turn off all light bulbs
     www.cnn.com
     logical name to physical       Implies later binding and thus
      name can be bound               a discovery phase
      dynamically                                                      3
    Communicating with Device vs.
        Traditional Servers
   Client expected to      Client may not know exact
    know exact server        server interface
    interface                 palm computer controlling a
     get mail                 VCR it knows nothing about
     send mail               security system composer
                               substituting Axis camera
                               with Aibot Robot, which may
                               not share an interface
                              impromptu interoperability
                              implies an interface
                               (capability) discovery phase


                                                              4
    Communicating with Device vs.
        Traditional Servers
   Client polls for         Client may wish to notified of
    traditional server        device changes
    changes                    current channel changed, so
     New mail arrived?         redisplay it
     Cannot track fast        Implies an eventing
      changing                  mechanism that is
      information                  distributed
                                   can be dynamically
                                    discovered




                                                               5
          Deploying Remote User
                Interfaces
   Run preloaded client      Because of late binding,
    user-interface             client UI program may not
    program                    exist
     xmh                     Implies dynamic user-
     netscape                 interface deployment




                                                           6
                 Composing Devices
   Traditional servers      Composite device may be
    not composed into a       composed out of multiple
    single unit               devices
       Not the same as        security system
        replicas               CD

                             How to support composite
                              and individual device
                              services.




                                                         7
    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
                                                                 8
              UPnP Tactics
   Start simple
     Buildin only universal things that
      everybody needs (and can live with)
     Add as needed

   Minimize requirements
          IP network connectivity
     Basic
     Common HTTP protocol stack

   Leverage existing standards
     HTTP,   XML

                                            9
  UPNP Examples: Installing a
          printer
Today                      Vision
 Attach it to server PC    Just connect printer
 Load device driver         to network
 Share printer
 Manually bind each
  client to printer




                                                    10
     Installing a device store
Today                 Vision
 Attach a new disk    Just connect drive to
  drive to computer     network




                                                11
         Intelligent Alarm clock
Today                  Vision
 Set alarm clock       Alarm clock tells PC
       May vary        It runs script that
        depending on     checks schedule and
        weekday or       sets thermostat
        weekend
   Set thermostat
   Hope meeting not
    missed



                                                12
       Arriving/leaving home
Today                      Vision
 Turn on entrance light    Light switch
 Change thermostat          communicates with
 Play answering machine     PC, which runs script
  messages                   and its inverse
 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
                                                     13
        Arriving/leaving town
Today                       Vision
 Manually change            Push button saying
  thermostat                  on vacation
 Change water heater              Could do it remotely
 Close/open water valve       Must still throw trash
 Hold mail
 Set vacation message(s)
 Inform neighbour(s)
 Throw trash



                                                           14
                Power outage
Today                       Vision
 Manually set all clocks    They automatically
                              synchronize with an
                              a networked atomic
                              clock
                             Script runs
                              periodically or when
                              power comes on




                                                     15
           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




                                        16
            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




                                  17
              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



                                           18
UPnP Device
Architecture




               19
           Architecture/Terminology
   Components                          Control Point
     Control   points
        Controller,   usually client
     Device                               Device

        Controlled,
                                          Service
        usually server
     Anactual device                   Control Point
     might contain
     both functions                        Device

                                          Service

                                                        20
                Architecture
                              UPnP Enabled Device

                                     Device

                             Service 1      Service 2




                     UPnP Enabled Device
                                           Control Point
                   Device
Control Point
                   Service




                              UPnP Enabled Device
                                  Root Device
                                         Embedded Device
                        Service             Service 1 Service 2



                  Service        Control
                                 Server                           21
                    State        Event
                    Table        Server
         Example Configuration
  Control Point
  (Pocket PC)
                                 Control Point
                               (Remote Control)




                  IP Network



Native Device
                                            UPnP Bridge
(UPnP VCR)                                                              Lightweight Device
                                                                      (LonWorks Thermostat)



                        Native Device
                                                          Non-IP Bus/Networks
                     (UPnP Alarm Clock)


                                                    Non-UPnP Device
                                                      (X-10 Light)




                                                                                              22
     Steps to UPnP Networking
          3 Control          4 Eventing         5 Presentation

       2 Description

   1 Discovery

0 Addressing



   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
                                                                 23
               UPnP Protocol Stack
Standardized Schema
                       URLs, Model, Device #
  Instances (Types)
         Vendor-specific API above       Schemas (Prog Lang)
  UPnP vendor

   UPnP Forum




                                                            Wire protocols
  UPnP Device Architecture

  HTTPU/MU GENA       SSDP    SOAP        HTTP     GENA
                              HTTP
  UDP                         TCP

  IP

  Name     Vendor-specific OS below
                                                    State Events
Discovery                             Capability    Operation
and Events      Multiple http servers                         24
                                      Discovery      Control
     Steps to UPnP Networking
          3 Control          4 Eventing         5 Presentation

       2 Description

   1 Discovery

0* Addressing



   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
                                                                 25
              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        26
    Overview -ad hoc
UPnP in action - ad hoc
        1. DHCP broadcast

                  (timeout)
        2. Assign AutoNet address

        3. DNS name multicast

        4. Announce service

         (timeout - wait for requests)

               5. Discover service
         7. Response to discover

              8. Get_HTTP XML

         9. XML content

                                         27
 Overview - configured

UPnP in action - configured
              1. DHCP broadcast

        2. Address from DHCP server

        3. Name unicast to DNS server




                                           Server
        4. Announce service to listener

          5. Listener Get_HTTP XML

        6. Directory updated by listener
        7. Device specific negotiation



           8. LDAP query directory

                                                    28
     Steps to UPnP Networking
          3 Control          4 Eventing         5 Presentation

       2 Description

   1* Discovery

0 Addressing



   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
                                                                 29
     1 Discovery: Pull (Active) vs.
            Push (Passive)
                        Client (Control point)
            Server       could pull info
Client
                          Servers could be
                           dynamically added
                          Needs to poll for new
                           devices
                        Server (Device) could
                         push advertisement
            Server        Control points can be
Client
                           dynamically added
                          Needs to continuously
                           send info, using
                           network

                                                   30
     1 Discovery: Pull (Active) vs.
            Push (Passive)
                              SSDP Solution:
Client            Server        Hybrid approach
                                Advertisement has
                                 lifetime
                                       Can simulate pure
                                        push model
                                  HTTP over UDP
                                     What if message
         Server                       gets lost?
                                     Must send UDP
                                      message 3 times
                                     Solution over TCP
                                      planned


                                                            31
    1 Discovery: SSDP Sidebar
   What is SSDP?
      IETFDraft Simple Service Discovery
      Protocol
   Key design principles
      Administratively-scoped   multicast
      Unicast   responses
      UDP
      Very simple advertisements
      Very simple search

                                             32
               1 Discovery
   Control point finds        Devices
    interesting device            Advertise when
       0 get address              added
                                  Refresh
       1 discover device
                                   advertisements
                                   (cf. lease)
   Advertise / find              Cancel

    typed devices                  advertisements
                                   when removed
    (services)
                               Control points
       Guarantee of
                                search as needed
        minimal
                                  Devices respond
        capabilities
                                  Control points
   Simple                         filter
                                                     33
     1 Discovery: Protocol Stack

UPnP vendor

UPnP Forum

UPnP Device Architecture

HTTPMU        GENA   SSDP   HTTPU       SSDP
(multicast)                 (unicast)

UDP

IP



                                               34
           1 Discovery: Advertising
                                                               Multicast
          Who? Device multicasts                              address
          When? Added or refresh (cf. lease)                     Port
          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



              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:rootdevice
                                                                           35
                    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”




                                                       36
                 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?
                                                       37
           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




                                            38
           Byebye message
   Sent before device ceases to operate
   NTS = ssdp:byebye
   NT = service type




                                           39
               1 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


              ST one of
                   Service type
                   Device type
                   Device UUID
                   upnp:rootdevice
                   ssdp:all



                                                40
       Broadcast message
   Can send message to all devices
     ssdp:all
     Network analysis tool
     Remote control unit




                                      41
           1 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



           1   time for each NT that matches

            Very   simple matching

                                                               42
                    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



                                                           43
       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




                                                   44
         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




                                                 45
         E.g. Network traffic
 1000  hosts
 50 printers
 Requests evenly distributed over 30 second period
 Message size = 512 bytes
 Bandwidth = 59 Megabits per second




                                                 46
     Steps to UPnP Networking
          3 Control          4 Eventing         5 Presentation

       2* Description

   1 Discovery

0 Addressing



   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
                                                                 47
                  2 Description
   Control point learns               Protocol stack
    about device
    capabilities                   UPnP vendor
     0 get address
     1 discover device            UPnP Forum
            get URL for
             description           UPnP Device Architecture
       2 retrieve descr           HTTP
            get URL for
             service description
                                   TCP

   Declare capabilities           IP




                                                              48
                  2 Description
   Device description                Services
    Type                                 Functional units
                                           within devices
    Physical                         Service description
     container                          Actions
                                        State variables
    Logical
                                        Actual (vs.
     container                           designed)
           For each service             implementation
              • Type
              • URL for
                description           Expressed in XML
              • URL for control
              • URL for eventing                              49
                              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




                                             50
    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
                                                            51
             uuid
                                          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>

                                                                             52
                                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>
  <iconList>
            <deviceList>Description of embedded devices (if any) go here</deviceList>
   <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 (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>                                                                      54
                                        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>                                                                  55
                                                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>

                                                                                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>

                                                                       57
     Steps to UPnP Networking
          3* Control         4 Eventing         5 Presentation

       2 Description

   1 Discovery

0 Addressing



   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
                                                                 58
                      3 Control
   Control point invokes       Protocol stack
    actions on device       UPnP vendor
     0 get address
                            UPnP Forum
     1 discover device
     2 retrieve descr      UPnP Device Architecture
            get URL for    SOAP
             control
       3 send actions to   HTTP
        device
                            TCP

                            IP


                                                       59
    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.
                                                   60
           3 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"
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
  s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <s:Body>
   <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>
 </s:Body>
</s:Envelope>
                                                                         61
            3 Control: Action Result
         Who? Device
         When? Action completes
         What?
HTTP/1.1 200 OK
CONTENT-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>
   <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>
 </s:Body>
</s:Envelope>

                                                                  62
     Steps to UPnP Networking
          3 Control          4* Eventing        5 Presentation

       2 Description

   1 Discovery

0 Addressing



   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
                                                                 63
                     4 Eventing
   Control point listens        Protocol stack
    to state changes of      UPnP vendor
    device
     0 get address          UPnP Forum

     1 discover device      UPnP Device Architecture
     2 retrieve descr
                             HTTP                  GENA
            get URL for
             eventing
       4 subscribe to       TCP
        events from device
                             IP

   Basic push model
                                                          64
   Simple
    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."
       SUBSCRIBEto notifications
       UNSUBSCRIBE

       NOTIFY
         • Of device availability
         • Of state variable changes
                                               65
            4 Eventing: Subscribing
       Who? Control point
      When? Before receiving any events

      What?
SUBSCRIBE publisher path HTTP/1.1
HOST: publisher host:publisher port
CALLBACK: <delivery URL>
NT: upnp:event
TIMEOUT: Second-requested subscription duration




                                                  66
           4 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
                                                              67
                    4 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

<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>
                                                           68
     Steps to UPnP Networking
          3 Control          4 Eventing         5* Presentation

       2 Description

   1 Discovery

0 Addressing



   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
                                                                  69
                 5 Presentation
   Control point controls UPnP vendor stack
                             Protocol
    device and/or views UPnP Device Architecture
    device status using
    HTML UI                HTTP
     0 get address
     1 discover device       TCP
     2 retrieve descr
            get URL for      IP
             presentation
       5 load presentation
        page

   (Don't constrain
    implementation)

                                                   70
   Example Device (Intel
     Implementation)
TV Composite
   Control    Service
      Volume

      Power

      ….

   Picture   Service
      Color

      Tint

      Contrast

      ….

                           71
           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>




                                                  72
              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>
                                                                      73
      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>                                                   74
</device>
                   Example Service

<?xml version="1.0" ?>
<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<specVersion>
   <major>1</major>
    <minor>0</minor>
</specVersion>




                                                  75
       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>
                                                                   76
          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>
                                          77
Example Presentation

             Described using HTML




                                    78
                 Example Server Code
Object 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());
}                                                                               79
...
    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




                                                   80
                           CD Example
                  disc

                  disc

                  disc

                 (empty)




    Changer
                 (empty)
                              disc

                  disc
                           disc tray
                  disc

                 (empty)


                  disc

                 (empty)


                carousel               disc tray door
                                          (closed)




                                                        Player
                CD
                Composite
Audio
                             Power

•When disc insertion event received play CD
• Play random (CD)
                                                                 81
            Elaborate Scenario
   New DVD player connected to network
     Assignsitself 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



                                                      82
             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
                                                        83
               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
                                                      84
         Issues raised by UPnP
          3 Control           4 Eventing          5 Presentation

       2 Description

   1 Discovery

0 Addressing


   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
                                                                    85
             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


                                                     86
                  Auto-Shutoff
   Auto Shut off problem
     Network storm when devices reboot in sync
     Combine address discovery and routing




                                                  87
    Simple-minded Search Facilities
   Choices
     All
     Service  type
     Device Type
     Specific
   Complex queries
     Attributes?




                                      88
                     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?
                                                         89
             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                                                  90
           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.

       kind of interactive computer may not be known
    the
    when service defined




                                                             91
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




                                                         92
     No Programmer-Defined Types
    Only supports predefined types
      state variables
      action parameters

    No way to model dynamic composites


Dynamic
programmer-
defined
collection



                                          93
             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?
                                                        94
           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!
                                                     95
                 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>


                                                                            96
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>
                                          97
                  Changed Server Code
Object 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());
}                                                                        98
               Ideal Developer Effort

int getChannel () { return channel};
void setChannel (int newChannel) {
     channel = newChannel;
}
...




                                        99
             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


                                                     100

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:28
posted:4/9/2011
language:English
pages:100