# Impact of CoAP and MQTT on NB-IoT System Performance +
## 1 Introduction
### IoT Stack for Massive MTC  
Several realizations of the full IoT stack have been discussed in the industry and academia. However, it is likely that convergence to a single option will not happen in the near future due to different characteristics of the large variety of use cases grouped under IoT. Figure 1 depicts different options for the IoT stack on different layers for the massive Machine Type Communication (MTC) use cases. When CoAP [9] is used in the transfer layer, UDP is the default transport assumed. It should be noted though that in the IETF, TCP transport for CoAP is currently discussed [10]. MQTT [11], relies on TCP on the transport layer, while a version for UDP called MQTT-SN has been discussed as well. More broadly, Data Distribution Service for Real-Time Systems typically utilizes UDP, while with Hypertext Transfer Protocol and Advanced Message Queuing Protocol, TCP is used instead by default. To understand how different stacks may impact application level performance and system design, the differences between the two different transports need to be understood. The key differences between TCP and UDP are that UDP is connectionless, light weight, and unreliable, whereas TCP brings more overhead but also reliability with its connection oriented confirmed delivery of packets. A TCP connection requires a three-way handshake between the sensor and the cloud end at the setup phase. On the contrary, a UDP data transmission does not require any setup or bi-directionality; the packet is simply sent from the transmitter end to the receiver end at a suitable time. TCP fast open is a variant of the TCP protocol, which allows data transmission along with TCP SYN and SYN-ACK transmissions [12]. Although TCP fast open will simplify TCP usage for IoT, we have chosen to limit our study on the legacy TCP as it still is widely used. Security is a key part of any IoT stack. There are different ways to provide security and typical options for the discussed stack are to use either Transport Layer Security (TLS) for TCP or Datagram Transport Layer Security (DTLS) for UDP. Security solutions typically bring overhead and may introduce extra handshakes to the procedure as well. However, in this work we assume that the security handshakes have already been performed at an earlier time, e.g., out-of-bound at deployment or manufacturing phase of the sensor life cycle. CoAP is a RESTful application layer transfer protocol specified by the IETF [9]. CoAP typically is run over UDP connections, although work to adapt to TCP is also ongoing [10]. CoAP may be run in two different modes, namely the confirmed delivery mode and the non-confirmed delivery mode. For sensor reporting with relaxed reliability requirement the non-confirmed mode is enough. Confirmations may be also requested only for some packets. CoAP headers are four Bytes long as a minimum. Optional fields may increase header size when needed. MQTT [11] is an application layer publish/subscribe transfer protocol specified by OASIS. In MQTT, topics are set up between the client and the server which are then subscribed and published to. For sensor reporting, the sensor client registers at a server to publish sensor data, and vice versa register for topics to receive updates when needed. MQTT headers are one Byte as a minimum. Optional fields may increase header size when needed. Overview of NB-IoT  
Narrowband Internet of things (NB-IoT) is a cellular radio access technology standardized in 3 rd generation partnership project (3 GPP), and it has been designed to provide low power wide area network (LPWAN) connectivity in licensed spectrum. The design principles for NB-IoT have been  
Figure 1: Different options for the IoT stack. long device battery life, low device complexity, support for massive number of devices and support for high coverage to reach devices in wide areas as well as in challenging locations [13]. As the name suggests, NB-IoT can be deployed in a narrow bandwidth of 200 kHz and offers coverage up to 164 dB maximum coupling loss (MCL).