IoT Solution Developer Protocols Guide
IoT Solution Developer Protocols Guide
NARROWBAND
IoT SOLUTION
DEVELOPER
PROTOCOLS
GUIDE
1
IoT Solution Developer Protocols Guide
INTRODUCTION
To deliver on its massive transformative potential, the Internet of Things needs to interconnect
an enormous number of devices, services, and applications over data networks as efficiently
as possible. Given the ever-growing diversity of devices—from resource-constrained sensors
to sophisticated smart phones—broad range of environments, and myriad evolving use cases,
building viable IoT solutions would be practically impossible if not for the decades of groundwork
that have gone into creating messaging protocols for the web and mobile communications.
Built upon standards established by the For devices operating in remote locations, The Open Mobile Alliance (OMA) uses CoAP
3rd Generation Partnership Project (3GPP), Message Queuing Telemetry Transport in the lightweight machine-to-machine
Narrowband IoT (NB-IoT) cellular networks (MQTT) is often suggested as the preferred (LWM2M) IoT device management standard.
now provide cost-efficient access to a massive messaging protocol. MQTT, however, relies on LWM2M enables remote management and
number of resource-constrained IoT devices the TCP/IP stack as the underlying transport, control of IoT devices using a streamlined
via mobile radio access networks. To take full and TCP is suboptimal for connecting over managed objects model and provides
advantage of NB-IoT, IoT solution developers mobile networks. interfaces for securely monitoring and
need to understand the capabilities and administering devices.
constraints of the NB-IoT data communication. The Internet Engineering Task Force (IETF)
developed the Constrained Application In this document, we highlight the main
Most IoT solution providers have a Protocol (CoAP) as an extremely lightweight characteristics of IoT protocols and assess
background in designing web or enterprise communications protocol stack suitable their suitability for the deployment over NB-
applications and are intimately familiar for resource-constrained, remote devices. IoT mobile networks both over IP and without
with the web protocol stack. Optimized IoT CoAP evolves and streamlines the web IP using Non-IP Data Delivery (NIDD).
applications, however, require a specialized Representational State Transfer (REST)-ful
application-level data transport protocol model inherent in the HTTP to make it as
and an IoT-centric communications stack. efficient and lightweight as possible.
2
IoT Solution Developer Protocols Guide
Throughput
Number of transactions for Cat-1 and above is already accounted for per current capacity calculations
Cat-4
DL:~150Mbps
UL:~50Mbps Connected vehicles Routers
VoLTE Video surveillance
Fleet management Smart watch
Low
Cat-1 to mid
DL:~10Mbps Asset trackers latency
UL:~5Mbps
VoLTE
Heart
Smart Connected Connected monitors
Cat-M1 meters elevators health care Activity
DL:~300Kbps trackers
UL:~375Kbps
VoLTE Industrial Bicycle Mid
Industrial monitoring sharing to high
sensors Smart Low latency latency
Cat-NB parking trackers
DL:~20Kbps
Transaction
UL:~60Kbps Up to 2/day Up to 1/hr; 24/day Up to 4/hr; 96/day Up to 10/hr; 240/day >240/day battery life
No voice Battery life: >10 years Battery life: 3-5 years Battery life: Months Battery life: Days Battery life: up to 1 day
3
IoT Solution Developer Protocols Guide
Fig. 2: Recommended bandwidth and payload characteristics for NB-IoT and LTE IoT devices
WHAT IS NB-IoT?
NB-IoT is a mobile access technology targeted data transmission protocols and minimize the Developers need to eliminate an unnecessary
at low-cost support for the massive deployment overhead of the data to be transmitted over overhead introduced by the IP, TCP, and TLS.
of lightweight and constrained IoT devices. cellular networks. The IoT device classes targeted by cellular
As such, it has the characteristics of the IoT and NB-IoT technologies will typically
constrained network; specifically, its effective The new OMA LWM2M 1.1 protocol provides transmit from a single byte to tens of bytes
bandwidth in one sector is limited to 226.7 the necessary transport binding for deploying in one payload. The devices will be in sleep
Kbps peak, and the overlaying protocols must over the NB-IoT access networks. It is based on mode most of the time, and there are strong
efficiently address the low-level fragmentation. the streamlined CoAP and contains necessary limitations imposed by the network on this
The protocol targets latency-insensitive semantics for performing device management highly streamlined data transmission channel.
applications. While NB-IoT is designed to and ensuring data transmission via the Typically, the bandwidth will be around 10
allow less than 10 sec latency, typical NB-IoT information-reporting interface. kbps, and the payload has to fit in the radio
devices and applications tolerate from 10 sec frame. Devices are supposed to transmit very
to more than 100 sec of latency. The NB-IoT The New NB-IoT Hourglass infrequently—at most, several times per hour,
devices suitable for applications that require NB-IoT presents developers with the and the transmission latency may be very
long battery life (e.g., 10+ years) and where the challenge of fitting the IoT communication high, from 10 sec. to 100 sec.
devices are expected to transmit an average from constrained devices into a constrained
200 bytes per day.1 communication channel with: These limitations are challenging for an
industry used to the relative freedom
NB-IoT can be used in both IP and NIDD modes. nn Narrow bandwidth of modern high-end communications
The data transmission cost is essentially the nn Low occurrence of data transactions channels. Cellular LTE networks deliver 10+
same as it is applied to gross transmitted nn Very small payloads Mbps bandwidth with latency measured in
data, not to the effective payload. Application nn High to very high latency milliseconds. Plus, reliable, long-lived TCP
developers need to be very efficient in their nn Devices in sleep mode most of the time connections are always available. With the
4
IoT Solution Developer Protocols Guide
effective payload on the order of magnitude of completely. However, this poses a new effectively addresses those challenges and
bytes, the overhead introduced by the TCP/IP challenge for application developers, allows smooth transition to the constrained
stack becomes significant and can be 10x to requiring them to address the need to NB-IoT stack. Moreover, not only does it
100x relative to actual payload. manage payload fragmentation, in-order deliver data efficiently, but LWM2M’s device
delivery, and flow control. management functionality enables the
NB-IoT allows constrained devices to devices themselves to be managed remotely—
overcome this limitation by introducing The combination of NB-IoT with the allowing for low-maintenance, long-battery-
NIDD and eliminating the TCP/IP stack technologies in the LWM2M 1.1 stack life device deployments and solutions.
In this model, the CoAP becomes the new spanning technology—the waist of the new NB-IoT hourglass model. With built-in congestion control,
block-wise transfer fragmentation handling mechanism, efficient coding of the headers (options) and payload, and the ability to effectively
transport agnostically, CoAP can be reused for both IP- and non-IP-based NB-IoT deployments.
IoT Application
MQTT
TLS
TCP
IP
Fig. 4: MQTT protocol stack and baseline sequence, QoS 1 and QoS 2 messages
5
IoT Solution Developer Protocols Guide
6
IoT Solution Developer Protocols Guide
MQTT message reliability (on top of the TCP) is assured by the three quality-of-service (QoS) levels:
CoAP Universal Resource Identifier (URI) instead lightweight with only 4-byte fixed header
CoAP has been specifically designed by of MQTT topics. However, there is a similarity encoding the GET, POST, PUT, DELETE
the IETF to meet the requirements of the between the CoAP URIs and MQTT topics. methods and response codes, type of
constrained devices and communications For example, sensor devices publishing message (confirmable or nonconfirmable),
channels. It is based on the REST their sensor information to a server could be and MessageID used to correlate requests with
architecture following the synchronous described in the following manner: responses (ACKs).
request-response HTTP model. CoAP uses
the GET, PUT, POST, and DELETE methods nn CoAP sensor publishing to CoAP
and response codes similar to, but not server: URI: coap://devices/sensors/
exactly like, HTTP. Therefore, it is easy to temperature
map CoAP traffic from devices to the RESTful
API logic. nn MQTT client publishing to a sensor
queue on the broker: topic: “/devices/
sensors/temperature”
CoAP uses the resource model mapped to the The CoAP message format is compact and Variable token is used for longer-term session
Marker: 0xFF var. Payload ... Payload: JSON, XML, CBOR, octet-stream...
7
IoT Solution Developer Protocols Guide
semantics (e.g., matching notifications to CoAP, on the other hand, runs on top of UDP resources change.
a particular observation request). Variable and provides its own reliability mechanism
options encode URI, content-format, and using confirmable and nonconfirmable CoAP provides its own reliability mechanism
information usually transmitted in the HTTP message types, and the block-wise transfer using confirmable messages and
headers, followed by the variable payload, fragmentation mechanism. nonconfirmable messages. Confirmable
which can be any internet format specified messages have the type “0” (CON), require
by the content-format options, e.g., JSON, Transport layer security for CoAP is an acknowledgment (message type 2 - ACK),
XML, or octet-stream. CoAP is extremely seamlessly provided in the Datagram and the client will continue resending it until
lightweight with only a 4-byte mandatory Transport Layer Security (DTLS) protocol. it receives the ACK message from the server
header. While MQTT specifies only 2 bytes CoAP provides its own reliability, flow control, or it times out. Nonconfirmable messages
for the fixed header, in reality, it has to always and fragmentation handling layers, and the have the type “v1” (NON) and the client will
carry another 2-byte MessageID for any MQTT only hard requirement is that a CoAP message not wait for the ACK. CoAP ACK messages
PUBLISH request. fits into an underlying protocol’s datagram, can carry useful payload data and themselves
meaning it can easily and seamlessly be do not require separate ACKs. The CoAP
CoAP’s request-response mode is deployed on any datagram-based transport, block-wise transfer mechanism ensures
asynchronous and nonblocking. A client does such as SMS or NB-IoT NIDD. reliable transmission of large-size payloads by
not have to wait for the response to initiate splitting it in chunks that are guaranteed to fit
another request, and CoAP responses can also Another remarkable feature of CoAP is into the lower-level datagrams (Fig. 9).
carry data so that no round trips are wasted. the ability to perform asynchronous push
observe/notify requests, which are modeled Whereas CoAP does not provide an explicit
The main difference between CoAP and after the observer software pattern. A server quality-of-service model (unlike MQTT), the
MQTT results from the MQTT requirement initiates a request to observe particular confirmable/nonconfirmable message types
to run on the reliable, lossless, in-order, resources on the CoAP client. The client allow it to loosely map to the MQTT QoS
byte-stream delivery transport, which remembers the request and notifies the semantics as follows:
effectively mandates the TCP/IP stack. server each time the state of the observed
Fig. 8: CoAP resource observations with confirmable notifications. Illustration courtesy of K. Hartke, Universitaet Bremen TZI.
8
IoT Solution Developer Protocols Guide
Fig. 9: CoAP fragmentation handling with block-wise transfer for large-size payload
9
IoT Solution Developer Protocols Guide
Fig. 10 shows how LWM2M reuses CoAP headers and maps all LWM2M-specific information into the LWM2M payload (URI parameters, specific
LWM2M content formats, etc.). Everything else is encoded in the payload in an efficient binary manner.
LWM2M 1.15 mandates plain text, opaque binary, and CoRE Link data formats for client implementations to ensure on-the-wire data transmission efficiency
and recommends implementing one of the two new data formats based on Sensor Markup Language (SenML) using either JSON or Concise Binary Object
Representation (CBOR). Previously mandatory in LWM2M 1.0 type-length-value (TLV) and optional, JSON is not recommended for use in LWM2M 1.1.
LWM2M uses a flat object/resource model to describe sensor/actuator model for devices, where a client device contains data structures mapped
to the device architecture and described by an object definition. Each object may have zero or more instances, and each instance contains
resources, which can contain values and be readable, writable, or executable. LWM2M defines a set of objects; however, the objects may be
defined outside of the LWM2M specification and used to model sensors and actuators of a device.
Below is a simple example of a smart lighting controller containing sensor and switch/dimmer objects:
Table 4: Example of the definition of a smart switch actuator object and resources (object URN: urn:oma:lwm2m:ext:3306)
10
IoT Solution Developer Protocols Guide
Light dimmer actuator LWM2M payload example (human readable contents of the binary TLV):
[URI-Path: /3306/0] // CoAP Path-Identifier of the Actuator object with the ID 3306 and instance 0
- 5852: 1800 // Light has been on for 30 minutes - value of resource 5852
Table 5: Example of the definition of a luminance sensor object and resources (object URN: urn:oma:lwm2m:ext:3301)
Light luminance sensor LWM2M payload example (human readable contents of the binary TLV):
[URI-Path: /3301/0] // CoAP Path-Identifier of the sensor object with the ID 3301 and instance 0
- 5602: 410 // Minimum value was 410 Lux - value of resource 5602
11
IoT Solution Developer Protocols Guide
The sensor/actuator LWM2M control flow (using the underlying CoAP protocol) may look like the following sequence:
Fig. 11: Example of a sensor/actuator communication sequence managing a smart light device via OMA LWM2M/CoAP
nn LWM2M does not introduce any header overhead to the underlying CoAP protocol.
nn LWM2M-specific header and payload values are very lightweight and usually coded as binary (JSON and text payloads are optional).
Therefore, in the overhead and traffic analysis, we do not need to specifically separate CoAP and LWM2M.
Note, however, that whereas LWM2M uses mostly binary payload and headers (options), even for text payloads such as JSON, the resources and values are
coded as integers. CoAP generally does not limit the formats, which can contain textual URI paths and text-based payloads, such as JSON and XML.
12
IoT Solution Developer Protocols Guide
The basic header structure and length for both MQTT and CoAP messages are very similar and lightweight. While CoAP requires a minimum of 4
bytes of headers, including the MessageID, the MQTT NOTIFY control packet also requires a minimum total of headers of 4 bytes (2 bytes for the
fixed header and 2 bytes for the Packet Identifier). For all protocols, MQTT topic and CoAP URIs are considered to belong to the payload.
MQTT requires an ordered lossless packet delivery and relies on the TCP as the underlying transport.2 User Datagram Protocol (UDP) and other
connectionless network transports, such as NB-IoT, are not suitable for MQTT due to the possibility of data loss and packet re-ordering. Therefore,
using MQTT creates packet overhead from both IP and TCP protocols.
CoAP, on the other hand, is designed to use UDP transport, does not require lossless and ordered delivery, and provides higher protocol level
fragmentation and flow controls. CoAP can be seamlessly deployed on any datagram transport, such as UDP, SMS, and NB-IoT (including NIDD).
MQTT involves complete packet overhead of TCP/IP packets (20 byte minimum for IPv4 headers and 40 bytes for IPv6). The TCP layer requires a
minimum of 24 bytes for the first two handshake messages and 20 bytes for the final ACK. Plus, teardown requires four messages with a minimum of
20 bytes each. Additionally, each TCP ACK will contribute an additional 20 bytes. In contrast, UDP packets only have a total of eight bytes each. When
CoAP/LWM2M is deployed over the NIDD transport, the UDP/IP stack is completely eliminated, providing more space for the payload data (Fig. 13).
Considering that in most cases each data transmission (e.g., MQTT NOTIFY control packet) requires a TCP ACK (20 bytes), the CoAP/LWM2M
savings will be even higher.
Start
CoAP over UDP/IP
IP CoAP DATA +16 bytes
Start
IP TCP MQTT DATA MQTT over TCP/IP
13
IoT Solution Developer Protocols Guide
Transmission overhead minimum overhead will be 352 bytes message is followed by the CoAP ACK
(not counting MQTT PUBLISH/PUBACK message) for all LWM2M operations. It is not
Each TCP connection requires a three-way control packets), which would be more mandated for the Notify (LWM2M information
handshake with a total of three messages and than 700 percent higher relative to the 50 reporting interface) operations but is highly
approximately 130 bytes, whereas teardown byte payload. Clearly, this would be very recommended since NB-IoT does not prevent
requires four messages with a total of 160 expensive for applications where devices packet loss.
bytes. Additionally, each MQTT packet will sleep most of the time, then wake up to
be followed by a TCP ACK (20 bytes each). report small payload, and go to sleep again. This leads to a very light transmission
Additionally, MQTT provides a mechanism to overhead for the CoAP data, even accounting
MQTT initially requires the client to initiate keep the TCP connection alive. However, the for the registration and deregistration, for a
a connection to the MQTT broker with two keep-alive packets are to be initiated by the total of approximately 20 bytes. Additionally,
messages: PUBLISH and PUBACK. After the client, which will require the devices to wake the client is not required to deregister as
MQTT connection has been established, the up just for the sake of sending the keep-alive soon as it wakes up before the registration
client can publish data by sending PUBLISH packet. lifetime expires.
messages to the server. MQTT has three QoS
levels, and the most typical QoS1 (at least CoAP/LWM2M, on the other hand (Fig. 15), Experimental measurement of various
once delivery) for reliable transmission will does not require any connection or session application data transmission protocols over
acknowledge each data publication with the setup on the TCP/IP level. LWM2M provides a live NB-IoT network in various conditions
PUBACK MQTT control packet. registration interface that requires the device is presented in Fig. 16. For good network
client to register with the server. This will conditions with low latency and low packet
The overall sequence with the overhead only require two CoAP messages (i.e., UDP loss, all connectionless transports (raw
budget to send one piece of data is shown datagrams). In addition, the server needs to UDP and CoAP) require only one message
on Fig. 14. If data reporting is infrequent send the first request to start observations, transmission, and the payload overhead
and requires TCP and MQTT to reestablish after which the client starts sending is very low due to the CoAP headers. The
connections each time, then the relative notifications asynchronously. LWM2M also overhead for the MQTT/TCP/IP stack would
overhead becomes huge for small data mandates the acknowledgments (CoAP be approximately 10 times higher due to TCP
payload. For example, the estimated confirmable mode where a CoAP CON and MQTT handshakes and ACKs.
Fig. 14: MQTT/TCP single notification round-trip data, no TLS, no keep-alive, QoS1 messages: 312 bytes registration overhead
14
IoT Solution Developer Protocols Guide
Fig. 15: CoAP single notification round-trip data, no TLS, CON messages: 20 bytes registration overhead
With degraded radio conditions and higher packet loss, connectionless transport overhead remains the same, but packets now start to get lost.
CoAP overhead increases due to the increased number of retransmissions; however, the data does not get lost due to the CoAP confirmable
message type mechanism. Overhead for MQTT/TCP would slightly increase due to the need to retransmit packets.
Overall, MQTT/TCP traffic requires approximately 10x more transactions and the data overhead is approximately 100x higher compared to the
CoAP/UDP traffic for the 5-byte payload (Fig. 16).
COAP
10.00 10.00
10 TCP
9.00 9.00 9.00 MQTT
8.00
8
6.00
6
5.00 5.00
4
3.00
2.00 2.00 2.00 2.00 2.00
2
1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
0
400
200
126.0
100
33.0 46.0 33.0 46.0 33.0 46.0 33.0 33.0
30.0 30.0 30.0 30.0 30.0
0 5.0 5.0 5.0 5.0 5.0
NIDD
SMS
UDP
COAP
TCP
MQTT
NIDD
SMS
UDP
COAP
TCP
MQTT
NIDD
SMS
UDP
COAP
TCP
MQTT
NIDD
SMS
UDP
COAP
TCP
MQTT
NIDD
SMS
UDP
COAP
TCP
MQTT
Fig. 16: Application-layer payload and transaction summary in live NB-IoT network – 5-byte payload
15
IoT Solution Developer Protocol Guide
Contact information
For any questions or comments, please reach out to IoTDeviceManagement@T-Mobile.com.
References
1. Y. P. E. Wang et al., “A Primer on 3GPP Narrowband Internet of Things,” IEEE Communications Magazine, vol. 55, no. 3, pp. 117-123, Mar. 2017.
2. Eclipse IoT Developer Survey 2018.
3. IETF RFC 7959 – Block-Wise Transfers in the Constrained Application Protocol (CoAP), 2016.
4. MQTT version 3.1.1 OASIS Standard, Dec. 2015.
5. Lightweight Machine-to-Machine Technical Specification, Approved Version 1.1 – August 2018, Open Mobile Alliance.
Acknowledgments
Sergey Slovetskiy, Principal Engineer, Systems Design and Strategy
Jeff Ahmet, Principal Engineer, Technology Development & Strategy
Karthik Iyer, Principal Engineer, Device Technology
Battery life and cost savings compared to Cat-M modules and IoT plans. Coverage not available in some areas.