CoAP protocol learning notes-CoAP format details (1)

Source: Internet
Author: User

CoAP protocol learning notes-CoAP format details (1)

CoAP is synonymous with restricted Application protocols. In the current world composed of PCs, information exchange is achieved through TCP and the application layer protocol HTTP. However, for small devices, implementing TCP and HTTP protocols is obviously an excessive requirement. To allow small devices to access the Internet, the CoAP protocol is designed. CoAP is an application layer protocol that runs over UDP rather than over TCP as HTTP. The CoAP protocol is very small, and the minimum data packet is only 4 bytes.

1. CoAP protocol Overview

Like the protocols in other tcp ip protocol clusters, the CoAP protocol always appears in the form of a "Header" before the load, while the load and CoAP headers are separated by a single byte 0xFF. The best way to learn the CoAP protocol is to analyze each part of the CoAP protocol message format in detail in combination with the RFC documentation. It is the CoAP Protocol packet structure.

Figure 1.1 CoAP Protocol packet structure

2 CoAP protocol packets

Ver indicates the version number of the CoAP protocol. Similar to HTTP 1.0 HTTP 1.1. The version number occupies 2 digits and the value is 01B.

T] Message type. The CoAP Protocol defines four different types of packets: CON, NON, ACK, and RST.

TKL: length of the CoAP identifier. CoAP has two similar identifiers: Message ID and Token ). Each packet contains a message ID, but the identifier is not required for the message.

Code: Function Code/response Code. Code has different forms in the CoAP request message and Response Message. Code occupies one byte and is divided into two parts: the first three parts and the last five parts, it is written as c. dd structure. 0. XX indicates a method of CoAP request, while 2.xx, 4. XX or 5. XX indicates a specific manifestation of CoAP response.

Message ID: the number of the Message.

Token: Specifies the Token length through TKL.

Option: Message Option. You can set the CoAP host, CoAP URI, CoAP request parameters, and load media type.

1111 11b: the delimiter between the CoAP message and the specific load.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.