# An Efficient Interface for the Integration of IoT Devices with Smart Grids
## 2 Background
### IoT Communication Protocols  
In IoT, communication devices and networks are not isolated but connected and integrated to form a computer network. This feature brings the need for regular communication within the computer network, but it is constrained by the devices that make up IoT systems, which has limited power supply and storage and processing capacities.  
Traditional protocols, such as Transmission Control Protocol (TCP), do not deal well with the limitations imposed by IoT devices, given the overheads generated by the process layers in these protocols. Furthermore, these protocols face addressing issues with each device. One of the alternatives to solve this problem was the adoption of Internet Protocol v6 (IPv6) and its new concepts, such as IPv6 over Low power Wireless Personal Area Networks (6 LoWPAN), conceived of the idea of assigning an address to computationally restricted devices [16]. To this end, the Internet Engineering Task Force (IETF) and other standards bodies have defined and developed application protocols for resource-constrained devices. Examples of protocols developed by IETF are CoAP and Routing Protocol for Low Power and Lossy Networks (RPL) [17].  
In addition to CoAP, other protocols are used to develop solutions for IoT, especially when focusing on Machine-to-Machine (M2M) communication. These alternatives may include: (i) MQTT; (ii) Extensible Messaging and Presence Protocol (XMPP); (iii) RESTful Services; (iv) Advanced Message Queuing Protocol (AMQP); (v) Data Distribution Service (DDS); (vi) OSGP; (vii) Open Platform Communication (OPC); and (viii) OPC Unified Architecture (UA). The two most common types of communication in IoT are request/response, as in CoAP, and publish/subscribe, used in MQTT.  
The MQTT protocol was introduced by IBM in 1999 and standardized by OASIS in 2013 [18]. This protocol provides built-in connectivity between applications, middleware, networks, and communication technology. MQTT is asynchronous, based on publish/subscribe communication, and is made up of a broker (who contains topics) and several clients (who publish or subscribe to the topics). A client can send data to a topic or receive data from a topic it subscribes as a publisher updates this topic. This protocol has reliability on three Quality of Service (QoS) levels: (i) fire and forget; (ii) delivered at least once; (iii) delivered exactly once. MQTT executes over TCP, and thus security is performed using the services of this protocol [18; 19; 20; 21]. MQTT and RESTfull are nowadays the most widely accepted and supported communication protocols for IoT, but CoAP might as well establish itself as a messaging standard in the future [22].  
CoAP is a synchronous request/response protocol developed for use with resource-constrained devices. It uses communication methods from Hypertext Transfer Protocol (HTTP), such as PUT, POST, GET, and DELETE, which allows these two protocols to work together [23]. CoAP allows interactions following a client/server architecture and has a lightweight implementation because it operates over User Datagram Protocol (UDP). The reliability mechanisms are implemented through two bits in the packet header, which define the message type and the QoS level. The messages can be: (i) commitable; (ii) unverifiable; (iii) recognition; and (iv) reset [17; 18; 20]. Figure 1 simply illustrates the protocol stack of CoAP by identifying its two layers.