lihongjie0209 / myblog

4 stars 0 forks source link

局域网服务发现 #297

Open lihongjie0209 opened 3 years ago

lihongjie0209 commented 3 years ago

Service Discovery layer has a prominent role in an IOT architecture. It is the service discovery or service management layer which differentiates an IOT network with that of typical internet network. The IOT devices need to connect and communicate with web or cloud based services and applications for IOT implementation. The cloud or web services and applications run on host computers which are identified by unique IP addresses on a network. In order to avail a cloud based service, the IOT devices must be connected with the computers (servers) hosting those services or applications. So, there are some protocols designed to resolve host IP addresses rendering IOT services and applications. These protocols help identifying servers hosting IOT services by their namespaces and allow an IOT board to connect with one (Unicast) or group of servers (Multicast) over the network.

Some of the popular service discovery protocols are as follow –

1) mDNS 2) DNS Service Discovery (DNS-SD) 3) uPnP 4) Simple Discovery Service Protocol

mDNS – Multicast Domain Name System (mDNS) is a DNS like service discovery protocol to resolve host names to IP addresses in a local network without using any unicast DNS server. It can be used without any additional infrastructure or DNS server in the network. The protocol operates on IP multicast UDP packets through which a node in the local network enquires the names of all other nodes. The client node sends a query message to respond by a node with specific name. When the node with the corresponding name receives the query, it responds with a multicast response message containing its IP address. Being a multicast response, the target device IP address and name is also saved by all the devices (nodes) of the network in their local caches.

In such a local network, the IP addresses could change at some time but not the names. This protocol is really useful as it does not need any additional infrastructure (DNS server in the network) and can be used to manage devices without any manual configuration or administration. The protocol can be implemented despite of infrastructure failures. Developed by IETF, mDNS protocol is defined in RFC6762 standard. DNS Service Discovery (DNS-SD) – This protocol stack uses standard DNS messages to discover services in an IOT network. Based on mDNS, DNS-SD is used to resolve services available in a network. The service discovery is implemented in two steps – in the first step, host names of the service providers are resolved and in the next step, IP addresses are paired with the host names using mDNS. It is important to identify host names as IP addresses can change in the network.

Like in mDNS, the IP address and host name of the target device is communicated as a multicast response and each node (connected IOT device in the network) updates the host name and related IP address on receiving the response. It is the protocol which keeps the host names constant in the network despite the devices or nodes have dynamic IP addresses. As the host name always remain constant in the network, it is possible to identify the devices uniquely and reliably within the local IOT network.

Like mDNS, this protocol stack does not require any additional infrastructure (DNS Name Server in the network) or manual configuration or administration of connected IOT devices.

uPnP – Maintained by Open Connectivity Foundation, Universal Plug and Play (uPnP) is a protocol stack that allows devices in a network to discover each other and each other’s capabilities along with setting up network functions like data sharing and communication.

There are three building blocks of any uPnP network – devices, services and control points. The devices are the basic blocks of the network where each device provides specific service or services. The services are seen as set of actions which can be implemented by the device. The control points identify devices by device and service descriptions and respond to client node by invoking requested services. In this protocol, the discovery of devices and services happen automatically and autonomously once a node enters the network. So, there remains no need to manually configure nodes (IOT devices) to discover available devices and service in the network.

This protocol is based on TCP-IP routing. The devices are identified by their Universal Resource Indicators (URIs) and the services are discovered using Hypertext Transfer Protocol (HTTP). A device connected to network automatically configures itself by acquiring a TCP-IP address and indicating available services by it using HTTP. The devices then use XML to communicate with each other and indicate each other’s capabilities (services to offer).

UPnP was earlier a proprietary standard of Microsoft but is now an open standard. It is quite suitable for small local IOT networks where devices would need to communicate with each other without any additional infrastructure. Like UPnP can be used by mobile devices to connect with printers and scanners in an automated office. Similarly, it can be used to transfer photos from a camera to mobile devices or laptop.

Simple Discovery Service Protocol (SDSP) – Simple Discovery Service Protocol is used in UPnP networks for discovering available services. It is used by control points in UPnP network to look for devices, services offered by them and their availability at a time. The control point sends a multicast search request to which the device offering requested service responds. The devices and services offered by them are identified by device and service descriptors respectively. The control point uses devices and service descriptions to look for requested services in the network.

There are also many public service discovery platforms to which IOT devices can request services for. Some of these platforms are as follow – HyperCat – an open standard collection of URIs to identify sensors and publish sensor data

Physical Web – a service initiated by Google’s Chrome Development Team, physical web allow mobile devices to capture sensor data using BLE beacons

Wi-Fi Aware – a service that will use Wi-Fi to connect smart phones and mobile devices with the surrounding sensors and IOT devices and collect as well as transmit data to them.

Bluetooth Beacons – a service that will allow smart phones and mobile devices to receive bluetooth beacons containing sensor data

Shazam – a service to identify music by recording an audio clip for few seconds. It is currently available as a mobile app and is frequently used for identifying music tracks

Open Hybrid – a service to map digital interfaces to the physical objects

Chirp – a mobile app to encode, transmit and decode data in the form of audible and inaudible near ultrasonic pitches

In the next tutorial, various application layer protocols used in IOT systems will be discussed.

To learn about physical and data link layer protocols commonly used for computer and mobile devices networking, check out the following tutorial –

Physical and Data Link Layer Protocols for Computers and Mobile Devices – Ethernet BLE Wi-Fi Wi-Fi Direct WPA