Overview of Networking and Messaging Protocols for IoT
Hello, Khabrovites! Russia's first online course IoT developer launches in OTUS in October. Enrollment for the course is open right now, in connection with which we continue to share useful materials with you.
The Internet of Things (IoT, Internet of Things) will be built on top of the existing network infrastructure, technologies and protocols currently used in homes/offices and the Internet, and will offer much more.
The purpose of this guide is to provide a brief overview of networking and application protocols for IoT.
TCP/IP uses a four-layer model with specific protocols at each layer. Cm. understanding the TCP/IP 4 layer model (we understand the four-layer model of TCP / IP).
The diagram below shows a comparison of the protocols currently in use and those most likely to be used for IoT.
Chart notes:
The font size indicates the popularity of the protocol. For example, on the left, IPv4 is larger, since it is much more popular on the modern Internet. However, it is smaller on the right as IPv6 is expected to be more popular in IoT.
Not all protocols are shown.
Most of the changes are at the channel (levels 1 and 2) and application levels (level 4).
The network and transport layers are likely to remain unchanged.
Link layer protocols
At the data link level (Data Link), you need to connect devices to each other. They can be both close, for example, in local networks (local networks) and at a great distance from each other: in urban (metropolitan area networks) and global networks (wide area networks).
Currently, at this level, home and office networks (LANs) use Ethernet and Wi-Fi, and mobile (WANs) use 3G / 4G. However, many IoT devices are low power, such as sensors, and are only powered by batteries. In these cases, Ethernet is not suitable, but low powered Wi-Fi and low powered Bluetooth can be used.
While existing wireless technologies (Wi-Fi, Bluetooth, 3G/4G) will continue to be used to connect these devices, it is also worth looking at new technologies specifically designed for IoT applications that are likely to grow in popularity.
At the network layer (Networking), the protocol will dominate in the long run IPv6. It is unlikely that IPv4 will be used, but it may play a role in the early stages. Most home IoT devices, such as smart light bulbs, currently use IPv4.
Transport level
At the transport layer (Transport), the Internet and the web are dominated by TCP. It is used in both HTTP and many other popular Internet protocols (SMTP, POP3, IMAP4, etc.).
MQTT, which I expect to become one of the main application layer protocols for messaging, currently uses TCP.
However, in the future, due to lower overhead, I expect UDP to become more popular for IoT. Probably more widespread MQTT-SN, running over UDP. See comparison article TCP vs UDP .
Application layer and messaging protocols
Important characteristics for IoT protocols:
Speed ββ- the amount of data transferred per second.
Latency is the time it takes to send a message.
Power consumption.
Security.
Availability of software.
Currently, two main protocols are actively used at this level: HTTP and MQTT.
HTTP is probably the most well-known protocol of this level underlying the web (WWW). It will continue to be important for IoT, as it is used for the REST API - the main mechanism for interaction between web applications and services. However, due to high overhead, HTTP is unlikely to become the main IoT protocol, although it will still be widely used on the Internet.
MQTT (Message Queuing Telemetry Transport) has become the main messaging protocol in IoT due to its lightness and ease of use. See article Introduction to MQTT for beginners (Introduction to MQTT for beginners).
Comparison of HTTP and MQTT for IoT
MQTT is rapidly becoming the de facto standard for IoT applications. This is due to its lightness and speed compared to HTTP and the fact that it is a one-to-many protocol rather than one-to-one (HTTP).
Many modern web applications would happily use MQTT instead of HTTP if it was available at the time of their development.
A good example is sending information to multiple clients, such as arrivals and departures of trains/buses/planes. In this scenario, a one-to-one protocol like HTTP has a lot of overhead and puts a lot of load on the web servers. Scaling these web servers can be difficult. With MQTT, clients connect to a broker, which can be easily added for load balancing. Watch the video tutorial about it Republish HTML Data Over MQTT (Flight Arrivals Example) and article MQTT vs HTTP for IOT.
Other messaging protocols
HTTP was not designed for IoT applications, but as mentioned, it will be widely used for some time due to its widespread use in API.
Almost all IoT platforms support both HTTP and MQTT.
However, there are other protocols worth considering.
Protocols
MQTT - (Message Queuing Telemetry Transport). Uses TCP/IP. The publish-subscribe model requires a message broker.
In this article the main protocols and their applications are considered. The conclusion of this article is that the IoT will use a set of protocols, depending on their intended use.
However, in retrospect, in the early years of the Internet, the HTTP protocol that would become dominant was just one of many protocols.
Although HTTP was not originally conceived for file and email transfer, today it is used for both.
I expect the same thing to happen with messaging protocols in IoT: most services will use one predominant protocol.
Below are Google Trends charts showing how the popularity of MQTT, COAP and AMQP has changed over the past few years.
Most of the changes are at the channel (levels 1 and 2) and application levels (level 4).
The network and transport layers are likely to remain unchanged.
At the application layer, IoT components will use messaging protocols. While we are still at an early stage in IoT development, it is likely that one or perhaps two messaging protocols will stand out.
Over the past few years, MQTT has become the most popular, and it is on it that I am now focusing on this site.
HTTP will also continue to be used as it is already well built into existing IoT platforms.