logo资料库

一张表了解 CoAP 协议.pdf

第1页 / 共1页
资料共1页,全文预览结束
CoAP Message Format
Message types
Method codes
Response codes
Options
Content-Formats
URI schemes
Transmission parameters
Link Format .well-known/core
Block
Observe
References
ConstrainedApplicationProtocol TheConstrainedApplicationProtocol(CoAP)isaspecializedweb transferprotocolforusewithconstrainednodesandconstrained (e.g.,low-power,lossy)networks. CoAPMessageFormat (RFC6690,RFC7252,RFC7959,RFC7641) 2 1 Code TKL | Message ID | Token (if any, TKL bytes) ... Options (if any) ... 0 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 | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1 1 1 1 1 1 1 1| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Ver: Version,T:Type,TKL:TokenLength Payload (if any) ... Messagetypes +------+-----------------+ | Type | Name | +------+-----------------+ | 0 | CONfirmable | | 1 | NON-confirmable | | 2 | ACKnowledgement | | 3 | ReSeT | +------+-----------------+ Methodcodes +------+--------+ | Code | Name | +------+--------+ | 0.00 | EMPTY | +------+--------+ | 0.01 | GET | | 0.02 | POST | | 0.03 | PUT | | 0.04 | DELETE | +------+--------+ | Description Responsecodes 00 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ |class| detail | +-+-+-+-+-+-+-+-+ +------------------+------------------------------+--------------+ | | Code | +------------------+------------------------------+--------------+ | 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 +------------------+------------------------------+--------------+ | Client Error | | 4.00 (128, 0x80) | Bad Request | | | 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 6 5 4 3 2 1 Option Delta (extended) Option Length (extended) Option Value 1 byte 0-2 bytes 0-2 bytes 0 or more bytes 0 7 +---------------+---------------+ | Option Delta | Option Length | +---------------+---------------+ / / \ \ +-------------------------------+ / / \ \ +-------------------------------+ / / +-------------------------------+ +-----+----+---+---+---+----------------+--------+--------+-------------+ | No. | C | U | N | R | Name | | Format | Length | Default +-----+----+---+---+---+----------------+--------+--------+-------------+ | | (none) | opaque | 0-8 | x | If-Match 1 | x | | | | string | 1-255 | (see note 1)| | Uri-Host 3 | x | x | - | | | | x | ETag | 4 | | | opaque | 1-8 | (none) | | | empty | 0 | (none) | 5 | x | | | If-None-Match | | | uint | (see note 1)| | 0-2 7 | x | x | - | | Uri-Port | | x | Location-Path | string | 0-255 | (none) 8 | | | | | 11 | x | x | - | x | Uri-Path | string | 0-255 | (none) | | | (none) | 0-2 | Content-Format | uint | | 12 | | | | | x | - | | 14 | | uint | Max-Age | 0-4 | 60 | | (none) | string | 0-255 | 15 | x | x | - | x | Uri-Query | | uint | Accept | 17 | x | | | | 0-2 | (none) | | x | Location-Query | string | 0-255 | (none) | 20 | | | | (none) | 0-4 | uint | Size2 | x | | | 28 | | | 35 | x | x | - | | Proxy-Uri | string | 1-1034 | (none) | | 39 | x | x | - | | (none) | | Proxy-Scheme | string | 1-255 | 60 | | | x | | Size1 | uint | 0-4 | (none) | +-----+----+---+---+---+----------------+--------+--------+-------------+ C=Critical,U=Unsafe,N=No-Cache-Key,R=Repeatable Note1: takenfromdestinationaddress/portofrequestmessage Content-Formats +--------------------------+-----+ | Id. | | Media type +--------------------------+-----+ | 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 | | +--------------------------+-----+ URIschemes Transmissionparameters coap-URI = "coap:" "//" host [ ":" port ] path-abempty [ "?" query ] coaps-URI = "coaps:" "//" host [ ":" port ] path-abempty [ "?" query ] +-------------------+---------------+ | name | default value | +-------------------+---------------+ | | ACK_TIMEOUT | 2 seconds | ACK_RANDOM_FACTOR | 1.5 | | 4 | MAX_RETRANSMIT | | NSTART | | 1 | | 5 seconds | DEFAULT_LEISURE | 1 Byte/second | | PROBING_RATE +-------------------+---------------+ | 0-3 B | 0-3 B LinkFormat.well-known/core Linkformatcanbeusedtodescribehostedresources,their attributes,andotherrelationshipsbetweenlinks. Example: REQ: GET /.well-known/core RES: 2.05 Content ;ct=40;title="Sensor Index", ;rt="temperature-c";if="sensor", ;rt="light-lux";if="sensor", ;anchor="/sensors/temp";rel="describedby", ;anchor="/sensors/temp";rel="alternate" | Format | Length | Default | uint | (none) | uint | (none) Block InordertotransferlargerpayloadswithCoAP −forinstance,for rmwareupdates −theBlockoptioncanbeused. +-----+---+---+---+---+----------------+--------+--------+----------+ | | No. | C | U | N | R | Name +-----+---+---+---+---+----------------+--------+--------+----------+ | 23 | x | x | - | - | Block2 | | 27 | x | x | - | - | Block1 | +-----+---+---+---+---+----------------+--------+--------+----------+ 00 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ | NUM |M| SZX | +-+-+-+-+-+-+-+-+ 0 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |M| SZX | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |M| SZX | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Observe InordertofollowstatechangesofCoAPresourcestheObserve optioncanbeused. +-----+---+---+---+---+---------+------------+-----------+---------+ | No. | C | U | N | R | Name | Default | +-----+---+---+---+---+---------+------------+-----------+---------+ | | | (none) +-----+---+---+---+---+---------+------------+-----------+---------+ References Thischeatsheetisbasedonandheavilystolefromthefollowing 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 | Format | Observe | uint | Length | 0-3 B | x | - | 1 NUM 6 | NUM 1
分享到:
收藏