Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

35
Universal Plug and Universal Plug and Play (UPnP) Play (UPnP) Presented by: Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh
  • date post

    22-Dec-2015
  • Category

    Documents

  • view

    243
  • download

    0

Transcript of Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Page 1: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Universal Plug and Play Universal Plug and Play (UPnP)(UPnP)

Presented by:Presented by:

Kamal Kamal Kamal Kamal Mohammad AtiehMohammad Atieh

Page 2: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

ContentsContents

IntroductionIntroduction UPnP ProtocolUPnP Protocol Development LevelsDevelopment Levels Control Point: Data structures and Control Point: Data structures and

ModulesModules Control Point User InterfaceControl Point User Interface

Page 3: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Introduction to UPnPIntroduction to UPnP The UPnP is a technology that provides a peer-to-peer The UPnP is a technology that provides a peer-to-peer

connectivity of intelligent appliance, wireless devices, connectivity of intelligent appliance, wireless devices, and PCs of all factors, and creates a distributed and PCs of all factors, and creates a distributed network such that each device that is connected to the network such that each device that is connected to the network offers its services to all the other connected network offers its services to all the other connected devices.devices.

In this project a UPnP on mobile phone is In this project a UPnP on mobile phone is implemented, such that the devices of the distributed implemented, such that the devices of the distributed network are mobile phones of Qualcomm (Brew), So network are mobile phones of Qualcomm (Brew), So the project is part of the development of the Brew the project is part of the development of the Brew mobile phone.mobile phone.

Page 4: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Introduction (Cont.)Introduction (Cont.)

The nodes of the created network are classified The nodes of the created network are classified into two parts: Devices that offer the services, and into two parts: Devices that offer the services, and a Control Point that uses these services.a Control Point that uses these services.

Two teams are working on this project: our team Two teams are working on this project: our team has to implement the Control Point, the other has to implement the Control Point, the other should implement the Device.should implement the Device.

The implementation will be tested by a Brew The implementation will be tested by a Brew simulator.simulator.

Page 5: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

UPnP StepsUPnP Steps DiscoveryDiscovery

advertisements by the devicesadvertisements by the devices search requests from the control pointssearch requests from the control points

DescriptionDescription Requested information about the device is sent to control pointRequested information about the device is sent to control point

ControlControl requests for actions from the control points to the devicesrequests for actions from the control points to the devices

EventingEventing subscription for events by the control pointssubscription for events by the control points notification of events by the devicenotification of events by the device

Presentation (control point)Presentation (control point) GUI to the user by the control pointGUI to the user by the control point

Page 6: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

UPnP Protocol StackUPnP Protocol Stack The UPnP discovery protocol is based on the Simple Service Discovery The UPnP discovery protocol is based on the Simple Service Discovery

Protocol (SSDP).Protocol (SSDP). Control messages are expressed in XML using the Simple Object Control messages are expressed in XML using the Simple Object

Access Protocol (SOAP).Access Protocol (SOAP). Event messages are also expressed in XML and formatted using the Event messages are also expressed in XML and formatted using the

General Event Notification Architecture (GENA). General Event Notification Architecture (GENA). SSDP works over UDP, SOAP and GENA works over TCP.SSDP works over UDP, SOAP and GENA works over TCP.

Page 7: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Control Point side of the UPnP Subsystem

Network

Discovery

SearchDiscovery

Response

Discovery

Description

Request

Description

Description

Response

Control

Request

Control

Control

Response

Eventing

Event

subscription

Events

notification

Presentation

Control point user

Page 8: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

DiscoveryDiscovery

The control point sends msearch:The control point sends msearch:

M-SEARCH * HTTP/1.1M-SEARCH * HTTP/1.1

HOST:HOST: 239.255.255.250:1900 239.255.255.250:1900MAN:MAN: "ssdp:discover" "ssdp:discover"MX:MX: seconds to delay response seconds to delay response

ST:ST: ssdp:all ssdp:all

Page 9: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Discovery Cont.Discovery Cont.

The device responds with:The device responds with:

HTTP/1.1 200 OKHTTP/1.1 200 OK

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

DATE:DATE: when response was generated when response was generatedLOCATION:LOCATION: URL for UPnP description for device URL for UPnP description for deviceSERVER:SERVER: OS/version UPnP/1.0 product/version OS/version UPnP/1.0 product/version

ST:ST: device type : device version device type : device version USN:USN: device UUID :: device type : device version device UUID :: device type : device version

Page 10: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

DescriptionDescription Device DescriptionDevice Description

defines logical devicesdefines logical devices contains URLs for service description, control, contains URLs for service description, control,

eventing.eventing. Service DescriptionService Description

tells how to form a request for a servicetells how to form a request for a service events that can be subscribed to by control pointsevents that can be subscribed to by control points fetched using HTTP GETfetched using HTTP GET

Page 11: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

XML in UPnP: Device DescriptionXML in UPnP: Device Description<xml version="1.0"?><root xmlns="urn:schemas-upnp-org:device-1-0"> <specVersion> <major>1</major> <minor>0</minor> </specVersion> <device> <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 defined by a UPnP Forum (if any) go here Declarations for other services added by UPnP vendor (if any) go here </serviceList> <deviceList> Description of embedded devices defined by a UPnP Forum (if any) go here Description of embedded devices added by UPnP vendor (if any) go here </deviceList> <presentationURL>URL for presentation</presentationURL> </device></root>

Page 12: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

XML in UPnP: Service DescriptionXML in UPnP: Service Description<scpd xmlns="urn:schemas-upnp-org:service-1-0"><actionList> <action> <name> actionName </name> <argumentList> <argument> <name>formalParameterName </name> <direction> in or out </direction> <relatedStateVariable> stateVariableName </relatedStateVariable> </argument> </argumentList> </action></actionList><serviceStateTable> <stateVariable sendEvents="yes"> <name>variableName </name> <dataType> variable data type </dataType> <defaultValue>default value </defaultValue> <allowedValueList> <allowedValue> enumerated value </allowedValue> </allowedValueList> </stateVariable> </serviceStateTable></scpd>

Page 13: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

ControlControl

Uses Simple Object Access Protocol (SOAP)Uses Simple Object Access Protocol (SOAP) Control pointsControl points

fetch the URL for controlfetch the URL for control construct requests using SOAPconstruct requests using SOAP send the requests over HTTPsend the requests over HTTP wait for the SOAP responses from deviceswait for the SOAP responses from devices

DevicesDevices parse the SOAP requestsparse the SOAP requests carry out the required action and return responses in carry out the required action and return responses in

SOAP messagesSOAP messages

Page 14: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

XML in UPnP: SOAPXML in UPnP: SOAP Uses XML and HTTP for control callsUses XML and HTTP for control calls SOAP requestSOAP request

POST POST pathpath ofof controlcontrol URLURL HTTP/1.1 HTTP/1.1HOST: HOST: hosthost ofof co conntrol trol URLURL::portport of of controlcontrol URLURLCONTENT-LENGTH: CONTENT-LENGTH: bytesbytes inin bodybodyCONTENT-TYPE: text/xml; charset="utf-8"CONTENT-TYPE: text/xml; charset="utf-8"SOAPACTION: "urn:schemas-upnp-org:service:SOAPACTION: "urn:schemas-upnp-org:service:serviceType:v#actionNameserviceType:v#actionName””

<s:Envelope xmlns: s=“http://schemas.xmlsoap.org/soap/envelope”<s:Envelope xmlns: s=“http://schemas.xmlsoap.org/soap/envelope” s:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding”> s:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding”><s:Body><s:Body> < <u:u:actionNameactionName xmlns:u="urn:schemas-upnp-org:service: xmlns:u="urn:schemas-upnp-org:service:serviceType:vserviceType:v">"> < <argumentNameargumentName>>in arg valuein arg value</</argumentNameargumentName>> otherother inin argsargs andand theirtheir valuesvalues gogo herehere, , ifif anyany </u:</u:actionNameactionName>></s:Body></s:Body></s:Envelope></s:Envelope>

Page 15: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

EventingEventing

Device publishes a list of events for which Device publishes a list of events for which control points can subscribe and get control points can subscribe and get notificationsnotifications

Control points subscribe with the devices for Control points subscribe with the devices for the events publishedthe events published

Event notifications by the devices over TCP to Event notifications by the devices over TCP to control pointscontrol points

Page 16: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

XML in UPnP: Event XML in UPnP: Event NotificationNotification

NOTIFY delivery path HTTP/1.1HOST: delivery host:delivery portCONTENT-TYPE: text/xmlCONTENT-LENGTH: Bytes in bodyNT: 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>

Page 17: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Development LevelsDevelopment Levels

Page 18: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Project StepsProject Steps

Reading and understanding the UPnP.Reading and understanding the UPnP. Installation of the BREW SDK v.3.1.3.Installation of the BREW SDK v.3.1.3. Reading relevant information from the BREW API Reading relevant information from the BREW API

reference ,and making the necessary steps in order to reference ,and making the necessary steps in order to develop on the BREW SDK.develop on the BREW SDK.

Writing a first simple program on the simulator, and Writing a first simple program on the simulator, and running it.running it.

Building the infrastructure of the connection between Building the infrastructure of the connection between two devices , by sockets, and understanding how two devices , by sockets, and understanding how connection works.connection works.

Page 19: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Project Steps (Cont.)Project Steps (Cont.)

Implementation of each protocol step: the implementation Implementation of each protocol step: the implementation is based on sending special messages to the device is based on sending special messages to the device according to the protocol of each step via a socket which according to the protocol of each step via a socket which listens on a selected port, then receiving messages from listens on a selected port, then receiving messages from the device ,via the same socket, parsing the message, the device ,via the same socket, parsing the message, getting needed information from it, and updating the getting needed information from it, and updating the control point data structure according to this information. control point data structure according to this information.

The last step is building a GUI, which offers a friendly The last step is building a GUI, which offers a friendly interface to make the protocol usage easy and funny!!interface to make the protocol usage easy and funny!!

Page 20: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Special Challenges and SolutionsSpecial Challenges and Solutions

Multicasting:Multicasting: the protocol is based on sending http the protocol is based on sending http multicast messages at the discovery step, however we multicast messages at the discovery step, however we don’t have the ability to do such a thing , since the don’t have the ability to do such a thing , since the BREW SDK doesn’t support multicasting . BREW SDK doesn’t support multicasting .

SynchronizationSynchronization problems such like listening to many problems such like listening to many sockets at the same time, and updating the data structure sockets at the same time, and updating the data structure when getting information from the device: we bypassed when getting information from the device: we bypassed these problems by using callback functions that act when these problems by using callback functions that act when a special events occur.a special events occur.

ParsingParsing the XML format messages: we implemented a the XML format messages: we implemented a special XML parser that satisfies our needs.special XML parser that satisfies our needs.

Page 21: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

The Control Point:The Control Point: Data Structures and Modules Data Structures and Modules

Page 22: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

The Control Point Data StructureThe Control Point Data Structure

The control point struct contains:The control point struct contains:

IdentifierIdentifier Connection sockets (one socket for each protocol Connection sockets (one socket for each protocol

step)step) List of connected devices List of connected devices …………..

Page 23: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Cont.Cont.

The device struct contains:The device struct contains:

Information about the device : device Information about the device : device type ,device type ,device version, identifier ,name and version, identifier ,name and manufacturer.manufacturer.

The device description URL.The device description URL.

List of UPnP Services.List of UPnP Services.

Page 24: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Cont.Cont.

The service struct contains:The service struct contains: Information about the service : service version, service ID Information about the service : service version, service ID

and service type.and service type. Service Description URL.Service Description URL. Control URL.Control URL. Subscription URL.Subscription URL. List of actions that can be invoked by this service.List of actions that can be invoked by this service. List of state variables.List of state variables. ……....

Page 25: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Cont.Cont.

Each control action has a name and a list of Each control action has a name and a list of arguments.arguments.

A state variable struct is consisted of: A state variable struct is consisted of:

NameName, data type , default value and value., data type , default value and value.

Page 26: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Data Structure SchemaData Structure Schema

Control Point

ID

Sockets

Device List

UDP SocketDescription Sockets

Control SocketSubscription Socket

Eventing Socket

Device 1 Device 2 ……….

Service 1 Service 2

Control Action1

State variable1

……….

……

….

……

….

Page 27: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Main ModulesMain Modules Building message moduleBuilding message module: creating messages : creating messages

according to the protocol syntax rules in every step of according to the protocol syntax rules in every step of the protocol.the protocol.

Discovery Module:Discovery Module: this module actually activates this module actually activates the control point, and creates UDP socket ,sends, the control point, and creates UDP socket ,sends, receives and reads messages in the Discovery step, receives and reads messages in the Discovery step, and according to these messages updates the data and according to these messages updates the data structure.structure.

Device description and Service Description Device description and Service Description Modules: Modules: creating connection, sending, receiving creating connection, sending, receiving and reading messages in the description step, and and reading messages in the description step, and according to these messages updating the data according to these messages updating the data structure.structure.

Page 28: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Cont.Cont. Control Module:Control Module: creating connection, creating connection,

sending, receiving and reading messages in sending, receiving and reading messages in the control step of the protocol.the control step of the protocol.

Eventing Module:Eventing Module: creating connection, creating connection, reading , sending and receiving eventing and reading , sending and receiving eventing and subscription messages in the eventing step, subscription messages in the eventing step, and updating the data structure if needed.and updating the data structure if needed.

List Module:List Module: removing , adding and getting removing , adding and getting items (e.g devices, services) from the lists in items (e.g devices, services) from the lists in the data structure .the data structure .

Page 29: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Cont.Cont.

Parsing Module:Parsing Module: Parsing different Parsing different formats of messages according to the formats of messages according to the protocol step. (e.g. control ,eventing protocol step. (e.g. control ,eventing messages).messages).

Menu Module:Menu Module: This module creates This module creates graphical interface, that makes the usage graphical interface, that makes the usage of the protocol services easy and funny!!of the protocol services easy and funny!!

Page 30: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

User InterfaceUser Interface

Page 31: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

The Protocol InterfaceThe Protocol Interface

The service we have tested is a clock: The service we have tested is a clock: the control point sends a request to the the control point sends a request to the device (demo device in this case) device (demo device in this case) which reply with the time.which reply with the time.

The state variable is the location of the The state variable is the location of the device.device.

At first the user chooses the protocol At first the user chooses the protocol icon on the mobile, then he/she clicks icon on the mobile, then he/she clicks start:start:

Page 32: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Cont.Cont.

The control point starts searching for a The control point starts searching for a device (discovery step).device (discovery step).

Afterwards the control point discovers Afterwards the control point discovers a device and proposes getting the a device and proposes getting the device description.device description.

Page 33: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Cont.Cont.

The user is asked if he is The user is asked if he is interested in getting the service interested in getting the service description (Description step):description (Description step):

Page 34: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

Cont.Cont.

Control Step: The device is Control Step: The device is ready to invoke an action :ready to invoke an action :

Page 35: Universal Plug and Play (UPnP) Presented by: Kamal Kamal Kamal Kamal Mohammad Atieh Mohammad Atieh.

ReferencesReferences Universal Plug and Play forum, http;//www.upnp.orgUniversal Plug and Play forum, http;//www.upnp.org UPnP architecture, UPnP architecture,

http://www.upnp.org/resources/documents/CleanUPnPDA101-http://www.upnp.org/resources/documents/CleanUPnPDA101-20031202s.pdf20031202s.pdf

Intel’s UPnP SDK for Linux, http://developer.intel.com/ial/upnp/Intel’s UPnP SDK for Linux, http://developer.intel.com/ial/upnp/ Simple object access protocol, http://www.w3.org/TR/SOAP/Simple object access protocol, http://www.w3.org/TR/SOAP/ http://www.artima.com/spontaneous/upnp_digihome2.htmlhttp://www.artima.com/spontaneous/upnp_digihome2.html http://brewforums.qualcomm.com/http://brewforums.qualcomm.com/