Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 12

Constrained Application Protocol (CoAP) is a specialized Internet Application

Protocol for constrained devices, as defined in RFC 7252. It enables those


constrained devices called "nodes" to communicate with the wider Internet using
similar protocols. CoAP is designed for use between devices on the same
constrained network (e.g., low-power, lossy networks), between devices and
general nodes on the Internet, and between devices on different constrained
networks both joined by an internet. CoAP is also being used via other
mechanisms, such as SMS on mobile communication networks.
CoAP is a service layer protocol that is intended for use in resource-constrained
internet devices, such as wireless sensor networknodes. CoAP is designed to
easily translate to HTTP for simplified integration with the web, while also
meeting specialized requirements such as multicast support, very low overhead,
and simplicity.[1][2] Multicast, low overhead, and simplicity are extremely important
for Internet of Things (IoT) and Machine-to-Machine (M2M) devices, which tend
to be deeply embedded and have much less memory and power supply than
traditional internet devices have. Therefore, efficiency is very important. CoAP
can run on most devices that support UDP or a UDP analogue.
The Internet Engineering Task Force (IETF) Constrained RESTful Environments
Working Group (CoRE) has done the major standardization work for this
protocol. In order to make the protocol suitable to IoT and M2M applications,
various new functionalities have been added. The core of the protocol is
specified in RFC 7252; important extensions are in various stages of the
standardization process.

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:

 Overhead and parsing complexity.


 URI and content-type support.
 Support for the discovery of resources provided by known CoAP services.
 Simple subscription for a resource, and resulting push notifications.
 Simple caching based on max-age.

The mapping of CoAP with HTTP is also defined, allowing proxies to be built


providing access to CoAP resources via HTTP in a uniform way.[3]
With the introduction of CoAP, a complete networking stack of open-standard
protocols that are suitable for constrained devices and environments becomes
available.[4]
From the architecture point of view, the CoAP server will be installed on the end
node, which could be a sensor. On the other hand, the CoAP client should be
installed on the controller, which manages several end nodes.
Registration of the meanings behind CoAP Code, Options and Content Type is
handled by IANA, shown in [2]

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

8. iPA 7. Not 5. Gate


TCH Accept way
able Timeo
 Success : ut
2.XX 8. Requ 6. Prox
1. Cre est ying
ated Entity Not
Incompl Suppor
2. Del ete ted
eted
9. Confli  Signaling
3. Val ct Codes : 7.XX
id
12. Preco 1. Unas
4. Ch ndition signed
ange Failed
d 2. CSM
13. Requ
5. Co est 3. Ping
ntent Entity
4. Pong
Too
31. Co Large 5. Rele
ntinu ase
e 15. Unsu
pported 6. Abor
Content t
-Format
Message ID (16 bits)
Used to detect message duplication and to match messages of type
Acknowledgement/Reset to messages of type Confirmable/Non-
confirmable.

You can easily extract the information from the fixed header in C via
these macros:

#define COAP_HEADER_VERSION(data) ( (0xC0 & data[0])>>6 )


#define COAP_HEADER_TYPE(data) ( (0x30 & data[0])>>4 )
#define COAP_HEADER_TKL(data) ( (0x0F & data[0])>>0 )
#define COAP_HEADER_CLASS(data) ( ((data[1]>>5)&0x07) )
#define COAP_HEADER_CODE(data) ( ((data[1]>>0)&0x1F) )
#define COAP_HEADER_MID(data) ( (data[2]<<8)|(data[3]) )

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)

Califo Java RFC Client Observ EPL+ https://www.eclipse.org/c


rnium 7252 + e, EDL alifornium
Server Blockwi
se
Transfe
Imple
Implem
Progra mente
ented
Na mming d Client/ Licen
CoAP Link
me Langu CoAP Server se
feature
age versio
s
n

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

CoAP C#, RFC Client Core, LGPL http://www.coapsharp.co


Imple
Implem
Progra mente
ented
Na mming d Client/ Licen
CoAP Link
me Langu CoAP Server se
feature
age versio
s
n

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

Copp JavaSc RFC Client Observ 3- https://github.com/mkova


er ript 7252 e, claus tsc/Copperhttps://addons
(Brows Blockwi e .mozilla.org/firefox/addon
er se
Imple
Implem
Progra mente
ented
Na mming d Client/ Licen
CoAP Link
me Langu CoAP Server se
feature
age versio
s
n

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

nCoa Java RFC Client Observ BSD https://github.com/oklein


p 7252 + e, e/nCoAP
Server Blockwi
se
Transfe
Imple
Implem
Progra mente
ented
Na mming d Client/ Licen
CoAP Link
me Langu CoAP Server se
feature
age versio
s
n

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

Sensi Java RFC Client Core, Com https://silver.arm.com/bro


node SE 7252 + Observ merci wse/SEN00
Java Server e, al
Devic Block,
Imple
Implem
Progra mente
ented
Na mming d Client/ Licen
CoAP Link
me Langu CoAP Server se
feature
age versio
s
n

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

txThi Python RFC Client Blockwi MIT https://github.com/mwasil


ngs (Twiste 7252 + se ak/txThings/
d) Server Transfe
Imple
Implem
Progra mente
ented
Na mming d Client/ Licen
CoAP Link
me Langu CoAP Server se
feature
age versio
s
n

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

You might also like