In a traditional IoT architecture there are one or more sensors, actuators and controllers. These typically talk to an edge gateway box and the edge gateway box talks across the wide area network (typically the internet) to the cloud or enterprise or server. There are a number of variations, for instance where a device is formed from a combination of sensors and a gateway.
The communication between the sensor and gateway occurs over a sensor area network. If this is an IP based network then MQTT can be used.
MQTT is lightweight message queuing and Transport protocol. MQTT, as its name implies, is suited for the transport of telemetry data (sensor and actor data).
MQTT is very lightweight and thus suited for M2M (Mobile to Mobile), WSN (Wireless Sensor Networks) and ultimately IoT (Internet of Things) scenarios where sensor and actor nodes communicate with applications through the MQTT message broker.
MQTT is designed to provide very efficient communication across the wide area network portion of the network, if IP based.
HTTP can be used for this purpose but it has some limitations.
Comparison of MQTT and HTTP
Table 1. Comparison of MQTT and HTTP
| MQTT | HTTP |
Pattern | Publish/Subscribe | Request and Response |
Complexity | Simple | More complex |
Messae size | Small | Larger |
Header | Compact binary header that is just two bytes in size | Status detail and other Header details are Text based |
Service levels | Three QoS settings | All messages get the same level of service |
Data distribution | Supports 1 to zero,1 to 1 and 1 to n | 1 to 1 only |
Realtime scenario on HTTP Message pattern and MQTT benefits over HTTP
Most IoT systems deal in events where an event can occur at any point e.g. when someone presses a doorbell - most of the time we do not know when this will occur. The normal model is the door bell sends a doorbell event that a person listens for and responds to. If this is handled with HTTP, the HTTP application would have to poll to ask whether the door bell been pressed and most of the time the answer is no. In fact it has to continuously poll to find out if the door bell has been pressed. This is an exceedingly inefficient use of the network, CPU and battery.
MQTT like HTTP uses an IP based network but enables applications to listen for events and go to sleep (or do something else) until the event occurs at which point the event will be pushed to the listening application. As MQTT is a publish-subscribe protocol many applications can listen for the same event and the MQTT server will deliver the event to all who have expressed an interest in it. The application here can be a server side or device(client) side application.
No comments:
Post a Comment