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