Introduction and understanding of UPnP

Source: Internet
Author: User
Tags uuid
The remote server opened a node B, and then on their own computer to start two nodes a,c, with the--bootnodes b command, A and C can add B nodes to their list, but a and C can not find each other is why. Supposedly, b should tell the node list that he knows to connect to the node.
The answer is: they will automatically find the node that satisfies the UPnP protocol. So now learn about UPnP. Preface

To do Android smart Hardware development year, Bluetooth contact is more than the SPP analog serial communication, and more is UPnP, because most of the projects are based on the cling Library WiFi solution project. Wi-Fi solution of the device relative Bluetooth tooth scheme, transmission speed, wide coverage, able to separate from the device Network, protocol specification is simple and clear, but the price is relatively higher.

Cling Library Address:
http://4thline.org/projects/cling/
1 2 about UPnP

UPnP is Universal Plug and Play, that is, Plug and Play device, can be regarded as a relatively complex network protocol, after all, it contains a lot of other network protocols, such as: IP (device addressing), TCP, UDP (data package send), HTTP (data transfer format) and so on.

UPnP can be extended, which means that you can also start adding other protocols, such as: When passing data, the HTTP protocol packets a layer of JSON protocol, or data passing using XML protocol to pass and so on.

The reason why UPnP is powerful is that it is based on the Internet, so that peer devices can interact freely over the internet, meaning that any device that can be networked can use the UPnP protocol. UPnP work Steps

Interested can go and see this UPnP documentation:

English ppt Introduction:
http://101.96.10.63/trinea.github.io/doc/upnp/UPnP_UDA_tutorial_July2014.pdf

Chinese version of the document description:
Http://read.pudn.com/downloads37/doc/comm/125876/UDA1.0-ChinesePDF.pdf
1 2 3) 4 5

The work step is actually just a work logic, roughly by function divided into 6 steps, as shown in Figure 1 below:

The workflow is shown in Figure 2 below:

0. Addressing-addressing

Since Internet-based, the basic peer-to-peer protocol needs to be met, so addressing is the basis of UPnP.

So we have to have addressing, the process of addressing is the process of acquiring IP address of the device, which is generally used DHCP (Dynamic Host configuration Protocol, dynamically configured protocol), that is, routing dynamic allocation of an unused IP address to the device. 1. Discovery of-discovery

Since came to the world of the Internet, by addressing the identity of the IP, idle boredom then must find a small partner communication, of course, the best sister, so this time there is a concept of discovery.

First you have to introduce yourself, that is, the network control points to introduce themselves (what, what to do), because do not know the current world has how many control points, so generally through the form of propaganda to introduce themselves. This means that the newly added device broadcasts its own information in the form of multicasting.

Of course, if you are a control point, you also have permission to search for devices that interest you. When searching the control point oneself do not know whether has the equipment which oneself is interested. Also this is the form of multicasting, when the other end of the world hears this message, then it will be answered in a separate form, which is the unicast response. The equivalent of the interview, the company to find a artist, publish an advertisement, add the requirements of welfare benefits, and then leave a mailbox, interested in the artist will send a resume to this mailbox. People can shout, companies can advertise, but the equipment can not. So the device is how to do, the device is based on SSDP (simple service Discovery Protocol) Easy Services Discovery Protocol, this agreement is similar to the definition of how to shout, shout the format, how to advertise ads, how the format of advertising. As follows: Devices introduce themselves (to introduce themselves in the form of propaganda)

NOTIFY * http/1.1 (Standard http1.1 protocol)
host:239.255.255.250:1900 (Routing fixed multicast address and port Internet number assignment organization very strong defined)
Cache-control: Max-age = seconds until advertisement expires refers to broadcast valid duration
Location:url for UPnP description for root device
Nt:se Arch target device type
NTS:ssdp:alive
usn:advertisement UUID compound identifier
1 2 3 4 5 6 7

In particular, Location,location is a URL for more information about the device (or an included device for the service), which is a document address describing the device information, which is used later. Control Point Search (company post recruitment ad format)

M-search * http/1.1
host:239.255.255.250:1900 (routing fixed multicast address and port Internet number assignment organization very strong defined) man
: "Ssdp:discover"
MX : Seconds to delay response
St:search target
1 2 3) 4 5

It is important to note that SSDP actually contains two simple protocols, namely: HTTPMU, HTTPU. HTTPMU (HTTP multicast UDP) is a variant of the HTTP protocol, that is, the UDP-based group advertises the contents of the HTTP format, and HTTPU sends the unicast to host via UDP. 2. Description-description

Since there is a way to find a small partner, then how to choose a small partner. Find only a few simple identifying information, such as the UPnP type of the device (or service), the globally unique identifier of the device, and the URL address of the device UPnP description. And to understand a small partner is certainly not enough, the equivalent of recruiting light on the resume profile is completely inadequate, but also need to know his appearance, ability to work and personality values.

So we need to get the device description, then how to get it. Yes, how to obtain, in fact, the device was found when the device description has been brought out, just encapsulated in a URL, that is, the location of the description URL, through the URL in the location can get an XML, the general description of the device is through the XML to identify.

A device description typically consists of two parts: a description of the physical and logical devices included, one or more service descriptions (describing the capabilities of the device to be exposed externally). It is also the equivalent of the object in addition to the basic appearance of the name, but also what he can do. Device descriptions include specific vendor, manufacturer information, such as module name and number, serial number, manufacturer name, specific vendor site URL, and more (details below). For each service in the device, the device description contains the service type, name, service description URL, control URL, and event URL. The device description also contains all embedded device descriptions and URL address sets.
As shown below:

<?xml version= "1.0"?> <root xmlns= "urn:schemas-upnp-org:device-1-0" > <specVersion> <major>1 </major> <minor>0</minor> </specVersion> <urlbase>base URL for all relative urls</url Base> <device> <deviceType>urn:schemas-upnp-org:device:deviceType:v</deviceType> < 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> <iconList> <icon> <mimetype>image/format</mimetype> <width>horizontal pixels</width> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

It is worth noting here that the description of the ability behavior is:

<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>
 &l

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.