Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does the CoAP protocol of the IoT Internet of things mean?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly analyzes the relevant knowledge of what the CoAP protocol of the IoT Internet of things means, the content is detailed and easy to understand, the operation details are reasonable, and has a certain reference value. If you are interested, you might as well follow the editor to have a look, and follow the editor to learn more about "what the CoAP protocol of the IoT Internet of things means".

CoAP is an abbreviation for restricted Application Protocol (Constrained Application Protocol). In the IoT Internet of things scenario, in order to enable small devices to access the Internet, CoAP protocol is designed. CoAP is an application layer protocol that runs on the UDP protocol rather than on TCP as HTTP does. The CoAP protocol is so small that the smallest packet is only 4 bytes.

CoAP is a network-oriented protocol, which adopts similar characteristics as HTTP. The core contents are resource abstraction, REST-like interaction and scalable header options. In order to overcome the disadvantage of HTTP for constrained environment, CoAP takes into account not only the optimization of Datagram length, but also the provision of reliable communication. On the one hand, CoAP provides URI,REST-style methods such as GET,POST,PUT and DELETE, as well as the extensibility provided by header options that can be defined independently. On the other hand, CoAP is based on the lightweight UDP protocol and allows IP multicast. In order to make up for the unreliability of UDP transmission, CoAP defines a transaction mechanism with retransmission mechanism. It also provides a resource discovery mechanism with a resource description.

Characteristics of the protocol

Based on message model

Request / response model

Two-way communication

Light weight and low power consumption

Support reliable transmission

Support IP Multicast

Non-persistent communication, supporting restricted devices

Support observation mode

Support for asynchronous communication

Content of the agreement

CoAP is a complete binary application layer protocol with compact message format and runs on UDP by default.

CoAP message

[Ver] version number.

[t] message type, CoAP protocol defines four different forms of message, CON message, NON message, ACK message and RST message.

[TKL] CoAP identifier length. In CoAP protocol, there are two kinds of identifiers with similar functions, one is Message ID (message number), the other is Token (identifier). Each of these messages contains a message number, but the identifier is not necessary for the message.

[Code] function code / response code. Code has different forms in CoAP request message and response message. Code occupies one byte. It is divided into two parts, the first three bits and the last five bits. In order to describe it conveniently, it is written as c.dd structure. Where 0.XX represents a method of an CoAP request, and 2.XX, 4.XX, or 5.XX represents a specific representation of the CoAP response.

[Message ID] message number.

[Token] the specific content of the identifier, which specifies the Token length through TKL.

[Option] message options, through which you can set the CoAP host, CoAP URI,CoAP request parameters, load media type, and so on.

[1111 1111B] the separator between the CoAP message and the specific payload.

Request method

0.01 GET: get resources

0.02 POST: create a resource

0.03 PUT: update resources

0.04 DELETE: delete resources

Response code Success 2.xx

This type of status code indicates that the request has been successfully received, understood, and accepted by the server.

2.01 Created

2.02 Deleted

2.03 Valid

2.04 Changed

2.05 Content

Client Error 4.xx

This type of status code means that the client appears to have made an error, interfering with the server's processing.

4.00 Bad Request

4.01 Unauthorized

4.02 Bad Option

4.03 Forbidden

4.04 Not Found

4.05 Method Not Allowed

4.06 Not Acceptable

4.12 Precondition Failed

4.13 Request Entity Too Large

4.15 Unsupported Content-Format

Server Error 5.xx

This kind of status code represents that there is an error or abnormal state in the process of processing the request, or it may be that the software and hardware resources of the server can not complete the processing of the request.

5.00 Internal Server Error

5.01 Not Implemented

5.02 Bad Gateway

5.03 Service Unavailable

Media type working mode

CoAP refers to a lot of HTTP design ideas, but also improves a lot of design details and adds a lot of practical functions according to the specific conditions of limited resource-limited devices.

Message type

CON: a request that needs to be acknowledged, and if a CON request is sent, the other party must respond.

NON: the request does not need to be acknowledged, and if the NON request is sent, then the other party does not have to respond.

ACK: reply message, receiving the response of the CON message.

RST: reset message. When the receiver receives a message that contains an error, the receiver parses the message or no longer cares about what the sender sends, then the reset message will be sent.

Request / response model

1. Carrying mode

two。 Separation mode

3. Non-confirmation mode

URI of CoAP protocol

In the world of HTTP, formal RESTFul protocols are becoming more and more popular in WEB applications because of their simplicity and applicability, which is also applicable to CoAP. A CoAP resource can be described by a URI, for example, a device can measure temperature, then the URI of the temperature sensor is described as: CoAP://machine.address:5683/sensors/temperature.

The default UDP port number for CoAP is 5683HTTP and CoAP comparison

HTTP stands for hypertext transfer protocol, and CoAP stands for constraint application protocol

The transport layer of HTTP protocol adopts TCP,CoAP protocol, and the transport layer of TCP,CoAP protocol uses UDP.

CoAP protocol is a simplified version of HTTP protocol.

The CoAP protocol uses the request / response model and has the same method as the HTTP protocol.

CoAP has lower overhead and supports multicast

CoAP is designed for resource composition applications, such as IoT/WSN/M2M, etc.

Comparison between CoAP and MQTT

The MQTT protocol uses the publish / subscribe model and the CoAP protocol uses the request / response model.

MQTT is persistent connection, CoAP protocol is connectionless.

MQTT is a many-to-many protocol for message delivery through intermediary agents. CoAP protocol is an one-to-one protocol for message delivery between Server and Client.

MQTT does not support tag messages with types or other help Clients understand, and CoAP has built-in content negotiation and discovery support that allows devices to snoop on each other to find ways to exchange data.

This is the end of the introduction on "what is the meaning of the CoAP protocol of the IoT Internet of things". More related content can be searched for previous articles, hoping to help you answer questions and questions, please support the website!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report