UPnP (Universal Plug and Play Protocol) is a zero-configuration networking protocol that allows devices to discover and advertise themselves in the network. Traditional device methods to connect involves installing device drivers in the machine to set them up. But, devices that support Zero conf. networking just need to be plugged in the network and is ready to use. So, if you are wondering. How this works and why it has not been implemented for so many years you have come to the right place. Many of us have had troubles with installing device drivers for our printers and cameras and setting up the same.
Let us understand how this magic works,
To understand UPnP, you need to be aware of IP. UPnP is implemented over the IP protocol. It uses HTTP.SOAP and XML implemented over IP to discover, advertise, control and handle event handling. Let me take you through the steps on how this magic works,
We already know that UPnP needs IP protocol in its backbone to operate. Addressing can be done in two ways First, the UPnP device should implement a DHCP Client to get an IP from a DHCP server to get an Ip address to discover itself uniquely in the local network if the network does not implement a DHCP Server It should assign a self IP address. The mechanism of assigning self IP to the device is called as AUTOIP. UPnP devices can work only on a local network.
UPnP uses the SSDP (Simple Service Discovery Protocol) to advertise its presence. Device search requests and advertisements are sent via HTTPMU (Multicast messages) over UDP. UPnP uses UDP over TCP and runs on UDP port 1900 to avoid overhead caused by TCP. And the device responses are sent via unicast HTTPU messages. The device that wishes to advertise itself in the sends SSDP alive messages over the network to indicate its active presence in the network to the control points. Control Points (CP) listens passively to the SSDP packets on the network to discover the devices of its interest.
The SSDP packets advertised by the device contains the location field that contains the device type and the services implemented by the devices and any vendor specific manufacturer information like model name, model number, manufacturer of the device. The location field contains XML location where the device information can be identified and obtained.
Through SOAP messages the devices can be controlled using the control messages in the Control XML implementation. The devices can be instructed by the control point to perform a particular function on the device.
GENA(General Event Notification) can be used to raise a trigger in case of any event triggers or any status changes in the device.
Some Devices provide a web URL which can be accessed from the control point and which contains the WebGUI implementation to control the device. Any control actions to be sent to the device or the device status information can be checked with the help of this presentation URL .