├── .gitignore ├── LICENSE ├── README.md ├── coap-cheatsheet.pdf └── coap-cheatsheet.tex /.gitignore: -------------------------------------------------------------------------------- 1 | *.aux 2 | *.log 3 | *.out 4 | 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Markus Becker 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A Cheatsheet for the Constrained Application Protocol (CoAP) 2 | 3 | This document is giving the most important information of CoAP, like options, codes, etc. in a compressed cheatsheet format. 4 | 5 | ## The current version uses the following RFCs 6 | 7 | * [RFC6690](http://tools.ietf.org/html/rfc6690) 8 | * [RFC7252](http://tools.ietf.org/html/rfc7252) 9 | * [RFC7959](http://tools.ietf.org/html/rfc7959) 10 | * [RFC7641](http://tools.ietf.org/html/rfc7641) 11 | -------------------------------------------------------------------------------- /coap-cheatsheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markushx/coap-cheatsheet/19ca863d1db85f4243288e4568fa97ba7dea4fa1/coap-cheatsheet.pdf -------------------------------------------------------------------------------- /coap-cheatsheet.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4,10pt,landscape]{article} 2 | \usepackage{multicol} 3 | \usepackage{calc} 4 | \usepackage{ifthen} 5 | \usepackage[landscape]{geometry} 6 | \usepackage{amsmath,amsthm,amsfonts,amssymb} 7 | \usepackage{color,graphicx} %,overpic} 8 | \usepackage{hyperref} 9 | \usepackage[defaultsans]{droidsans} 10 | \usepackage[defaultmono]{droidmono} 11 | \renewcommand*\familydefault{\sfdefault} %% Only if the base font of the document is to be typewriter style 12 | \usepackage[T1]{fontenc} 13 | 14 | 15 | \pdfinfo{ 16 | /Title (coap-cheatsheet.pdf) 17 | /Creator (LaTeX) 18 | /Author (Markus Becker) 19 | /Subject (CoAP) 20 | /Keywords (CoAP)} 21 | 22 | % This sets page margins to .5 inch if using letter paper, and to 1cm 23 | % if using A4 paper. (This probably isn't strictly necessary.) 24 | % If using another size paper, use default 1cm margins. 25 | \ifthenelse{\lengthtest { \paperwidth = 11in}} 26 | { \geometry{top=.25in,left=.25in,right=.25in,bottom=.25in} } 27 | {\ifthenelse{ \lengthtest{ \paperwidth = 297mm}} 28 | {\geometry{top=.5cm,left=.5cm,right=.5cm,bottom=.5cm} } 29 | {\geometry{top=.5cm,left=.5cm,right=.5cm,bottom=.5cm} } 30 | } 31 | 32 | % Turn off header and footer 33 | \pagestyle{empty} 34 | 35 | % Redefine section commands to use less space 36 | \makeatletter 37 | \renewcommand{\section}{\@startsection{section}{1}{0mm}% 38 | {-1ex plus -.5ex minus -.2ex}% 39 | {0.5ex plus .2ex}%x 40 | {\normalfont\large\bfseries}} 41 | \renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}% 42 | {-1ex plus -.5ex minus -.2ex}% 43 | {0.5ex plus .2ex}% 44 | {\normalfont\normalsize\bfseries}} 45 | \renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}% 46 | {-1ex plus -.5ex minus -.2ex}% 47 | {1ex plus .2ex}% 48 | {\normalfont\small\bfseries}} 49 | \makeatother 50 | 51 | % Define BibTeX command 52 | \def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em 53 | T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}} 54 | 55 | % Don't print section numbers 56 | \setcounter{secnumdepth}{0} 57 | 58 | 59 | \setlength{\parindent}{0pt} 60 | \setlength{\parskip}{0pt plus 0.5ex} 61 | 62 | %My Environments 63 | \newtheorem{example}[section]{Example} 64 | % ----------------------------------------------------------------------- 65 | 66 | \begin{document} 67 | \raggedright 68 | \footnotesize 69 | \begin{multicols}{3} 70 | 71 | 72 | % multicol parameters 73 | % These lengths are set only within the two main columns 74 | %\setlength{\columnseprule}{0.25pt} 75 | \setlength{\premulticols}{1pt} 76 | \setlength{\postmulticols}{1pt} 77 | \setlength{\multicolsep}{1pt} 78 | \setlength{\columnsep}{1pt} 79 | 80 | \begin{center} 81 | \Large{\underline{Constrained Application Protocol}} \\ 82 | {\tiny 83 | (RFC 6690, RFC 7252, RFC 7959, RFC 7641) 84 | } 85 | \end{center} 86 | 87 | The Constrained Application Protocol (CoAP) is a specialized web 88 | transfer protocol for use with constrained nodes and constrained 89 | (e.g., low-power, lossy) networks. 90 | 91 | \section{CoAP Message Format} 92 | {\tiny 93 | \begin{verbatim} 94 | 0 1 2 3 95 | 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 96 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 97 | |Ver| T | TKL | Code | Message ID | 98 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 99 | | Token (if any, TKL bytes) ... 100 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 101 | | Options (if any) ... 102 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 103 | |1 1 1 1 1 1 1 1| Payload (if any) ... 104 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 105 | \end{verbatim} 106 | Ver: Version, T: Type, TKL: Token Length 107 | } 108 | 109 | \section{Message types} 110 | {\tiny 111 | \begin{verbatim} 112 | +------+-----------------+ 113 | | Type | Name | 114 | +------+-----------------+ 115 | | 0 | CONfirmable | 116 | | 1 | NON-confirmable | 117 | | 2 | ACKnowledgement | 118 | | 3 | ReSeT | 119 | +------+-----------------+ 120 | \end{verbatim} 121 | } 122 | 123 | \section{Method codes} 124 | {\tiny 125 | \begin{verbatim} 126 | +------+--------+ 127 | | Code | Name | 128 | +------+--------+ 129 | | 0.00 | EMPTY | 130 | +------+--------+ 131 | | 0.01 | GET | 132 | | 0.02 | POST | 133 | | 0.03 | PUT | 134 | | 0.04 | DELETE | 135 | +------+--------+ 136 | \end{verbatim} 137 | } 138 | 139 | \section{Response codes} 140 | 141 | {\tiny 142 | \begin{verbatim} 143 | 0 144 | 0 1 2 3 4 5 6 7 145 | +-+-+-+-+-+-+-+-+ 146 | |class| detail | 147 | +-+-+-+-+-+-+-+-+ 148 | \end{verbatim} 149 | } 150 | 151 | {\tiny 152 | \begin{verbatim} 153 | +------------------+------------------------------+--------------+ 154 | | Code | Description | | 155 | +------------------+------------------------------+--------------+ 156 | | 2.01 (65, 0x41) | Created | Success | 157 | | 2.02 (66, 0x42) | Deleted | | 158 | | 2.03 (67, 0x43) | Valid | | 159 | | 2.04 (68, 0x44) | Changed | | 160 | | 2.05 (69, 0x45) | Content | | 161 | | 2.31 (95, 0x5F) | Continue | | 162 | +------------------+------------------------------+--------------+ 163 | | 4.00 (128, 0x80) | Bad Request | Client Error | 164 | | 4.01 (129, 0x81) | Unauthorized | | 165 | | 4.02 (130, 0x82) | Bad Option | | 166 | | 4.03 (131, 0x83) | Forbidden | | 167 | | 4.04 (132, 0x84) | Not Found | | 168 | | 4.05 (133, 0x85) | Method Not Allowed | | 169 | | 4.06 (134, 0x86) | Not Acceptable | | 170 | | 4.08 (136, 0x88) | Request Entity Incomplete | | 171 | | 4.12 (140, 0x8C) | Precondition Failed | | 172 | | 4.13 (141, 0x8D) | Request Entity Too Large | | 173 | | 4.15 (143, 0x8F) | Unsupported Content-Format | | 174 | +------------------+------------------------------+--------------+ 175 | | 5.00 (160, 0xA0) | Internal Server Error | Server Error | 176 | | 5.01 (161, 0xA1) | Not Implemented | | 177 | | 5.02 (162, 0xA2) | Bad Gateway | | 178 | | 5.03 (163, 0xA3) | Service Unavailable | | 179 | | 5.04 (164, 0xA4) | Gateway Timeout | | 180 | | 5.05 (165, 0xA5) | Proxying Not Supported | | 181 | +------------------+------------------------------+--------------+ 182 | \end{verbatim} 183 | } 184 | 185 | \section{Options} 186 | 187 | {\tiny 188 | \begin{verbatim} 189 | 0 1 2 3 4 5 6 7 190 | +---------------+---------------+ 191 | | Option Delta | Option Length | 1 byte 192 | +---------------+---------------+ 193 | / Option Delta / 0-2 bytes 194 | \ (extended) \ 195 | +-------------------------------+ 196 | / Option Length / 0-2 bytes 197 | \ (extended) \ 198 | +-------------------------------+ 199 | / Option Value / 0 or more bytes 200 | +-------------------------------+ 201 | \end{verbatim} 202 | } 203 | 204 | {\tiny 205 | \begin{verbatim} 206 | +-----+----+---+---+---+----------------+--------+--------+-------------+ 207 | | No. | C | U | N | R | Name | Format | Length | Default | 208 | +-----+----+---+---+---+----------------+--------+--------+-------------+ 209 | | 1 | x | | | x | If-Match | opaque | 0-8 | (none) | 210 | | 3 | x | x | - | | Uri-Host | string | 1-255 | (see note 1)| 211 | | 4 | | | | x | ETag | opaque | 1-8 | (none) | 212 | | 5 | x | | | | If-None-Match | empty | 0 | (none) | 213 | | 7 | x | x | - | | Uri-Port | uint | 0-2 | (see note 1)| 214 | | 8 | | | | x | Location-Path | string | 0-255 | (none) | 215 | | 11 | x | x | - | x | Uri-Path | string | 0-255 | (none) | 216 | | 12 | | | | | Content-Format | uint | 0-2 | (none) | 217 | | 14 | | x | - | | Max-Age | uint | 0-4 | 60 | 218 | | 15 | x | x | - | x | Uri-Query | string | 0-255 | (none) | 219 | | 17 | x | | | | Accept | uint | 0-2 | (none) | 220 | | 20 | | | | x | Location-Query | string | 0-255 | (none) | 221 | | 28 | | | x | | Size2 | uint | 0-4 | (none) | 222 | | 35 | x | x | - | | Proxy-Uri | string | 1-1034 | (none) | 223 | | 39 | x | x | - | | Proxy-Scheme | string | 1-255 | (none) | 224 | | 60 | | | x | | Size1 | uint | 0-4 | (none) | 225 | +-----+----+---+---+---+----------------+--------+--------+-------------+ 226 | \end{verbatim} 227 | C=Critical, U=Unsafe, N=No-Cache-Key, R=Repeatable \\ 228 | Note 1: taken from destination address/port of request message 229 | } 230 | 231 | \section{Content-Formats} 232 | {\tiny 233 | \begin{verbatim} 234 | +--------------------------+-----+ 235 | | Media type | Id. | 236 | +--------------------------+-----+ 237 | | text/plain;charset=utf-8 | 0 | 238 | | application/link-format | 40 | 239 | | application/xml | 41 | 240 | | application/octet-stream | 42 | 241 | | application/exi | 47 | 242 | | application/json | 50 | 243 | | application/cbor | 60 | 244 | +--------------------------+-----+ 245 | \end{verbatim} 246 | } 247 | 248 | \section{URI schemes} 249 | {\tiny 250 | \begin{verbatim} 251 | coap-URI = "coap:" "//" host [ ":" port ] path-abempty [ "?" query ] 252 | coaps-URI = "coaps:" "//" host [ ":" port ] path-abempty [ "?" query ] 253 | \end{verbatim} 254 | } 255 | 256 | \section{Transmission parameters} 257 | {\tiny 258 | \begin{verbatim} 259 | +-------------------+---------------+ 260 | | name | default value | 261 | +-------------------+---------------+ 262 | | ACK_TIMEOUT | 2 seconds | 263 | | ACK_RANDOM_FACTOR | 1.5 | 264 | | MAX_RETRANSMIT | 4 | 265 | | NSTART | 1 | 266 | | DEFAULT_LEISURE | 5 seconds | 267 | | PROBING_RATE | 1 Byte/second | 268 | +-------------------+---------------+ 269 | \end{verbatim} 270 | } 271 | 272 | \section{Link Format .well-known/core} 273 | 274 | Link format can be used to describe hosted resources, their 275 | attributes, and other relationships between links. 276 | 277 | Example: 278 | {\tiny 279 | \begin{verbatim} 280 | REQ: GET /.well-known/core 281 | 282 | RES: 2.05 Content 283 | 284 | ;ct=40;title="Sensor Index", 285 | ;rt="temperature-c";if="sensor", 286 | ;rt="light-lux";if="sensor", 287 | ;anchor="/sensors/temp";rel="describedby", 288 | ;anchor="/sensors/temp";rel="alternate" 289 | \end{verbatim} 290 | } 291 | 292 | \section{Block} 293 | 294 | In order to transfer larger payloads with CoAP $-$ for instance, for 295 | firmware updates $-$ the Block option can be used. 296 | 297 | {\tiny 298 | \begin{verbatim} 299 | +-----+---+---+---+---+----------------+--------+--------+----------+ 300 | | No. | C | U | N | R | Name | Format | Length | Default | 301 | +-----+---+---+---+---+----------------+--------+--------+----------+ 302 | | 23 | x | x | - | - | Block2 | uint | 0-3 B | (none) | 303 | | 27 | x | x | - | - | Block1 | uint | 0-3 B | (none) | 304 | +-----+---+---+---+---+----------------+--------+--------+----------+ 305 | \end{verbatim} 306 | } 307 | {\tiny 308 | \begin{verbatim} 309 | 0 310 | 0 1 2 3 4 5 6 7 311 | +-+-+-+-+-+-+-+-+ 312 | | NUM |M| SZX | 313 | +-+-+-+-+-+-+-+-+ 314 | 315 | 0 1 316 | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 317 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 318 | | NUM |M| SZX | 319 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 320 | 321 | 0 1 2 322 | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 323 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 324 | | NUM |M| SZX | 325 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 326 | \end{verbatim} 327 | } 328 | 329 | \section{Observe} 330 | 331 | In order to follow state changes of CoAP resources the Observe option 332 | can be used. 333 | 334 | {\tiny 335 | \begin{verbatim} 336 | +-----+---+---+---+---+---------+------------+-----------+---------+ 337 | | No. | C | U | N | R | Name | Format | Length | Default | 338 | +-----+---+---+---+---+---------+------------+-----------+---------+ 339 | | 6 | | x | - | | Observe | uint | 0-3 B | (none) | 340 | +-----+---+---+---+---+---------+------------+-----------+---------+ 341 | \end{verbatim} 342 | } 343 | 344 | \section{References} 345 | This cheatsheet is based on and heavily stole from the following 346 | documents:\\ 347 | 348 | {\tiny 349 | Link-format: \url{http://tools.ietf.org/html/rfc6690}\\ 350 | CoAP: \url{http://tools.ietf.org/html/rfc7252}\\ 351 | Block: \url{http://tools.ietf.org/html/rfc7959}\\ 352 | Observe: \url{http://tools.ietf.org/html/rfc7641}\\ 353 | } 354 | % You can even have references 355 | %\rule{0.3\linewidth}{0.25pt} 356 | %\scriptsize 357 | %\bibliographystyle{abstract} 358 | %\bibliography{refFile} 359 | \end{multicols} 360 | \end{document} 361 | --------------------------------------------------------------------------------