Constrained Application Protocol: Difference between revisions

Content deleted Content added
Security issues: space units
DrTobbe (talk | contribs)
Message formats: Reorganize the messages format introduction (high-level view in the first paragraph, structure in the second paragraph) and fix naming: "header" denotes only the first 4 bytes, "payload" is the correct name of what was called "message body" before according to the spec
Line 16:
 
==Message formats==
The smallest CoAP message is 4 bytes in length, if the token, options and payload fields are omitted. CoAP makes use of two message types, requests and responses, using a simple, binary, base header format. The base header may be followed by options in an optimized type–length–value format. CoAP is by default bound to [[User Datagram Protocol|UDP]] and optionally to [[DTLS]], providing a high level of communications security. When bound to UDP, the entire message ''must'' fit within a single datagram. When used with [[6LoWPAN]] as defined in RFC 4944, messages ''should'' fit into a single [[IEEE 802.15.4]] frame to minimize fragmentation.
 
The smallest CoAP message is 4 bytes in length, if the token, options and payload fields are omitted, i.e. if it only consists of the CoAP header. The header is followed by the token value (0 to 8 bytes) which may be followed by a list of options in an optimized type–length–value format. Any bytes after the header, token and options (if any) are considered the message payload, which is prefixed by the one-byte "payload marker" (0xFF). The length of the payload is implied by the datagram length.
Any bytes after the headers in the packet are considered the message body. The length of the message body is implied by the datagram length. When bound to UDP, the entire message ''must'' fit within a single datagram. When used with [[6LoWPAN]] as defined in RFC 4944, messages ''should'' fit into a single [[IEEE 802.15.4]] frame to minimize fragmentation.
{| class="wikitable" style="margin: 0 auto; text-align:center"
|+ CoAP HeaderMessage
! [[Octet (computing)|Octet]] offset !! !! colspan="8" | 0 !! colspan="8" | 1 !! colspan="8" | 2 !! colspan="8" | 3
|-