The distinction lies already in the protocol hierarchy level. In the layering scheme of the protocol stack, the MQTT ranks on the same layer as CoAP. LwM2M provides a standardized data model and interface semantics on top of the CoAP layer.
As far as comparison between CoAP and MQTT is concerned, the difference is found in communication methods: CoAP provides communication based on requests and responses, whereas MQTT relies on a publish/subscribe messaging system. However, as it is a lower-layer protocol, any device management or monitoring application using MQTT needs to define its own semantics on top of it. LwM2M takes care of that, but uses CoAP as its basis instead.
What are the benefits of using LwM2M?
The Lightweight Machine-to-Machine standard is truly lightweight. It allows to manage devices that have very little power over really low bandwidth networks, while being itself a standard with a very simple and not confusing stack of technology. The devices that LwM2M is designed to manage include sensors, microcontrollers, actuators etc. which can sometimes be installed in a place that is hard to reach. It does not change the fact that such devices are actually on the web and do need to be managed, secured, updated, monitored etc.
To sum it up, LwM2M responds to these needs by offering:
a simple but well-thought-out and well-designed stack of technology
ability to manage devices with very little power over really low bandwidth networks
very little bandwidth consumption with very light payloads
great security based on DTLS and TLS
enhanced interoperability thanks to a clearly defined data model
device and network flexibility and applicability to rapidly changing needs of the IoT market
possibility for the IoT market to move into sectors where devices need to be of low cost, low power, limited network or battery lifetime etc.
time-to-market improvement – LwM2M is ready to use as a plug-and-play solution
open-source LwM2M clients and SDKs are available – free to download and use
What are some of the most important device management features in the latest version of the LwM2M protocol?
Composite operations such as READ-COMPOSITE, WRITE-COMPOSITE and others.
In the early specification, LwM2M utilizing CoAP used simple operations such as READ, WRITE, EXECUTE, CREATE (and others) based on basic methods used for example in HTTP (GET, POST, PUT, DELETE). In the latest LwM2M 1.1 specification however, there are new operations added on top of the already existing ones. These include composite operations such as READ-COMPOSITE or WRITE-COMPOSITE. The idea behind this was to extend the basic READ, WRITE and other commands to allow aggregation of operations on many different objects and send all the acquired parameters in one payload.
SEND operation in Information Reporting interface.
As far as operations are concerned, SEND is another one that significantly improves LwM2M’s telemetry capabilities. In the previous specification, in order for the LwM2M Client to be notified about any changes in a given resource, the LwM2M Server had to first issue OBSERVE operation on that resource and only then could the LwM2M Client issue a NOTIFY operation to receive the desired information. SEND on the other hand, gives similar results to NOTIFY operation, with the difference that it does not require OBSERVE operation to be active to send notifications. Thus, it makes the communication between the client and the server not only easier but also more reliable.
Transport bindings such as CoAP over TCP and Non-IP Data Delivery.
LwM2M gives you a plethora of transport bindings to choose from. If your project requires minimum power drain and maximum speed, UDP is a way to go. However, if you need reliability, you can use the TCP protocol thanks to its NAT/firewall traversal capabilities. Furthermore, you can also make use of Non-IP Data Delivery – another transport binding, which is particularly attractive for the IoT, because it further minimizes power consumption for IoT-specific resource-constrained devices.