UNIT 5- IoT Protocols.pdf
Document Details
Tags
Full Transcript
SYLLABUS: UNIT-1: Introduction to IOT UNIT-2: Arduino Simulation Environment UNIT-3: Interfacing Arduino Uno with I/O devices UNIT-4: Interfacing Arduino with Sensors and Actuators UNIT-5: IoT Protocols UNIT-6: Cloud Platforms for IOT...
SYLLABUS: UNIT-1: Introduction to IOT UNIT-2: Arduino Simulation Environment UNIT-3: Interfacing Arduino Uno with I/O devices UNIT-4: Interfacing Arduino with Sensors and Actuators UNIT-5: IoT Protocols UNIT-6: Cloud Platforms for IOT 1 UNIT 5: IoT Protocols M2M vs. IOT Basics of IoT communication protocols: – HTTP – AMQP – Websocket – MQTT – CoAP – XMPP WiFi module ESP8266 pin configuration Interfacing ESP8266 with Arduino. 2 IoT Protocols Protocols are a set of rules for transmitting data between electronic devices according to a preset agreement regarding information structure and how each side will send and receive data. IoT communication protocols are modes of communication that protect and ensure optimum security to the data being exchanged between connected devices 3 IoT Protocols IoT Protocols Should also Satisfy These Requirements Allow communication among various devices simultaneously. IoT is being used in critical areas like health, industries, home surveillance, etc. hence communication security needs to be ensured. Transport data efficiently. IoT devices can be added or removed from the IoT network. Hence protocols must provide scalability. 4 IoT Protocols 5 IoT Protocols IoT data /Communication protocols: used for presentation or application layers. provide point-to-point communication with the hardware at the user side without any Internet connection. Connectivity in IoT data protocols is through a wired or a cellular network. Network protocols: used for datalink and physical layers. used to connect devices over the network. typically used over the Internet Provide end-to-end data communication within the scope of the network 6 IoT Protocols 7 M2M vs IoT Internet of Things (IoT): IoT refers to a network of interconnected devices or "things" embedded with sensors, software, and connectivity capabilities. These devices can communicate with each other and with centralized systems via the Internet, enabling data exchange and automation of processes. Machine-to-Machine (M2M): M2M, on the other hand, specifically denotes direct communication between devices without human intervention. It involves the exchange of data or commands between machines, typically over a network such as cellular or wired connections. 8 M2M vs IoT 9 M2M vs IoT 10 Importance of IoT protocols Users can engage with and control devices based on the information and orders that are transmitted to them. Protocols for the Internet of Things (IoT) are an essential component of the IoT technological stack which facilitate this exchange of information between nodes in the network. In the absence of standardized protocols for the IoT, the hardware would be completely worthless. The protocols are directly related to access, storage, and distribution of data through the IoT network. The data may be transferred between clients and servers as well as between brokers and subscribers in the IoT ecosystem. Eg: HTTP, AMQP, Websocket, MQTT, CoAP, XMPP 11 Basics of IoT communication protocols: IoT communication protocols: – HTTP – AMQP – Websocket – MQTT – CoAP – XMPP 12 HTTP HTTP: HyperText Transfer Protocol. Developed by Tim Berners-Lee and his team between 1989-1991 Used to access the data on the World Wide Web (www). It is a protocol used for transmitting hypertext over the internet and is the basis for web communication. Used to transfer the data in the form of plain text, hypertext, audio, video, and so on. It is the most common protocol that is used for IoT devices when there is a lot of data to be published. In this protocol the communication generally takes place over a (Transmission Control Protocol) TCP/IP protocol. It also works over (User Datagram Protocol) UDP. Used to carry the data in the form of Multipurpose Internet Mail Extensions (MIME)-like format. Connectionless protocol: The connection between client and server exist only during the current request and response time only. Media independent: As data can be sent as long as both the client and server know how to handle the data content. Stateless: Both the client and server know each other only during the current request. HTTP HTTP Architecture: HTTP Client Server HTTP transaction between client and server HTTP HTTP Methods: A client can use any of these request methods to send a request message to an HTTP server. HEAD method: A client can use the HEAD request to get the header that a GET request would have obtained. This is useful for retrieving meta- information written in response headers, without having to transport the entire content. GET method: used to get the data from the server. POST Method: Used to post data to the webserver. It is a safe method because it does not modify the state of the server. PUT method: Ask the server to store the data. It will update or replace existing data on the server HTTP Advantages of HTTP Memory usage and CPU usage are low because of fewer simultaneous connections. Since there are few TCP connections hence network congestion is less. Since handshaking is done at the initial connection stage, then latency is reduced because there is no further need for handshaking for subsequent requests. The error can be reported without closing the connection. HTTP allows HTTP pipe-lining of requests or responses. HTTP Disadvantages of HTTP HTTP requires high power to establish communication and transfer data. HTTP is less secure because it does not use any encryption method like HTTPS. HTTP is not optimized for cellular phones. HTTP does not offer a genuine exchange of data because it is less secure. The client does not close the connection until it receives complete data from the server; hence, the server needs to wait for data completion and cannot be available for other clients during this time. AMQP AMQP or the advanced message queuing protocol is an open standard middleware at the application layer developed for message-oriented operations. AMQP is a message-oriented protocol, that focuses on the reliable delivery of discrete messages between systems. Each message is treated as an atomic unit of data. AMQP ensures: Reliability of message deliveries Rapid and ensured delivery of messages Message acknowledgements 19 AMQP Architecture AMQP Working : The message is the core element of the whole communication. The publisher creates a message and sends it. The messaging broker distributes the message to different queues according to defined rules.eg. RabbitMQ. The consumer/subscriber takes the message out of the queue that they can access. 20 AMQP Applications of AMPQ: It is used whenever there is a need for high-quality and safe delivery of messages between applications and processes. AMQP can be used in : Monitoring and globally sharing updates Connecting different systems to talk to each other Allowing servers to respond to immediate requests quickly and delegate time consuming tasks for later processing Distributing a message to multiple recipients for consumption WebSocket Websocket follows OSI layer seven protocol which enables reliable and full-duplex communication channels over a single TCP connection It is a powerful communication protocol that allows for bidirectional and continuous communication between a server and its clients over a single TCP connection (instead of two). WebSockets used in real-time applications such as browser- based chatrooms, live sports trackers, multiplayer video games etc. WS enables client–server interactions over the Web. Web servers and clients such as browsers can transfer real-time data between them without incurring many overheads. Upon establishment of a connection, servers can send content to 22 clients without the clients requesting them first. WebSocket WebSocket Architecture 23 WebSocket Functions of Web Sockets: The steps for establishing the connection of Web Socket are as follows − The client establishes a connection through a process known as Web Socket handshake(open event). The process begins with the client sending a regular HTTP request to the server. An Upgrade header is requested. In this request, it informs the server that request is for Web Socket connection. Web Socket URLs use the ws scheme. They are also used for secure Web Socket connections. WebSocket Advantages of web socket: Bidirectional Full Duplex Low Latency: due to Single TCP Connection WebSocket Disadvantages of web socket: If a connection over WebSockets is lost, there are no included mechanisms for reconnecting. WebSockets do not support caching, (stores a response associated with a request and reuses the stored response for subsequent requests) like HTTP. WebSockets are not optimized for streaming audio and video data MQTT Specially designed for machine-to-machine (M2M) communication and IoT connectivity. lightweight Publish/Subscribe messaging protocol invented at IBM send frequency message with less payload. runs over Transmission Control Protocol (TCP) It is used by devices which are economical and requires less power and memory in low bandwidth. 27 MQTT Architecture The components of the MQTT architecture are: Message: data that is carried out by the protocol across the network for the application. each message contains a message content, the so-called payload. Client: subscriber and publisher are the two roles of a client. Server or Broker: allows the client to publish the messages and subscribe to the messages. TOPIC: label provided to the message is checked against the subscription known by the server 28 MQTT Message queue telemetry transport or MQTT is a simple, lightweight publish–subscribe protocol, designed mainly for messaging in constrained devices and networks. It provides a one-to-many distribution of messages reliably and flawlessly over high latency and limited bandwidth without the need for significant device resources and device power. The MQTT paradigm consists of numerous clients connecting to a server; this server is referred to as a broker. The clients can have the roles of information publishers (sending messages to the broker) or information subscribers (retrieving messages from the broker). This allows MQTT to be largely decoupled from the applications being used with MQTT. 29 MQTT Advantages of MQTT: Lightweight and Efficient: message headers are small to optimize network bandwidth. Bi-directional Communications: device to cloud and vice-versa. Reliable Message Delivery Support for Unreliable Networks Security Enabled: easy to encrypt messages using TLS (Transport Layer Security) 30 MQTT Disadvantages of MQTT: DOES NOT Support Video Streaming. does not support advanced features such as flow control. Issues with Latency Security Not Built In MQTT uses TCP protocol which requires more processing power and more memory. The number of times devices can be put to sleep is limited. 31 CoAP It is useful in M2M data exchange. provides the RESTful (HTTP) interface between HTTP client (low power sensors) and server designed for constrained devices (such as microcontrollers) and constrained networks primarily based on HTTP protocols. At a lower level, CoAP messages are sent and received over User Datagram Protocol (UDP), which by nature is unreliable, so a basic reliability scheme is built into CoAP on top of UDP. For security aspect to protect the information, CoAP protocol uses Datagram Transport layer security (DTLS) over UDP. CoAP provides a request/response interaction model between application endpoints. 32 CoAP The constrained application protocol, or CoAP is designed for use as a web transfer protocol in constrained devices and networks, which are typically low power and lossy. The constrained devices typically have minimal RAM and an 8-bit processor at most, high error rates, and bandwidth in the range of kilobits. CoAP follows a request–response paradigm for communication over these lossy networks. Additional highlights of this protocol include support for service discovery, resource discovery, URIs (uniform resource identifier), Internet media handling support, easy HTTP integration, and multicasting support, that too while maintaining low overheads. CoAP implementations can act as both clients and servers (not simultaneously). A CoAP client’s request signifies a request for action from an identified resource on a server, which is similar to HTTP. The response sent by the server in the form of a response code can contain resource representations. 33 CoAP Advantages of CoAP: The packet size used is very small thus maximizing the use of memory efficiently and allowing for faster communication. It operates over UDP, devices can sleep for extended periods and wake up quickly. This in turn helps to save battery and optimize power usage. CoAP allows for asynchronous message exchanges. Sensor nodes can send their messages to a multicast group. 34 CoAP Disadvantages of CoAP: It is not an encrypted protocol. In the case of Network Address Translation devices being used, CoAP can have problems since the IP can be a dynamic IP. CoAP is also an evolving (developing gradually) and maturing (to be fully developed) standard. 35 XMPP The extensible messaging and presence protocol, or XMPP, which was initially named as Jabber, is designed for message-oriented middlewares based on the extensible markup language (XML). XMPP was developed for instant messaging, maintenance of contacts, and information about network presence. Structured and extensible data between two networked nodes/devices can be exchanged in near realtime using this protocol. XMPP has found use in VOIP (voice-over Internet protocol) presence signaling, video and file transfers, smart grid, social networks, publish– subscribe systems, IoT applications, and others. As XMPP follows a client–server architecture. 36 XMPP XMPP Architecture XMPP XMPP Advantages: It is free and decentralized which means anyone can set up an XMPP server. It is based on open standards. It supports multiple implementations of clients and servers. It is flexible, XML-based and can be extended. So, suitable for both instant messaging features and custom cloud services. Security is supported via SASL and TLS. 38 XMPP Disadvantages of XMPP: XMPP does not support Quality of Service (QoS). Server may overload with presence and instant messaging. 39