Professional Documents
Culture Documents
CoAP Protocol CoA
CoAP Protocol CoA
Contents
1Features
2Message formats
3Implementations
4Proxy implementations
5CoAP group communication
6Security issues
7See also
8References
9External links
Features[edit]
The nodes often have 8-bit microcontrollers with small amounts of ROM and
RAM, while constrained networks such as IPv6 over Low-Power Wireless
Personal Area Networks (6LoWPANs) often have high packet error rates and a
typical throughput of 10s of kbit/s. The protocol is designed for machine-to-
machine (M2M) applications such as smart energy and building automation. [1]
The CoRE group has designed CoAP with the following features in mind:
Message formats[edit]
The smallest CoAP message is 4 bytes in length, if omitting Token, Options and
Payload. 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 UDP and optionally to DTLS, providing a high level of communications
security.
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.
CoAP Header
O
ff
Oc
s 0 1 2 3
tet
et
s
O
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
ct Bit 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
et
CoAP
VE Typ Token
4 32 Request/Respons Message ID
R e Length
e Code
8 64
1 Token (0 - 8 bytes)
96
2
1 12
Options (If Available)
6 8
2 16
11 1 11111 Payload (If Available)
0 0
Version (VER) (2 bits)
Indicates the CoAP version number.
Type (2 bits)
Indicates if this message is of type Confirmable (0), Non-confirmable (1),
Acknowledgement (2), or Reset (3)
Token Length (4 bits)
Indicates the length of the variable-length Token field, which may be 0-8
bytes in length.
CoAP Request/Response Code (8 bits)
The three most significant bits form a number known as the "class",
which is analogous to the class of HTTP status codes. The five least
significant bits form a code that communicates further detail about the
request or response. The entire code is typically communicated in the
form class.code . You can find the latest CoAP request/response codes
at [3], though the below list gives some examples:
Method: Client Server
0.XX Error : 4.XX Error : 5.XX
1. EM 1. Bad 1. Inter
PTY Reques nal
2. GE t Server
T Error
2. Unau
3. PO thorized 2. Not
ST Imple
3. Bad mente
4. PU Option d
T
4. Forbi 3. Bad
5. DE dden Gatew
LETE ay
5. Not
6. FE Found 4. Servi
TCH ce
6. Meth
7. PA od Not Unavai
TCH Allowed lable
You can easily extract the information from the fixed header in C via
these macros:
Implementations[edit]
Imple
Implem
Progra mente
ented
Na mming d Client/ Licen
CoAP Link
me Langu CoAP Server se
feature
age versio
s
n
Blockwi
se
Client Transfe
aioco Python RFC https://pypi.python.org/py
+ rs, MIT
ap 3 7252 pi/aiocoap
Server Observ
e
(partial)
rs,
DTLS
Client
cantc RFC https://github.com/staropr
C++/C + BSD
oap 7252 am/cantcoap
Server
Apach
Client
Cano RFC e https://github.com/zubair
Go + Core
pus 7252 Licen hamed/canopus
Server
se 2.0
CoAP
imple Core +
Client
ment RFC Draft https://github.com/dustin/
Go + MIT
ation 7252 Subscri go-coap
Server
for be
Go
RFC
Core,
7252,
Observ
coap- 3-
Client e,
CoAP 13, claus https://github.com/smesh
C# + Blockwi
.NET coap- e link/CoAP.NET
Server se
08, BSD
Transfe
coap-
rs
03
Observ
Shar + e,
.NET 7252 m
p Server Block,
RD
Observ
Client e,
+ Multica
Server st
+ server
Forwar discove
CoAP RFC https://github.com/Tanga
Python d ry, MIT
thon 7252 nelli/CoAPthon
Proxy CoRE
+ Link
Revers Format
e parsing,
Proxy Block-
wise
Observ
e,
Apach
Blockwi
CoAP RFC e https://github.com/tzolov/
Java Client se
Shell 7252 Licen coap-shell
Transfe
se 2.0
rs,
DTLS
Transfe
Plugin) BSD /copper-270430/
rs
Client
eCoA RFC https://gitlab.com/jobol/ec
C + Core MIT
P 7252 oap
Server
Observ
Erbiu e, 3-
Client
m for RFC Blockwi claus http://www.contiki-os.org/
C +
Conti 7252 se e (er-rest-example)
Server
ki Transfe BSD
rs
Core,
Observ
e,
iCoA Objecti RFC https://github.com/stuffra
Client Blockwi MIT
P ve-C 7252 bbit/iCoAP
se
Transfe
rs
Observ
e, Apach
Client
jCoA RFC Blockwi e https://code.google.com/
Java +
P 7252 se Licen p/jcoap/
Server
Transfe se 2.0
rs
Imple
Implem
Progra mente
ented
Na mming d Client/ Licen
CoAP Link
me Langu CoAP Server se
feature
age versio
s
n
Observ
e,
Client Blockwi
libcoa RFC BSD/ https://github.com/obgm/l
C + se
p 7252 GPL ibcoap
Server Transfe
rs,
DTLS
Core,
Client Observ
LibNy RFC https://github.com/darcon
C + e, MIT
oci 7252 eous/libnyoci
Server Block,
DTLS
Observ
e,
lobar Client
RFC Blockwi http://www.lobaro.com/lo
o- C + MIT
7252 se baro-coap
coap Server
Transfe
rs
Client
micro RFC https://github.com/1248/
C + MIT
coap 7252 microcoap
Server
rs,
CoRE
Link
Format,
Endpoi
nt-ID-
Draft
Client Core,
node- Javascr RFC https://github.com/mcollin
+ Observ MIT
coap ipt 7252 a/node-coap
Server e, Block
Core,
Client https://github.com/nning/
Observ
Ruby RFC + MIT, coap
Ruby e,
coap 7252 Server GPL https://github.com/nning/
Block,
(david) david
RD
Sensi
node Core,
C Client Observ Com
RFC https://silver.arm.com/bro
Devic C + e, merci
7252 wse/SEN00
e Server Block, al
Librar RD
y
e
Librar RD
y
Sensi
node Core,
Nano Observ Com
Java RFC Cloud https://silver.arm.com/bro
Servi e, merci
SE 7252 Server wse/SEN00
ce Block, al
Platfo RD
rm
Core,
Observ
Client e,
Swift RFC https://github.com/stuffra
Swift + Blockwi MIT
CoAP 7252 bbit/SwiftCoAP
Server se
Transfe
rs
Observ
Tiny e,
Client
OS coap- Blockwi http://docs.tinyos.net/tiny
nesC/C + BSD
Coap 13 se wiki/index.php/CoAP
Server
Blip Transfe
rs
rs,
Observ
e
(partial)
Client
Core,
+
DTLS,
Server
Free RFC Blockwi https://github.com/keith-
C + BSD
CoAP 7252 se cullen/FreeCoAP
HTTP/
Transfe
CoAP
rs
Proxy
Client
coap- RFC https://github.com/Covert
Rust + MIT
rs 7252 ness/coap-rs
Server
YaCo https://github.com/RIOT-
C MIT
AP Makers/YaCoAP
Proxy implementations