没有合适的资源?快使用搜索试试~ 我知道了~
首页一张表了解 CoAP 协议
一张表了解 CoAP 协议
5星 · 超过95%的资源 需积分: 49 190 下载量 167 浏览量
更新于2023-03-16
评论 4
收藏 79KB PDF 举报
国外网友有一张 CheatSheet,把CoAP的主体内容都涵盖进来。我在上面增加了一些备注,方便消化理解。
资源详情
资源评论
资源推荐
Constrained Application Protocol
(RFC 6690, RFC 7252, RFC 7959, RFC 7641)
The Constrained Application Protocol (CoAP) is a specialized web
transfer protocol for use with constrained nodes and constrained
(e.g., low-power, lossy) networks.
CoAP Message Format
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Ver| T | TKL | Code | Message ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Token (if any, TKL bytes) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options (if any) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|1 1 1 1 1 1 1 1| Payload (if any) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Ver: Version, T: Type, TKL: Token Length
Message types
+------+-----------------+
| Type | Name |
+------+-----------------+
| 0 | CONfirmable |
| 1 | NON-confirmable |
| 2 | ACKnowledgement |
| 3 | ReSeT |
+------+-----------------+
Method codes
+------+--------+
| Code | Name |
+------+--------+
| 0.00 | EMPTY |
+------+--------+
| 0.01 | GET |
| 0.02 | POST |
| 0.03 | PUT |
| 0.04 | DELETE |
+------+--------+
Response codes
0
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|class| detail |
+-+-+-+-+-+-+-+-+
+------------------+------------------------------+--------------+
| Code | Description | |
+------------------+------------------------------+--------------+
| 2.01 (65, 0x41) | Created | Success |
| 2.02 (66, 0x42) | Deleted | |
| 2.03 (67, 0x43) | Valid | |
| 2.04 (68, 0x44) | Changed | |
| 2.05 (69, 0x45) | Content | |
| 2.31 (95, 0x5F) | Continue | |
+------------------+------------------------------+--------------+
| 4.00 (128, 0x80) | Bad Request | Client Error |
| 4.01 (129, 0x81) | Unauthorized | |
| 4.02 (130, 0x82) | Bad Option | |
| 4.03 (131, 0x83) | Forbidden | |
| 4.04 (132, 0x84) | Not Found | |
| 4.05 (133, 0x85) | Method Not Allowed | |
| 4.06 (134, 0x86) | Not Acceptable | |
| 4.08 (136, 0x88) | Request Entity Incomplete | |
| 4.12 (140, 0x8C) | Precondition Failed | |
| 4.13 (141, 0x8D) | Request Entity Too Large | |
| 4.15 (143, 0x8F) | Unsupported Content-Format | |
+------------------+------------------------------+--------------+
| 5.00 (160, 0xA0) | Internal Server Error | Server Error |
| 5.01 (161, 0xA1) | Not Implemented | |
| 5.02 (162, 0xA2) | Bad Gateway | |
| 5.03 (163, 0xA3) | Service Unavailable | |
| 5.04 (164, 0xA4) | Gateway Timeout | |
| 5.05 (165, 0xA5) | Proxying Not Supported | |
+------------------+------------------------------+--------------+
Options
0 1 2 3 4 5 6 7
+---------------+---------------+
| Option Delta | Option Length | 1 byte
+---------------+---------------+
/ Option Delta / 0-2 bytes
\ (extended) \
+-------------------------------+
/ Option Length / 0-2 bytes
\ (extended) \
+-------------------------------+
/ Option Value / 0 or more bytes
+-------------------------------+
+-----+----+---+---+---+----------------+--------+--------+-------------+
| No. | C | U | N | R | Name | Format | Length | Default |
+-----+----+---+---+---+----------------+--------+--------+-------------+
| 1 | x | | | x | If-Match | opaque | 0-8 | (none) |
| 3 | x | x | - | | Uri-Host | string | 1-255 | (see note 1)|
| 4 | | | | x | ETag | opaque | 1-8 | (none) |
| 5 | x | | | | If-None-Match | empty | 0 | (none) |
| 7 | x | x | - | | Uri-Port | uint | 0-2 | (see note 1)|
| 8 | | | | x | Location-Path | string | 0-255 | (none) |
| 11 | x | x | - | x | Uri-Path | string | 0-255 | (none) |
| 12 | | | | | Content-Format | uint | 0-2 | (none) |
| 14 | | x | - | | Max-Age | uint | 0-4 | 60 |
| 15 | x | x | - | x | Uri-Query | string | 0-255 | (none) |
| 17 | x | | | | Accept | uint | 0-2 | (none) |
| 20 | | | | x | Location-Query | string | 0-255 | (none) |
| 28 | | | x | | Size2 | uint | 0-4 | (none) |
| 35 | x | x | - | | Proxy-Uri | string | 1-1034 | (none) |
| 39 | x | x | - | | Proxy-Scheme | string | 1-255 | (none) |
| 60 | | | x | | Size1 | uint | 0-4 | (none) |
+-----+----+---+---+---+----------------+--------+--------+-------------+
C=Critical, U=Unsafe, N=No-Cache-Key, R=Repeatable
Note 1: taken from destination address/port of request message
Content-Formats
+--------------------------+-----+
| Media type | Id. |
+--------------------------+-----+
| text/plain;charset=utf-8 | 0 |
| application/link-format | 40 |
| application/xml | 41 |
| application/octet-stream | 42 |
| application/exi | 47 |
| application/json | 50 |
| application/cbor | 60 |
+--------------------------+-----+
URI schemes
coap-URI = "coap:" "//" host [ ":" port ] path-abempty [ "?" query ]
coaps-URI = "coaps:" "//" host [ ":" port ] path-abempty [ "?" query ]
Transmission parameters
+-------------------+---------------+
| name | default value |
+-------------------+---------------+
| ACK_TIMEOUT | 2 seconds |
| ACK_RANDOM_FACTOR | 1.5 |
| MAX_RETRANSMIT | 4 |
| NSTART | 1 |
| DEFAULT_LEISURE | 5 seconds |
| PROBING_RATE | 1 Byte/second |
+-------------------+---------------+
Link Format .well-known/core
Link format can be used to describe hosted resources, their
attributes, and other relationships between links.
Example:
REQ: GET /.well-known/core
RES: 2.05 Content
</sensors>;ct=40;title="Sensor Index",
</sensors/temp>;rt="temperature-c";if="sensor",
</sensors/light>;rt="light-lux";if="sensor",
<http://www.example.com/sensors/t123>;anchor="/sensors/temp";rel="describedby",
</t>;anchor="/sensors/temp";rel="alternate"
Block
In order to transfer larger payloads with CoAP − for instance, for
firmware updates − the Block option can be used.
+-----+---+---+---+---+----------------+--------+--------+----------+
| No. | C | U | N | R | Name | Format | Length | Default |
+-----+---+---+---+---+----------------+--------+--------+----------+
| 23 | x | x | - | - | Block2 | uint | 0-3 B | (none) |
| 27 | x | x | - | - | Block1 | uint | 0-3 B | (none) |
+-----+---+---+---+---+----------------+--------+--------+----------+
0
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
| NUM |M| SZX |
+-+-+-+-+-+-+-+-+
0 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NUM |M| SZX |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NUM |M| SZX |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Observe
In order to follow state changes of CoAP resources the Observe
option can be used.
+-----+---+---+---+---+---------+------------+-----------+---------+
| No. | C | U | N | R | Name | Format | Length | Default |
+-----+---+---+---+---+---------+------------+-----------+---------+
| 6 | | x | - | | Observe | uint | 0-3 B | (none) |
+-----+---+---+---+---+---------+------------+-----------+---------+
References
This cheatsheet is based on and heavily stole from the following
documents:
Link-format: http://tools.ietf.org/html/rfc6690
CoAP: http://tools.ietf.org/html/rfc7252
Block: http://tools.ietf.org/html/rfc7959
Observe: http://tools.ietf.org/html/rfc7641
01
序列号
第4章
0-8bytes 章节5.3.1
Class 0: Request
Class 2
Class 4
Class 5
0xFF 有Payload时会携带这个Marker
第6章
0-12 用增量编码表示OptionNumber
13 8bit extended
14 16bit extender
15 Marker(0xF)/Reserve
章节4.8
资源发现
块传输,空中升级比较有用。
观察者模式
iotisan
- 粉丝: 2209
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 27页智慧街道信息化建设综合解决方案.pptx
- 计算机二级Ms-Office选择题汇总.doc
- 单链表的插入和删除实验报告 (2).docx
- 单链表的插入和删除实验报告.pdf
- 物联网智能终端项目设备管理方案.pdf
- 如何打造品牌的模式.doc
- 样式控制与页面布局.pdf
- 武汉理工Java实验报告(二).docx
- 2021线上新品消费趋势报告.pdf
- 第3章 Matlab中的矩阵及其运算.docx
- 基于Web的人力资源管理系统的必要性和可行性.doc
- 基于一阶倒立摆的matlab仿真实验.doc
- 速运公司物流管理模式研究教材
- 大数据与管理.pptx
- 单片机课程设计之步进电机.doc
- 大数据与数据挖掘.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论4