How Does IoT works on Local Networks?


From a communications point of view, IoT has been a nothing but a special use case with a set of unique messaging limitations and challenges.

how does iot work


The biggest of these are latency and power consumption. Latency is basically the speed of communication. And in most cases, the latency is directly proportional to the relative amount energy consumed for this communication. High latency communication protocols tend to consume more energy.

Most standard networks make use of the TCP/IP protocols, which have been around since the start of the internet. TCP/IP has gone through a lot of upgrades over the years, and most recently there have been several IoT-specific additions to the stack.

IoT communication today is the same thing with smaller wireless devices designed for more specific purposes like Sensing or Electrical Control. For example, in Home Automation, the Sensors and Electrical Relays talk to each other in a way similar to how your Printer talks to your Laptop in a WiFi network.

To address the challenges that IoT devices face, there have been several new protocols implemented on the TCP/IP stack that use a modification in the way that the TCP/IP communication layers are implemented.

A slightly primitive version of an IoT network can be imagined as the local network of computer and printers in a standard office. All these devices connected to a common TCP/IP network and communicated via some very standard protocols like HTTP.

Given their use cases, the office appliances didn't need to worry about latency and power consumption, since these parameters were never critical to the functioning of that environment. You really wouldn't mind the printer spending an extra second to print your document. In fact, you wouldn't even notice.

These factors become exponentially more important in the case of IoT applications like Industrial Automation or Lighting Control. In these cases, a delay of even a second is a deal-breaker, and could cost you dearly.

Also, most IoT devices are battery-powered and designed for retrofit installations into existing environments. So, minimising power consumption becomes very important to maximise their life span.
Let me walk you through an example of how this communication works on a standard LAN network between PCs and Printers.


There are various protocols that are used, based on the application. HTTP is a universal protocol and identifies each device by it’s IP address. Each device sends a requests to another device, and accepts a response.
There are different types of requests that are allowed (GET, PUT, POST, DELETE, etc.).
Further reading: https://restfulapi.net/http-methods/

List of HTTP requests (Verbs)


For example, while opening the Google website, your browser sends a GET request to a Server at Google’s IP address, which responds with the HTML contents of the Google website.
Similarly, one IoT device can send a GET request to another IoT device’s local IP address and expect a response. This can be used to request information, or even pass a command and request the result of it’s execution as a response.

A lot of Server APIs work like this. They pass parameters through their HTTP requests, often in the form of JSON objects, and expect responses in JSON as well. 
The communication usually happens through a WiFi Router. The Router is a communications medium that relays every request and response to the correct IP address. Any message first goes to the Router, which reads it's headers (containing target IP addresses) and then directs it to the intended device on the Network.
In LAN networks (Local Network of a Router), the local IP addresses are usually something like 192.168.xxx.yyy . ‘xxx’ (0–254) can be user-defined, and ‘yyy’ (0–254) is the unique address given to each device on that network. The addresses are assigned by the Router’s DHCP server.
So if IoT device 1 is connected on 192.168.1.120, and IoT device 2 is on 192.168.1.200, sending a message from device 1 to device 2 is as simple as sending a GET request from device 1 to the device at 192.168.1.200, by including the destination IP address in the headers.
OSI Layers
There are several other TCP/IP protocols that are used for IoT, like CoAP, MQTT, UDP, etc. Each protocol has it’s own pros and cons, and must be chosen smartly based on the intended application. There are a lot of such protocols designed specifically for IoT.
Given the need for instant communication, most IoT products on LAN don’t use HTTP any more, because of it’s bulky nature. They go for more low-latency and optimised protocols that work with the TCP/IP stack.

Having said that, the choice of the IoT protocol is a non-trivial task, since it involves understanding the expected communication environments as well as the intended application of the system.

For example, UDP in practice is best used for brute force data transfer like streaming realtime video, whereas MQTT is an optimised and selective message queuing protocol best used in applications like Industrial Automation.

There is a lot of development happening on low-power protocols based on radically new Physical and Network OSI layers. For example a lot of devices are using LoRA technology which is physically different from WiFi, and solves the latency and power problems of IoT by compromising on message payload sizes.

Comments

Popular Posts