Constrained Application Protocol: Difference between revisions

Content deleted Content added
ce
 
(208 intermediate revisions by more than 100 users not shown)
Line 1:
{{Short description|Specialized Internet application protocol}}
{{context|date=August 2011}}
{{IP stack}}
 
'''Constrained Application Protocol''' ('''CoAP''') is a specialized [[User Datagram Protocol|UDP-based]] Internet application protocol for constrained devices, as defined in [https://datatracker.ietf.org/doc/html/rfc7252 RFC 7252] (published in 2014). It enables those constrained devices called "nodes" to communicate with the wider Internet using similar protocols.
'''Constrained Application Protocol''' (CoAP) is a software protocol intended to be used in very simple electronics devices that allows them to communicate interactively over the Internet. It is particularly targeted for small low power sensors, switches, valves and similar components that need to be controlled or supervised remotely, through standard Internet networks.
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 an [[application layer]] protocol that is intended for use in resource-constrained internet devices, such as [[WSN]] nodes. 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.<ref>[https://datatracker.ietf.org/doc/draft-ietf-core-coap Internet Draft describing Constrained Application Protocol (CoAP)]</ref><ref>"[http://hinrg.cs.jhu.edu/joomla/images/stories/IPSN_2011_koliti.pdf Integrating Wireless Sensor Networks with the Web]" , Walter, Colitti 2011</ref> 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 system|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 [[User Datagram Protocol|UDP]] or a UDP analogue.
 
CoAP is an application-layer protocol that is intended for use in resource-constrained Internet devices, such as [[wireless sensor network]] nodes. 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.<ref>[https://tools.ietf.org/html/rfc7252 RFC 7252, Constrained Application Protocol (CoAP)]</ref><ref>"[http://hinrg.cs.jhu.edu/joomla/images/stories/IPSN_2011_koliti.pdf Integrating Wireless Sensor Networks with the Web] {{Webarchive|url=https://web.archive.org/web/20170830060917/http://hinrg.cs.jhu.edu/joomla/images/stories/IPSN_2011_koliti.pdf |date=2017-08-30 }}" , Walter, Colitti 2011</ref> Multicast, low overhead, and simplicity are important for [[Internet of things]] (IoT) and [[machine-to-machine]] (M2M) communication, which tend to be [[Embedded system|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 ([[CoRE]]) Working Group 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.<ref>[https://datatracker.ietf.org/wg/core/ The CORE WG's IETF Area]</ref> This protocol is still under development.
 
The Internet Engineering Task Force ([[IETF]]) Constrained [[RESTful]] Environments Working Group ([https://datatracker.ietf.org/doc/charter-ietf-core/ CoRE]) has done the major standardization work for this protocol. In order to make the protocol suitable to IoT and M2M applications, various new functions have been added.
== Features ==
 
== Specification ==
The CoRE group has proposed the following features for CoAP:
The core of the protocol is specified in {{IETF RFC|7252}}. Various extensions have been proposed, particularly:
* {{IETF RFC|7641}} (2015) Observing Resources in the Constrained Application Protocol
* {{IETF RFC|7959}} (2016) Block-Wise Transfers in the Constrained Application Protocol (CoAP)
* {{IETF RFC|8323}} (2018) CoAP (Constrained Application Protocol) over TCP, TLS, and [[WebSocket]]s
* {{IETF RFC|8974}} (2021) Extended Tokens and Stateless Clients in the Constrained Application Protocol (CoAP)
 
==Message formats==
* RESTful protocol design minimizing the complexity of mapping with HTTP.
CoAP makes use of two message types, requests and responses, using a simple, binary header 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.
* Low header 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 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.
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.<ref>[https://datatracker.ietf.org/doc/draft-castellani-core-http-mapping/ Best practices for HTTP-CoAP mapping implementation]</ref>
{| class="wikitable" style="margin: 0 auto; text-align:center"
|+ CoAP Message
! [[Octet (computing)|Octet]] offset !! !! colspan="8" | 0 !! colspan="8" | 1 !! colspan="8" | 2 !! colspan="8" | 3
|-
! !! [[Bit (computing)|Bit]] offset !! 0 !! 1 !! 2 !! 3 !! 4 !! 5 !! 6 !! 7 !! 8 !! 9 !! 10 !! 11 !! 12 !! 13 !! 14 !! 15 !! 16 !! 17 !! 18 !! 19 !! 20 !! 21 !! 22 !! 23 !! 24 !! 25 !! 26 !! 27 !! 28 !! 29 !! 30 !! 31
|-
! 4 !! 32
| colspan="2" | ver || colspan="2" | type || colspan="4" | token length || colspan="8" | request/response code || colspan="16" | message ID
|-
! 8 !! 64
| colspan="32" rowspan="2" | token (0–8 bytes)
|-
! 12 !! 96
|-
! 16 !! 128
| colspan="32" | options (if available)
|-
! 20 !! 160
| 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || colspan="24" | payload (if available)
|}
 
=== CoAP fixed-size header ===
==Message Formats==
The first 4 bytes are mandatory in all CoAP datagrams, they constitute the fixed-size header.
 
These fields can be extracted from these 4 bytes in C via these macros:
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 ICMP-style Type-Length-Value format. CoAP is by default bound to UDP and optionally to TCP.
<syntaxhighlight lang="c">
#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] )
</syntaxhighlight>
 
==== Version (ver) (2 bits) ====
Any bytes after the headers in the packet are considered the message body if any. 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 [http://tools.ietf.org/html/rfc4944 RFC 4944], messages SHOULD fit into a single IEEE 802.15.4 frame to minimize fragmentation.
 
:Indicates the CoAP version number.
==Implementations==
 
==== Type (2 bits) ====
 
:This describes the datagram's message type for the two message type context of Request and Response.
:* Request
:** 0 : Confirmable : This message expects a corresponding acknowledgement message.
:** 1 : Non-confirmable : This message does not expect a confirmation message.
:* Response
:** 2 : Acknowledgement : This message is a response that acknowledge a confirmable message
:** 3 : Reset : This message indicates that it had received a message but could not process it.
 
==== Token length (4 bits) ====
 
:Indicates the length of the variable-length Token field, which may be 0–8 bytes in length.
 
==== Request/response code (8 bits) ====
{| class="wikitable"
!0
!1
!2
!3
!4
!5
!6
!7
|-
| colspan="3" |Class
| colspan="5" |Code
|}
The three most significant bits form a number known as the "class", which is analogous to the [[List of HTTP status codes|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 <code>class.code</code> .
 
You can find the latest CoAP request/response codes at [https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#codes], though the below list gives some examples:
 
{{colbegin|colwidth=22em}}
* Method: 0.XX {{ordered list|start=0
| EMPTY
| GET
| POST
| PUT
| DELETE
| FETCH
| PATCH
| iPATCH
}}
* Success: 2.XX {{ordered list|
| Created
| Deleted
| Valid
| Changed
| Content
| item7_value = 31
| Continue
}}
* Client Error: 4.XX {{ordered list|start=0
| Bad Request
| Unauthorized
| Bad Option
| Forbidden
| Not Found
| Method Not Allowed
| Not Acceptable
| item8_value = 8
| Request Entity Incomplete
| Conflict
| item10_value = 12
| Precondition Failed
| Request Entity Too Large
| item12_value = 15
| Unsupported Content-Format
}}
* Server error: 5.XX {{ordered list|start=0
| Internal server error
| Not implemented
| Bad gateway
| Service unavailable
| Gateway timeout
| Proxying not supported
}}
* Signaling Codes: 7.XX {{ordered list|start=0
| Unassigned
| CSM
| Ping
| Pong
| Release
| Abort
}}
{{colend}}
 
==== Message ID (16 bits) ====
 
:Used to detect message duplication and to match messages of type acknowledgement/reset to messages of type confirmable/non-confirmable.
 
=== Token ===
Every request carries a token (but it may be zero length) whose value was generated by the client. The server must echo every token value without any modification back to the client in the corresponding response. It is intended for use as a client-local identifier to match requests and responses, especially for concurrent requests.
 
Matching requests and responses is not done with the message ID because a response may be sent in a different message than the acknowledgement (which uses the message ID for matching). For example, this could be done to prevent retransmissions if obtaining the result takes some time. Such a detached response is called "separate response". In contrast, transmitting the response directly in the acknowledgement is called "piggybacked response" which is expected to be preferred for efficiency reasons.
 
=== Option ===
{| class="wikitable"
|+Option Format
! colspan="8" |Bit position
|-
!0
!1
!2
!3
!4
!5
!6
!7
|-
| colspan="4" |Option delta
| colspan="4" |Option length
|-
| colspan="8" |Option delta extended (none, 8 bits, 16 bits)
|-
| colspan="8" |Option length extended (none, 8 bits, 16 bits)
|-
| colspan="8" |Option value
|}
Option delta:
 
* 0 to 12: For delta between 0 and 12: Represents the exact delta value between the last option ID and the desired option ID, with no option delta extended value
* 13: For delta from 13 to 268: Option delta extended is an 8-bit value that represents the option delta value minus 13
* 14: For delta from 269 to 65,804: Option delta extended is a 16-bit value that represents the option delta value minus 269
* 15: Reserved for payload marker, where the option delta and option length are set together as 0xFF.
 
Option length:
 
* 0 to 12: For option length between 0 and 12: Represents the exact length value, with no option length extended value
* 13: For option length from 13 to 268: Option length extended is an 8-bit value that represents the option length value minus 13
* 14: For option length from 269 to 65,804: Option length extended is a 16-bit value that represents the option length value minus 269
* 15: Reserved for future use. It is an error for the option length field to be set to 0xFF.
 
Option value:
 
* Size of option value field is defined by option length value in bytes.
* Semantic and format this field depends on the respective option.
 
==Active protocol implementations==
{| class="wikitable sortable"
|-
! Name !! Programming Language !! Implemented CoAP version !! Client/Server !! Implemented CoAP features !! License !! Link
|-
| libcoapcoap || CDart || coap-13RFC 7252|| Client + Server || Blockwise Transfers, Observe, Multicast, Proxying (partial) || BSD/GPLMIT || httphttps://sourceforgegithub.netcom/projectsshamblett/libcoap/developcoap
|-
| aiocoap || Python 3 || RFC 7252, RFC 7641, RFC 7959, RFC 8323, RFC 7967, RFC 8132, RFC 9176, RFC 8613, RFC 9528|| Client + Server || Blockwise Transfers, Observe (partial) || MIT || {{URL|https://pypi.python.org/pypi/aiocoap}}
| jcoap || Java || coap-08? || Client + Server || || Apache || http://code.google.com/p/jcoap/
|-
| Californium || Java || RFC 7252, RFC 7641, RFC 7959|| Client + Server || Observe, Blockwise Transfers, Multicast (since 2.x), DTLS (+ DTLS 1.2 Connection ID) || EPL+EDL || {{URL|https://www.eclipse.org/californium}} {{URL|https://github.com/eclipse/californium}}
| coapy || Python || coap-03 || Client + Server || || BSD || http://sourceforge.net/projects/coapy/
|-
| TinyOS CoapBlipCoAPSharp || nesC/ C#, .NET || coap-03/coap-08RFC 7252|| Client + Server || Core, Observe, Block, RD || BSDMIT || {{URL|http://docswww.tinyoscoapsharp.netcom https:/tinywiki/indexgithub.phpcom/FemtomaxInc/CoAPcoapsharp}}
|-
| RESTful ContikiFreeCoAP || C || coap-03RFC 7252|| Client + Server + HTTP/CoAP Proxy ||Core, DTLS, Blockwise Transfers || 3-clause BSD || http{{URL|https://wwwgithub.contiki-os.orgcom/ (restkeith-example)cullen/FreeCoAP}}
|-
| Erbium for ContikiGo-CoAP || C[[Go (programming language)|Go]] || coap-13RFC 7252, RFC 8232, RFC 7641, RFC 7959|| Client + Server || Core, Observe, Blockwise, TransfersMulticast, TCP/TLS || 3-clauseApache BSDLicense 2.0 || http{{URL|https://wwwgithub.contikicom/plgd-os.orgdev/ (ergo-rest-example)coap}}
|-
| Californiumjava-coap || Java || coap-13RFC 7252, RFC 7641, RFC 7959, RFC 8323|| Client + Server || Observe, Blockwise Transfers, DTLS || 3-clauseApache BSDLicense 2.0 || {{URL|https://github.com/mkovatscPelionIoT/Californiumjava-coap}}
|-
| Copperlibcoap || JavaScript (Browser Plugin)C || coap-13RFC 7252, RFC 7390, RFC 7641, RFC 7959, RFC 7967, RFC 8132, RFC 8323, RFC 8516, RFC 8613, RFC 8768, RFC 8974, RFC 9175, RFC 9177|| Client + Server ||Core, Observe, Multicast, Blockwise Transfers, Patch/Fetch, OSCORE, (D)TLS || 3-clause BSD/GPL || https://github.com/mkovatsc/Copper https://addons.mozilla.org/de/firefox/addon/copper-270430obgm/libcoap
|-
|libcoapy
| CoAP implementation for TinyOS || nesC/C || coap-08 || ?? || || ?? || http://telecom.dei.unipd.it/pages/read/90/
|Python
| colspan="3" |same support as libcoap
|MIT
|{{URL|https://github.com/anyc/libcoapy}}
|-
| CoAP implementation for Golobaro-coap || [[Go (programming language)|Go]]C || coap-10RFC 7252|| Client + Server ||Observe, CoreBlockwise + Draft SubscribeTransfers || MIT || https{{URL|http://githubwww.lobaro.com/dustin/golobaro-coap}}
|-
| microCoAPy || MicroPython || RFC 7252|| Client + Server || Core || Apache License 2.0 || {{URL|https://github.com/insighio/microCoAPy}}
|-
| nanoCoAP || C || RFC 7252|| Client + Server || Core, Blockwise Transfers, DTLS || LGPL || {{URL|https://api.riot-os.org/group__net__nanocoap.html}}
|-
| node-coap || JavaScript || RFC 7252,
RFC 7641, RFC 7959
| Client + Server || Core, Observe, Block || MIT || {{URL|https://github.com/mcollina/node-coap}}
|-
| Qt CoAP || C++ || RFC 7252|| Client || Core, Observe, Blockwise Transfers || GPL, Commercial || https://doc.qt.io/qt-6/qtcoap-index.html
|-
| coap-rs || Rust || RFC 7252|| Client + Server || Core, Multicast, Observe option, ''Too Many Requests'' Response Code || MIT || {{URL|https://github.com/Covertness/coap-rs}}
{{URL|https://docs.rs/coap/}}
|-
|}
 
==Proxy implementations==
There exist [[Proxy server|proxy]] implementations which provide [[Forward proxy|forward]] or [[Reverse proxy|reverse]] proxy functionality for the CoAP protocol and also implementations which translate between protocols like HTTP and CoAP.
 
The following projects provide proxy functionality:
* [http://telecom.dei.unipd.it/pages/read/90/ Squid 3.1.9 with transparent HTTP-CoAP mapping module]
* [https://code.google.com/p/jcoap/ jcoap Proxy]
* [https://github.com/eclipse/californium/tree/master/californium-proxy2 Californium cf-proxy2]
* [https://github.com/Tanganelli/CoAPthon CoAPthon]
* [https://github.com/keith-cullen/FreeCoAP FreeCoAP]
* [https://github.com/obgm/libcoap libcoap]
 
==Projects using CoAP==
{| class="wikitable sortable"
|-
! Name !! Programming Language !! Implemented CoAP version !! Client/Server !! Implemented CoAP features !! License !! Link
|-
| CoAP Shell || Java || RFC 7252|| Client || Observe, Blockwise Transfers, DTLS || Apache License 2.0 || https://github.com/tzolov/coap-shell
|-
| Copper || JavaScript (browser plugin) || RFC 7252|| Client || Observe, Blockwise Transfers || 3-clause BSD || https://github.com/mkovatsc/Copper https://addons.mozilla.org/firefox/addon/copper-270430/{{Dead link|date=July 2019 |bot=InternetArchiveBot |fix-attempted=yes }}
|-
|}
 
==Inactive protocol implementations==
==Proxy Implementations==
{| class="wikitable sortable"
* Squid 3.1.9 with transparent HTTP-CoAP mapping module http://telecom.dei.unipd.it/pages/read/90/
|-
* jcoap Proxy http://code.google.com/p/jcoap/
! Name !! Programming Language !! Implemented CoAP version !! Client/Server !! Implemented CoAP features !! License !! Link
* Californium cf-proxy https://github.com/mkovatsc/Californium
|-
| cantcoap || C++/C || RFC 7252|| Client + Server || || BSD || https://github.com/staropram/cantcoap
|-
| Canopus || [[Go (programming language)|Go]] || RFC 7252|| Client + Server || Core || Apache License 2.0 || https://github.com/zubairhamed/canopus
|-
| CoAP implementation for Go || [[Go (programming language)|Go]] || RFC 7252|| Client + Server || Core + Draft Subscribe || MIT || https://github.com/dustin/go-coap
|-
| CoAP.NET || C# || RFC 7252, coap-13, coap-08, coap-03 || Client + Server || Core, Observe, Blockwise Transfers || 3-clause BSD || https://github.com/smeshlink/CoAP.NET
|-
| CoAPthon || Python || RFC 7252|| Client + Server + Forward Proxy + Reverse Proxy || Observe, Multicast server discovery, CoRE Link Format parsing, Block-wise || MIT || https://github.com/Tanganelli/CoAPthon
|-
| eCoAP || C || RFC 7252|| Client + Server || Core || MIT || https://gitlab.com/jobol/ecoap
|-
| Erbium for Contiki || C || RFC 7252|| Client + Server || Observe, Blockwise Transfers || 3-clause BSD || http://www.contiki-os.org/ (er-rest-example)
|-
| guile-coap || Guile || RFC 7252, RFC 8323 || Client + Server || || GPL-3.0-or-later || https://codeberg.org/eris/guile-coap
|-
| iCoAP || Objective-C || RFC 7252|| Client || Core, Observe, Blockwise Transfers || MIT || https://github.com/stuffrabbit/iCoAP
|-
| jCoAP || Java || RFC 7252|| Client + Server || Observe, Blockwise Transfers || Apache License 2.0 || https://code.google.com/p/jcoap/
|-
| LibNyoci || C || RFC 7252|| Client + Server || Core, Observe, Block, DTLS || MIT || https://github.com/darconeous/libnyoci
|-
| microcoap || C || RFC 7252|| Client + Server || || MIT || https://github.com/1248/microcoap
|-
| nCoap || Java || RFC 7252|| Client + Server || Observe, Blockwise Transfers, CoRE Link Format, [https://tools.ietf.org/html/draft-kleine-core-coap-endpoint-id-01 Endpoint-ID-Draft] || BSD || https://github.com/okleine/nCoAP
|-
| Ruby coap || Ruby || RFC 7252|| Client + Server (david) || Core, Observe, Block, RD || MIT, GPL || https://github.com/nning/coap<br/>https://github.com/nning/david
|-
| Sensinode C Device Library || C || RFC 7252|| Client + Server || Core, Observe, Block, RD || Commercial || https://silver.arm.com/browse/SEN00
|-
| Sensinode Java Device Library || Java SE || RFC 7252|| Client + Server || Core, Observe, Block, RD || Commercial || https://silver.arm.com/browse/SEN00
|-
| Sensinode NanoService Platform || Java SE || RFC 7252|| Cloud Server || Core, Observe, Block, RD || Commercial || https://silver.arm.com/browse/SEN00
|-
| SwiftCoAP || Swift || RFC 7252|| Client + Server || Core, Observe, Blockwise Transfers || MIT || https://github.com/stuffrabbit/SwiftCoAP
|-
| TinyOS CoapBlip || nesC/C || coap-13 || Client + Server || Observe, Blockwise Transfers || BSD || https://web.archive.org/web/20130312140509/http://docs.tinyos.net/tinywiki/index.php/CoAP
|-
| txThings || Python (Twisted) || RFC 7252|| Client + Server || Blockwise Transfers, Observe (partial) || MIT || https://github.com/mwasilak/txThings/
|-
| YaCoAP || C || || || || MIT || https://github.com/RIOT-Makers/YaCoAP
|-
|}
 
==CoAP group communication==
In many CoAP application domains it is essential to have the ability to address several CoAP resources as a group, instead of addressing each resource individually
(e.g. to turn on all the CoAP-enabled lights in a room with a single CoAP request triggered by toggling the light switch).
To address this need, the IETF has developed an optional extension for CoAP in the form of an experimental RFC: Group Communication for CoAP - RFC 7390<ref>[https://tools.ietf.org/html/rfc7390 RFC 7390, Group Communication for CoAP]</ref>
This extension relies on IP multicast to deliver the CoAP request to all group members.
The use of multicast has certain benefits such as reducing the number of packets needed to deliver the request to the members.
However, multicast also has its limitations such as poor reliability and being cache-unfriendly.
An alternative method for CoAP group communication that uses unicasts instead of multicasts relies on having an intermediary where the groups are created.
Clients send their group requests to the intermediary, which in turn sends individual unicast requests to the group members, collects the replies from them, and sends back an aggregated reply to the client.<ref>"[http://www.mdpi.com/1424-8220/14/6/9833/htm Flexible Unicast-Based Group Communication for CoAP-Enabled Devices]" , Ishaq, I.; Hoebeke, J.; Van den Abeele, F.; Rossey, J.; Moerman, I.; Demeester, P. Sensors 2014</ref>
 
== Security ==
CoAP defines four security modes:<ref>[https://tools.ietf.org/html/rfc7252 RFC 7252, Constrained Application Protocol (CoAP)]</ref>
* NoSec, where [[DTLS]] is disabled
* PreSharedKey, where DTLS is enabled, there is a list of pre-shared keys, and each key includes a list of which nodes it can be used to communicate with. Devices must support the AES cipher suite.
* RawPublicKey, where DTLS is enabled and the device uses an asymmetric key pair without a certificate, which is validated out of band. Devices must support the AES cipher suite and Elliptic Curve algorithms for key exchange.
* Certificate, where DTLS is enabled and the device uses [[X.509]] certificates for validation.
 
Research has been conducted on optimizing DTLS by implementing security associates as CoAP resources rather than using DTLS as a security wrapper for CoAP traffic. This research has indicated that improvements of up to 6.5 times none optimized implementations.<ref name="Security as a CoAP resource: An optimized DTLS implementation for the IoT">{{cite book |last1=Capossele |first1=Angelo |last2=Cervo |first2=Valerio |last3=De Cicco |first3=Gianluca |last4=Petrioli |first4=Chiara|title=2015 IEEE International Conference on Communications (ICC) |chapter=Security as a CoAP resource: An optimized DTLS implementation for the IoT |author4-link= Chiara Petrioli |date=June 2015 |publisher=IEEE |pages=529–554 |doi= 10.1109/ICC.2015.7248379|isbn=978-1-4673-6432-4 |s2cid=12568959 }}</ref>
 
In addition to DTLS, RFC8613<ref>{{Cite journal|last1=Palombini|first1=Francesca|last2=Seitz|first2=Ludwig|last3=Selander|first3=Goeran|last4=Mattsson|first4=John|title=Object Security for Constrained RESTful Environments (OSCORE)|url=https://tools.ietf.org/html/rfc8613.html|access-date=2021-05-07|website=tools.ietf.org|year=2019 |doi=10.17487/RFC8613 |s2cid=58380874 |language=en}}</ref> defines the Object Security for Constrained RESTful Environments ([[OSCORE]]) protocol which provides security for CoAP at the application layer.
 
== Security issues ==
Although the protocol standard includes provisions for mitigating the threat of [[DDoS]] amplification attacks,<ref>[https://blog.cloudflare.com/why-iot-is-insecure/ "TLS 1.3 is going to save us all, and other reasons why IoT is still insecure", Dani Grant, 2017-12-24]</ref> these provisions are not implemented in practice,<ref>[https://i.blackhat.com/eu-18/Thu-Dec-6/eu-18-Maggi-When-Machines-Cant-Talk-wp.pdf "When Machines Can't Talk: Security and Privacy Issues of Machine-to-Machine Data Protocols", Federico Maggi and Rainer Vosseler, 2018-12-06]</ref> resulting in the presence of over 580,000 targets primarily located in China and attacks up to 320&nbsp;Gbit/s.<ref>[https://www.zdnet.com/article/the-coap-protocol-is-the-next-big-thing-for-ddos-attacks/ "The CoAP protocol is the next big thing for DDoS attacks", Catalin Cimpanu, 2018-12-05]</ref>
 
==See also==
* [[Internet of Things]]
* [[OMA LWM2M|OMA Lightweight M2M]]
* [[Web of Things]]
* [[Static Context Header Compression|Static Context Header Compression (SCHC)]]
 
== References ==
{{reflist}}
 
== External links ==
[[Category:Network protocols]]
{{commons category|SSL and TLS}}
[[Category:Internet protocols|Internet protocols]]
* [https://datatracker.ietf.org/doc/html/rfc7252 RFC 7252 "The Constrained Application Protocol (CoAP)"]
* [http://coap.me/ coap.me] – CoAP test server run by [[University of Bremen]]
 
[[Category:Hypertext Transfer Protocol]]
[[Category:Application layer protocols]]
[[Category:Internet of things]]