asciidoctor-rfc 0.2.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +116 -6
- data/asciidoctor-rfc.gemspec +15 -1
- data/lib/asciidoctor/rfc/common/base.rb +74 -7
- data/lib/asciidoctor/rfc/common/front.rb +1 -1
- data/lib/asciidoctor/rfc/v2/base.rb +87 -38
- data/lib/asciidoctor/rfc/v2/blocks.rb +29 -2
- data/lib/asciidoctor/rfc/v2/converter.rb +0 -1
- data/lib/asciidoctor/rfc/v2/inline_anchor.rb +2 -8
- data/lib/asciidoctor/rfc/v2/lists.rb +7 -4
- data/lib/asciidoctor/rfc/v2/table.rb +1 -1
- data/lib/asciidoctor/rfc/v3/base.rb +41 -43
- data/lib/asciidoctor/rfc/v3/blocks.rb +29 -2
- data/lib/asciidoctor/rfc/v3/converter.rb +0 -2
- data/lib/asciidoctor/rfc/v3/inline_anchor.rb +2 -6
- data/lib/asciidoctor/rfc/version.rb +1 -1
- data/spec/asciidoctor/rfc/v2/comments_spec.rb +7 -3
- data/spec/asciidoctor/rfc/v2/date_spec.rb +23 -0
- data/spec/asciidoctor/rfc/v2/dlist_spec.rb +107 -9
- data/spec/asciidoctor/rfc/v2/image_spec.rb +17 -0
- data/spec/asciidoctor/rfc/v2/inline_formatting_spec.rb +12 -0
- data/spec/asciidoctor/rfc/v2/listing_spec.rb +22 -0
- data/spec/asciidoctor/rfc/v2/literal_spec.rb +22 -2
- data/spec/asciidoctor/rfc/v2/preamble_spec.rb +72 -0
- data/spec/asciidoctor/rfc/v2/references_spec.rb +3 -1
- data/spec/asciidoctor/rfc/v2/table_spec.rb +104 -4
- data/spec/asciidoctor/rfc/v2/text_spec.rb +89 -0
- data/spec/asciidoctor/rfc/v2/ulist_spec.rb +40 -0
- data/spec/asciidoctor/rfc/v3/dlist_spec.rb +103 -1
- data/spec/asciidoctor/rfc/v3/image_spec.rb +18 -0
- data/spec/asciidoctor/rfc/v3/listing_spec.rb +26 -0
- data/spec/asciidoctor/rfc/v3/literal_spec.rb +20 -1
- data/spec/asciidoctor/rfc/v3/preamble_spec.rb +150 -0
- data/spec/asciidoctor/rfc/v3/references_spec.rb +35 -34
- data/spec/asciidoctor/rfc/v3/series_info_spec.rb +39 -0
- data/spec/examples/README.adoc +162 -0
- data/spec/examples/davies-template-bare-06.adoc +3 -0
- data/spec/examples/draft-ietf-core-block-xx.mkd +935 -0
- data/spec/examples/draft-ietf-core-block-xx.mkd.adoc +1013 -0
- data/spec/examples/draft-ietf-core-block-xx.xml.orig +1251 -0
- data/spec/examples/example-v2.adoc +6 -2
- data/spec/examples/example-v3.adoc +5 -1
- data/spec/examples/hoffmanv2.xml.adoc +247 -0
- data/spec/examples/hoffmanv2.xml.orig +339 -0
- data/spec/examples/hoffmanv3.xml.orig +346 -0
- data/spec/examples/mib-doc-template-xml-06.adoc +5 -1
- data/spec/examples/rfc2100.md.adoc +2 -3
- data/spec/examples/rfc3514.md.adoc +3 -2
- data/spec/examples/rfc5841.md.adoc +1 -1
- data/spec/examples/rfc748.md.adoc +7 -6
- data/spec/examples/rfc7511.md.adoc +15 -15
- data/spec/examples/skel.mkd +32 -0
- data/spec/examples/skel.mkd.adoc +50 -0
- data/spec/examples/skel.xml.orig +105 -0
- data/spec/examples/stupid-s.mkd +569 -0
- data/spec/examples/stupid-s.mkd.adoc +771 -0
- data/spec/examples/stupid-s.xml.orig +880 -0
- data/spec/spec_helper.rb +1 -1
- metadata +32 -4
@@ -0,0 +1,1013 @@
|
|
1
|
+
= Blockwise transfers in CoAP
|
2
|
+
Carsten Bormann <cabo@tzi.org>; Zach Shelby <zach@sensinode.com>
|
3
|
+
:doctype: internet-draft
|
4
|
+
:name: draft-ietf-core-block-05
|
5
|
+
:revdate: 2012-01-13
|
6
|
+
:ipr: trust200902
|
7
|
+
:area: Applications
|
8
|
+
:workgroup: CoRE Working Group
|
9
|
+
:keyword: Internet-Draft
|
10
|
+
:status: standard
|
11
|
+
:toc-include: true
|
12
|
+
:sort-refs: yes
|
13
|
+
:sym-refs: yes
|
14
|
+
:forename_initials: C.
|
15
|
+
:organization: Universitaet Bremen TZI
|
16
|
+
:street: Postfach 330440
|
17
|
+
:city: Bremen
|
18
|
+
:code: D-28359
|
19
|
+
:country: Germany
|
20
|
+
:phone: +49-421-218-63921
|
21
|
+
:fax: +49-421-218-7000
|
22
|
+
:email: cabo@tzi.org
|
23
|
+
:forename_initials_2: Z.
|
24
|
+
:organization_2: Sensinode
|
25
|
+
:role_2: editor
|
26
|
+
:street_2: Kidekuja 2
|
27
|
+
:city_2: Vuokatti
|
28
|
+
:code_2: 88600
|
29
|
+
:country_2: Finland
|
30
|
+
:phone_2: +358407796297
|
31
|
+
:email_2: zach@sensinode.com
|
32
|
+
:inline-definition-lists: true
|
33
|
+
|
34
|
+
[abstract]
|
35
|
+
CoAP is a RESTful transfer protocol for constrained nodes and networks.
|
36
|
+
Basic CoAP messages work well for the small payloads we expect
|
37
|
+
from temperature sensors, light switches, and similar
|
38
|
+
building-automation devices.
|
39
|
+
Occasionally, however, applications will need to transfer
|
40
|
+
larger payloads -- for instance, for firmware updates. With
|
41
|
+
HTTP, TCP does the grunt work of slicing large payloads up
|
42
|
+
into multiple packets and ensuring that they all arrive and
|
43
|
+
are handled in the right order.
|
44
|
+
|
45
|
+
CoAP is based on datagram transports such as UDP or DTLS,
|
46
|
+
which limits the maximum size of resource representations that
|
47
|
+
can be transferred without too much fragmentation.
|
48
|
+
Although UDP supports larger payloads through IP
|
49
|
+
fragmentation, it is limited to 64 KiB and, more importantly,
|
50
|
+
doesn't really work well for constrained applications and
|
51
|
+
networks.
|
52
|
+
|
53
|
+
Instead of relying on IP fragmentation, this specification
|
54
|
+
extends basic CoAP with a pair of "Block" options, for
|
55
|
+
transferring multiple blocks of information from a resource
|
56
|
+
representation in multiple request-response pairs. In many
|
57
|
+
important cases, the Block options enable a server to be truly
|
58
|
+
stateless: the server can handle each block transfer
|
59
|
+
separately, with no need for a connection setup or other
|
60
|
+
server-side memory of previous block transfers.
|
61
|
+
|
62
|
+
In summary, the Block options provide a minimal way to
|
63
|
+
transfer larger representations in a block-wise fashion.
|
64
|
+
|
65
|
+
|
66
|
+
[#problems]
|
67
|
+
== Introduction
|
68
|
+
|
69
|
+
The CoRE WG is tasked with standardizing an
|
70
|
+
Application Protocol for Constrained Networks/Nodes, CoAP.
|
71
|
+
This protocol is intended to provide RESTful <<REST>> services not
|
72
|
+
unlike HTTP <<RFC2616>>,
|
73
|
+
while reducing the complexity of implementation as well as the size of
|
74
|
+
packets exchanged in order to make these services useful in a highly
|
75
|
+
constrained network of themselves highly constrained nodes.
|
76
|
+
|
77
|
+
This objective requires restraint in a number of sometimes conflicting ways:
|
78
|
+
|
79
|
+
* reducing implementation complexity in order to minimize code size,
|
80
|
+
* reducing message sizes in order to minimize the number of fragments
|
81
|
+
needed for each message (in turn to maximize the probability of
|
82
|
+
delivery of the message), the amount of transmission power needed
|
83
|
+
and the loading of the limited-bandwidth channel,
|
84
|
+
* reducing requirements on the environment such as stable storage,
|
85
|
+
good sources of randomness or user interaction capabilities.
|
86
|
+
|
87
|
+
CoAP is based on datagram transports such as UDP, which limit the
|
88
|
+
maximum size of resource representations that can be transferred
|
89
|
+
without creating unreasonable levels of IP fragmentation. In
|
90
|
+
addition, not all resource representations will fit into a single link
|
91
|
+
layer packet of a constrained network, which may cause adaptation
|
92
|
+
layer fragmentation even if IP layer fragmentation is not required.
|
93
|
+
Using fragmentation (either at the adaptation layer or at the IP
|
94
|
+
layer) to enable the transport of larger representations is possible
|
95
|
+
up to the maximum size of the underlying datagram protocol (such as
|
96
|
+
UDP), but the fragmentation/reassembly process loads the lower layers
|
97
|
+
with conversation state that is better managed in the application
|
98
|
+
layer.
|
99
|
+
|
100
|
+
This specification defines a pair of CoAP options to enable *block-wise* access to
|
101
|
+
resource representations.
|
102
|
+
The Block options provide a minimal way to transfer larger
|
103
|
+
resource representations in a block-wise fashion.
|
104
|
+
The overriding objective is to avoid
|
105
|
+
creating conversation state at the server for block-wise GET requests.
|
106
|
+
(It is impossible to fully avoid creating conversation state for
|
107
|
+
POST/PUT, if the creation/replacement of resources is to be atomic;
|
108
|
+
where that property is not needed, there is no need to create server
|
109
|
+
conversation state in this case, either.)
|
110
|
+
|
111
|
+
|
112
|
+
In summary, this specification adds a pair of Block options to CoAP that
|
113
|
+
can be used for block-wise transfers. Benefits of using these options
|
114
|
+
include:
|
115
|
+
|
116
|
+
* Transfers larger than can be accommodated in constrained-network
|
117
|
+
link-layer packets can be performed in smaller blocks.
|
118
|
+
* No hard-to-manage conversation state is created at the adaptation
|
119
|
+
layer or IP layer for fragmentation.
|
120
|
+
* The transfer of each block is acknowledged, enabling retransmission
|
121
|
+
if required.
|
122
|
+
* Both sides have a say in the block size that actually will be used.
|
123
|
+
* The resulting exchanges are easy to understand using packet
|
124
|
+
analyzer tools and thus quite accessible to debugging.
|
125
|
+
* If needed, the Block options can also be used as is to provide random
|
126
|
+
access to power-of-two sized blocks within a resource representation.
|
127
|
+
|
128
|
+
The key words "**MUST**", "**MUST NOT**", "**REQUIRED**", "**SHALL**", "**SHALL NOT**",
|
129
|
+
"**SHOULD**", "**SHOULD NOT**", "**RECOMMENDED**", "**MAY**", and "**OPTIONAL**" in this
|
130
|
+
document are to be interpreted as described in RFC 2119, BCP 14
|
131
|
+
<<RFC2119>> and indicate requirement levels for compliant CoAP
|
132
|
+
implementations.
|
133
|
+
|
134
|
+
In this document, the term "byte" is used in its now customary sense
|
135
|
+
as a synonym for "octet".
|
136
|
+
|
137
|
+
Where bit arithmetic is explained, this document uses the notation
|
138
|
+
familiar from the programming language C, except that the operator "**"
|
139
|
+
stands for exponentiation.
|
140
|
+
|
141
|
+
== Block-wise transfers
|
142
|
+
|
143
|
+
As discussed in the introduction, there are good reasons to limit the
|
144
|
+
size datagrams in constrained networks:
|
145
|
+
|
146
|
+
* by the maximum datagram size (~ 64 KiB for UDP)
|
147
|
+
* by the desire to avoid IP fragmentation (MTU of 1280 for IPv6)
|
148
|
+
* by the desire to avoid adaptation layer fragmentation (60–80 bytes
|
149
|
+
for 6LoWPAN)
|
150
|
+
|
151
|
+
When a resource representation is larger than can be comfortably
|
152
|
+
transferred in the payload of a single CoAP datagram, a Block option
|
153
|
+
can be used to indicate a block-wise transfer. As payloads can be
|
154
|
+
sent both with requests and with responses, this specification
|
155
|
+
provides two separate options for each direction of payload transfer.
|
156
|
+
|
157
|
+
In the following, the term "payload" will be used for the actual
|
158
|
+
content of a single CoAP message, i.e. a single block being
|
159
|
+
transferred, while the term "body" will be used for the entire
|
160
|
+
resource representation that is being transferred in a block-wise
|
161
|
+
fashion.
|
162
|
+
|
163
|
+
In most cases, all blocks being transferred for a body will be of the
|
164
|
+
same size. The block size is not fixed by the protocol. To keep the
|
165
|
+
implementation as simple as possible, the Block options support only a
|
166
|
+
small range of power-of-two block sizes, from 2\\**4 (16) to 2**10
|
167
|
+
(1024) bytes. As bodies often will not evenly divide into the
|
168
|
+
power-of-two block size chosen, the size need not be reached in the
|
169
|
+
final block; still this size will be given as the block size even for
|
170
|
+
the final block.
|
171
|
+
|
172
|
+
[#block-option]
|
173
|
+
=== The Block Options
|
174
|
+
|
175
|
+
[#block-option-numbers]
|
176
|
+
.Block Option Numbers
|
177
|
+
[cols=">,<,<,<,<,<",grid=cols]
|
178
|
+
|===
|
179
|
+
|Type | C/E | Name | Format | Length | Default
|
180
|
+
|
181
|
+
| 19 | Critical | Block1 | uint | 1-3 B | 0 (see below)
|
182
|
+
| 17 | Critical | Block2 | uint | 1-3 B | 0 (see below)
|
183
|
+
|===
|
184
|
+
|
185
|
+
Both Block1 and Block2 options can be present both in request and
|
186
|
+
response messages. In either case, the Block1 Option pertains to the
|
187
|
+
request payload, and the Block2 Option pertains to the response payload.
|
188
|
+
|
189
|
+
Hence, for the methods defined in <<I-D.ietf-core-coap>>, Block1 is
|
190
|
+
useful with the payload-bearing POST and PUT requests and their
|
191
|
+
responses. Block2 is useful with GET, POST, and PUT requests and
|
192
|
+
their payload-bearing responses (2.01, 2.02, 2.04, 2.05 -- see
|
193
|
+
section "Payload" of <<I-D.ietf-core-coap>>).
|
194
|
+
|
195
|
+
(As a memory aid: Block_1_ pertains to the payload of the _1st_ part
|
196
|
+
of the request-response exchange, i.e. the request, and Block_2_
|
197
|
+
pertains to the payload of the _2nd_ part of the request-response
|
198
|
+
exchange, i.e. the response.)
|
199
|
+
|
200
|
+
Where Block1 is present in a request or Block2 in a response (i.e., in
|
201
|
+
that message to the payload of which it pertains) it indicates a
|
202
|
+
block-wise transfer and describes how this block-wise payload forms
|
203
|
+
part of the entire body being transferred ("descriptive usage").
|
204
|
+
Where it is present in the opposite direction, it provides additional
|
205
|
+
control on how that payload will be formed or was processed ("control usage").
|
206
|
+
|
207
|
+
Implementation of either Block option is intended to be optional.
|
208
|
+
However, when it is present in a CoAP message, it **MUST** be processed
|
209
|
+
(or the message rejected);
|
210
|
+
therefore it is identified as a critical option.
|
211
|
+
|
212
|
+
Three items of information may need to be transferred in a Block
|
213
|
+
option:
|
214
|
+
|
215
|
+
* The size of the block (SZX);
|
216
|
+
* whether more blocks are following (M);
|
217
|
+
* the relative number of the block (NUM) within a sequence of blocks
|
218
|
+
with the given size.
|
219
|
+
|
220
|
+
The value of the option is a 1-, 2- or 3-byte integer which encodes
|
221
|
+
these three fields, see <<block>>.
|
222
|
+
|
223
|
+
[#block]
|
224
|
+
.Block option value
|
225
|
+
====
|
226
|
+
....
|
227
|
+
0
|
228
|
+
0 1 2 3 4 5 6 7
|
229
|
+
+-+-+-+-+-+-+-+-+
|
230
|
+
| NUM |M| SZX |
|
231
|
+
+-+-+-+-+-+-+-+-+
|
232
|
+
|
233
|
+
0 1
|
234
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
235
|
+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
236
|
+
| NUM |M| SZX |
|
237
|
+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
238
|
+
|
239
|
+
0 1 2
|
240
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
|
241
|
+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
242
|
+
| NUM |M| SZX |
|
243
|
+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
244
|
+
....
|
245
|
+
====
|
246
|
+
|
247
|
+
The block size is encoded as a three-bit unsigned integer (0 for 2\\**4 to 6
|
248
|
+
for 2**10 bytes), which we call the `SZX` (size exponent); the
|
249
|
+
actual block size is then `2**(SZX + 4)`. SZX is transferred in the
|
250
|
+
three least significant bits of the option value (i.e., `val & 7`
|
251
|
+
where `val` is the value of the option).
|
252
|
+
|
253
|
+
The fourth least significant bit, the M or "more" bit (`val & 8`),
|
254
|
+
indicates whether more blocks are following or the current block-wise
|
255
|
+
transfer is the last block being transferred.
|
256
|
+
|
257
|
+
The option value divided by sixteen (the NUM field) is the sequence
|
258
|
+
number of the block currently being transferred, starting from
|
259
|
+
zero. The current transfer is therefore about the `size` bytes
|
260
|
+
starting at byte `NUM << (SZX + 4)`. (Note that, as an implementation
|
261
|
+
convenience, `(val & ~0xF) << (val & 7)`, i.e. the option value with
|
262
|
+
the last 4 bits masked out, shifted to the left by the value of SZX,
|
263
|
+
gives the byte position of the block.)
|
264
|
+
|
265
|
+
The default value of both the Block1 and the Block2 Option is zero,
|
266
|
+
indicating that the current block is the first and only block of the
|
267
|
+
transfer (block number 0, M bit not set); however, there is no
|
268
|
+
explicit size implied by this default value.
|
269
|
+
|
270
|
+
More specifically, within the option value of a Block1 or Block2
|
271
|
+
Option, the meaning of the option fields is defined as follows:
|
272
|
+
|
273
|
+
NUM: :: Block Number. The block number is a variable-size (4, 12, or 20 bit)
|
274
|
+
unsigned integer (uint, see Appendix A of <<I-D.ietf-core-coap>>)
|
275
|
+
indicating the block number being requested or provided. Block
|
276
|
+
number 0 indicates the first block of a body.
|
277
|
+
|
278
|
+
M: :: More Flag (not last block). For descriptive usage, this flag, if
|
279
|
+
unset, indicates that the payload in this message is the last block
|
280
|
+
in the body; when set it indicates that there are one or more
|
281
|
+
additional blocks available. When a Block2 Option is used in a
|
282
|
+
request to retrieve a specific block number ("control usage"), the M
|
283
|
+
bit **MUST** be sent as zero and ignored on reception. (In a Block1
|
284
|
+
Option in a response, the M flag is used to indicate atomicity, see
|
285
|
+
below.)
|
286
|
+
|
287
|
+
SZX: :: Block Size. The block size is a three-bit unsigned integer indicating the size of a block to
|
288
|
+
the power of two. Thus block size = 2\\**(SZX + 4). The allowed
|
289
|
+
values of SZX are 0 to 6, i.e., the minimum block size is 2**(0+4) = 16
|
290
|
+
and the maximum is 2**(6+4) = 1024.
|
291
|
+
The value 7 for SZX (which would indicate a block size of 2048) is
|
292
|
+
reserved, i.e. [bcp14]#MUST NOT# be sent and [bcp14]#MUST# lead to a 4.00 Bad Request
|
293
|
+
response code upon reception in a request.
|
294
|
+
|
295
|
+
The Block options are used in one of three roles:
|
296
|
+
|
297
|
+
* In descriptive usage, i.e. a Block2 Option in a response (e.g., a
|
298
|
+
2.05 response for GET), or a Block1 Option in a request (e.g., PUT
|
299
|
+
or POST):
|
300
|
+
** The NUM field in the option value describes what block number is
|
301
|
+
contained in the payload of this message.
|
302
|
+
** The M bit indicates whether further
|
303
|
+
blocks are required to complete the transfer of that body.
|
304
|
+
** The block size given by SZX **MUST** match the size of the payload in
|
305
|
+
bytes, if the M bit is set. (The block size given is irrelevant if
|
306
|
+
M is unset). For Block2, if the request suggested a larger value
|
307
|
+
of SZX, the next request **MUST** move SZX down to the size given
|
308
|
+
here. (The effect is that, if the server uses the smaller of its
|
309
|
+
preferred block size and the one requested, all blocks for a body
|
310
|
+
use the same block size.)
|
311
|
+
|
312
|
+
* A Block2 Option in control usage in a request (e.g., GET):
|
313
|
+
** The NUM field in the Block2 Option gives the block number of the
|
314
|
+
payload that is being requested to be returned in the response.
|
315
|
+
** In this case, the M bit has no function and **MUST** be set to zero.
|
316
|
+
** The block size given (SZX) suggests a block size (in the case of
|
317
|
+
block number 0) or repeats the block size of previous blocks
|
318
|
+
received (in the case of block numbers other than 0).
|
319
|
+
|
320
|
+
* A Block1 Option in control usage in a response (e.g., a 2.xx
|
321
|
+
response for a PUT or POST request):
|
322
|
+
** The NUM field of the Block1 Option indicates what block number is
|
323
|
+
being acknowledged.
|
324
|
+
** If the M bit was set in the request, the server can choose whether
|
325
|
+
to act on each block separately, with no memory, or whether to
|
326
|
+
handle the request for the entire body atomically, or any mix of
|
327
|
+
the two. If the M bit is also set in the response, it indicates
|
328
|
+
that this response does not carry the final response code to the
|
329
|
+
request, i.e. the server collects further blocks and plans to
|
330
|
+
implement the request atomically (e.g., acts only upon reception
|
331
|
+
of the last block of payload). Conversely, if the M bit is unset
|
332
|
+
even though it was set in the request, it indicates the block-wise
|
333
|
+
request was enacted now specifically for this block, and the
|
334
|
+
response carries the final response to this request (and to any
|
335
|
+
previous ones with the M bit set in the response's Block1 Option
|
336
|
+
in this sequence of block-wise transfers); the client is still
|
337
|
+
expected to continue sending further blocks, the request method
|
338
|
+
for which may or may not also be enacted per-block.
|
339
|
+
** Finally, the SZX block size given in a control Block1 Option
|
340
|
+
indicates the largest block size preferred by the server for
|
341
|
+
transfers toward the resource that is the same or smaller than the
|
342
|
+
one used in the initial exchange; the client **SHOULD** use this block
|
343
|
+
size or a smaller one in all further requests in the transfer
|
344
|
+
sequence, even if that means changing the block size (and possibly
|
345
|
+
scaling the block number accordingly) from now on.
|
346
|
+
|
347
|
+
[#block-usage]
|
348
|
+
=== Using the Block Options
|
349
|
+
|
350
|
+
Using one or both Block options, a single REST operation can be split
|
351
|
+
into multiple CoAP message exchanges. As specified in
|
352
|
+
<<I-D.ietf-core-coap>>, each of these message exchanges uses their own
|
353
|
+
CoAP Message ID.
|
354
|
+
|
355
|
+
When a request is answered with a response carrying a Block2 Option with
|
356
|
+
the M bit set, the requester may retrieve additional blocks of the
|
357
|
+
resource representation by sending further
|
358
|
+
requests with the same options and a Block2 Option giving the block
|
359
|
+
number and block size desired. In a request, the client **MUST** set the M bit of a Block2 Option
|
360
|
+
to zero and the server **MUST** ignore it on reception.
|
361
|
+
|
362
|
+
To influence the block size used in a response, the
|
363
|
+
requester also uses the Block2 Option, giving the desired size, a block
|
364
|
+
number of zero and an M bit of zero. A server **MUST** use the block
|
365
|
+
size indicated or a smaller size. Any further block-wise requests for
|
366
|
+
blocks beyond the first one **MUST** indicate the same block size that was
|
367
|
+
used by the server in the
|
368
|
+
response for the first request that gave a desired size using a Block2
|
369
|
+
Option.
|
370
|
+
|
371
|
+
Once the Block2 Option is used by the requester, all requests in a
|
372
|
+
single block-wise transfer
|
373
|
+
**MUST** ultimately use the same size, except that there may not be enough
|
374
|
+
content to fill the last block (the one returned with the M bit not
|
375
|
+
set).
|
376
|
+
(Note that the client may start using the Block2 Option in a second
|
377
|
+
request after a first request without a Block2 Option resulted in a
|
378
|
+
Block option in the response.)
|
379
|
+
The server **SHOULD** use the block
|
380
|
+
size indicated in the request option or a smaller size, but the
|
381
|
+
requester **MUST** take note of the actual block size used in the response
|
382
|
+
it receives
|
383
|
+
to its initial request and proceed to use it in subsequent requests. The
|
384
|
+
server behavior **MUST** ensure that this client behavior results in the
|
385
|
+
same block size for all responses in a sequence (except for the last
|
386
|
+
one with the M bit not set, and possibly the first one if the initial
|
387
|
+
request did not contain a Block2 Option).
|
388
|
+
|
389
|
+
Block-wise transfers can be used to GET resources the representations
|
390
|
+
of which are entirely static (not changing over time at all, such as
|
391
|
+
in a schema describing a device), or for dynamically changing
|
392
|
+
resources. In the latter case, the Block2 Option **SHOULD** be used in
|
393
|
+
conjunction with the ETag Option, to ensure that the blocks being
|
394
|
+
reassembled are from the same version of the representation: The
|
395
|
+
server **SHOULD** include an ETag option in each response. If an ETag
|
396
|
+
option is available, the client's reassembler, when reassembling the
|
397
|
+
representation from the blocks being exchanged, **MUST** compare ETag
|
398
|
+
Options. If the ETag Options do not match in a GET transfer, the
|
399
|
+
requester has the option of attempting to retrieve fresh values for
|
400
|
+
the blocks it retrieved first. To minimize the resulting
|
401
|
+
inefficiency, the server **MAY** cache the current value of a
|
402
|
+
representation for an ongoing sequence of requests. The client **MAY**
|
403
|
+
facilitate identifying the sequence by using the Token Option with a
|
404
|
+
non-default value. Note well that this specification makes no
|
405
|
+
requirement for the server to establish any state; however, servers
|
406
|
+
that offer quickly changing resources may thereby make it impossible
|
407
|
+
for a client to ever retrieve a consistent set of blocks.
|
408
|
+
|
409
|
+
In a request with a request payload (e.g., PUT or POST), the Block1
|
410
|
+
Option refers to the payload in the request (descriptive usage).
|
411
|
+
|
412
|
+
In response to a request with a payload (e.g., a PUT or POST
|
413
|
+
transfer), the block size given in the Block1 Option indicates the
|
414
|
+
block size preference of the server for this resource (control usage).
|
415
|
+
Obviously, at this point the first block has already been transferred
|
416
|
+
by the client without benefit of this knowledge. Still, the client
|
417
|
+
**SHOULD** heed the preference and, for all further blocks, use the block
|
418
|
+
size preferred by the server or a smaller one. Note that any
|
419
|
+
reduction in the block size may mean that the second request starts
|
420
|
+
with a block number larger than one, as the first request already
|
421
|
+
transferred multiple blocks as counted in the smaller size.
|
422
|
+
|
423
|
+
To counter the effects of adaptation layer fragmentation on packet
|
424
|
+
delivery probability, a client may want to give up retransmitting a
|
425
|
+
request with a relatively large payload even before MAX_RETRANSMIT has
|
426
|
+
been reached, and try restating the request as a block-wise transfer
|
427
|
+
with a smaller payload. Note that this new attempt is then a new
|
428
|
+
message-layer transaction and requires a new Message ID.
|
429
|
+
(Because of the uncertainty whether the request or the acknowledgement
|
430
|
+
was lost, this strategy is useful mostly for idempotent requests.)
|
431
|
+
|
432
|
+
In a blockwise transfer of a request payload (e.g., a PUT or POST) that is intended to be implemented in an
|
433
|
+
atomic fashion at the server, the actual creation/replacement takes
|
434
|
+
place at the time the final block, i.e. a block with the M bit unset
|
435
|
+
in the Block1 Option, is received. If not
|
436
|
+
all previous blocks are available at the server at this time, the
|
437
|
+
transfer fails and error code 4.08 (Request Entity Incomplete) **MUST** be returned. The error
|
438
|
+
code 4.13 (Request Entity Too Large) can be returned at any time by a server that does not
|
439
|
+
currently have the resources to store blocks for a block-wise request payload transfer that it would intend to implement in an atomic fashion.
|
440
|
+
|
441
|
+
If multiple concurrently proceeding block-wise request payload
|
442
|
+
transfer (e.g., PUT or POST) operations
|
443
|
+
are possible, the requester **SHOULD** use the Token Option to clearly separate the different sequences.
|
444
|
+
In this case, when reassembling the representation from the blocks
|
445
|
+
being exchanged to enable atomic processing, the reassembler **MUST**
|
446
|
+
compare any Token Options present (and, as usual, taking an absent Token Option
|
447
|
+
to default to the empty Token).
|
448
|
+
If atomic processing is not desired, there is no need to process the
|
449
|
+
Token Option (but it is still returned in the response as usual).
|
450
|
+
|
451
|
+
== Examples
|
452
|
+
|
453
|
+
This section gives a number of short examples with message flows for a
|
454
|
+
block-wise GET, and for a PUT or POST.
|
455
|
+
These examples demonstrate the basic operation, the operation in the
|
456
|
+
presence of retransmissions, and examples for the operation of the
|
457
|
+
block size negotiation.
|
458
|
+
|
459
|
+
In all these examples, a Block option is shown in a decomposed way
|
460
|
+
separating the kind of Block option (1 or 2), block number (NUM), more bit (M), and block size exponent
|
461
|
+
(2**(SZX+4)) by slashes. E.g., a Block2 Option value of 33 would be shown as
|
462
|
+
2/2/0/32), or a Block1 Option value of 59 would be shown as 1/3/1/128.
|
463
|
+
|
464
|
+
The first example (<<simple-get>>) shows a GET request that is split
|
465
|
+
into three blocks.
|
466
|
+
The server proposes a block size of 128, and the client agrees.
|
467
|
+
The first two ACKs contain 128 bytes of payload each, and third ACK
|
468
|
+
contains between 1 and 128 bytes.
|
469
|
+
|
470
|
+
[#simple-get]
|
471
|
+
.Simple blockwise GET
|
472
|
+
====
|
473
|
+
....
|
474
|
+
CLIENT SERVER
|
475
|
+
| |
|
476
|
+
| CON [MID=1234], GET, /status ------> |
|
477
|
+
| |
|
478
|
+
| <------ ACK [MID=1234], 2.05 Content, 2/0/1/128 |
|
479
|
+
| |
|
480
|
+
| CON [MID=1235], GET, /status, 2/1/0/128 ------> |
|
481
|
+
| |
|
482
|
+
| <------ ACK [MID=1235], 2.05 Content, 2/1/1/128 |
|
483
|
+
| |
|
484
|
+
| CON [MID=1236], GET, /status, 2/2/0/128 ------> |
|
485
|
+
| |
|
486
|
+
| <------ ACK [MID=1236], 2.05 Content, 2/2/0/128 |
|
487
|
+
....
|
488
|
+
====
|
489
|
+
|
490
|
+
In the second example (<<early-get>>), the client anticipates the blockwise transfer
|
491
|
+
(e.g., because of a size indication in the link-format description)
|
492
|
+
and sends a size proposal. All ACK messages except for the last carry
|
493
|
+
64 bytes of payload; the last one carries between 1 and 64 bytes.
|
494
|
+
|
495
|
+
[#early-get]
|
496
|
+
.Blockwise GET with early negotiation
|
497
|
+
====
|
498
|
+
....
|
499
|
+
CLIENT SERVER
|
500
|
+
| |
|
501
|
+
| CON [MID=1234], GET, /status, 2/0/0/64 ------> |
|
502
|
+
| |
|
503
|
+
| <------ ACK [MID=1234], 2.05 Content, 2/0/1/64 |
|
504
|
+
| |
|
505
|
+
| CON [MID=1235], GET, /status, 2/1/0/64 ------> |
|
506
|
+
| |
|
507
|
+
| <------ ACK [MID=1235], 2.05 Content, 2/1/1/64 |
|
508
|
+
: :
|
509
|
+
: ... :
|
510
|
+
: :
|
511
|
+
| CON [MID=1238], GET, /status, 2/4/0/64 ------> |
|
512
|
+
| |
|
513
|
+
| <------ ACK [MID=1238], 2.05 Content, 2/4/1/64 |
|
514
|
+
| |
|
515
|
+
| CON [MID=1239], GET, /status, 2/5/0/64 ------> |
|
516
|
+
| |
|
517
|
+
| <------ ACK [MID=1239], 2.05 Content, 2/5/0/64 |
|
518
|
+
....
|
519
|
+
====
|
520
|
+
|
521
|
+
In the third example (<<late-get>>), the client is surprised by the
|
522
|
+
need for a blockwise transfer, and unhappy with the size chosen
|
523
|
+
unilaterally by the server. As it did not send a size proposal
|
524
|
+
initially, the negotiation only influences the size from the second
|
525
|
+
message exchange onward. Since the client already obtained both the first and
|
526
|
+
second 64-byte block in the first 128-byte exchange, it goes on
|
527
|
+
requesting the third 64-byte block ("2/0/64"). None of this is (or
|
528
|
+
needs to be) understood by the server, which simply responds to the
|
529
|
+
requests as it best can.
|
530
|
+
|
531
|
+
[#late-get]
|
532
|
+
.Blockwise GET with late negotiation
|
533
|
+
====
|
534
|
+
....
|
535
|
+
CLIENT SERVER
|
536
|
+
| |
|
537
|
+
| CON [MID=1234], GET, /status ------> |
|
538
|
+
| |
|
539
|
+
| <------ ACK [MID=1234], 2.05 Content, 2/0/1/128 |
|
540
|
+
| |
|
541
|
+
| CON [MID=1235], GET, /status, 2/2/0/64 ------> |
|
542
|
+
| |
|
543
|
+
| <------ ACK [MID=1235], 2.05 Content, 2/2/1/64 |
|
544
|
+
| |
|
545
|
+
| CON [MID=1236], GET, /status, 2/3/0/64 ------> |
|
546
|
+
| |
|
547
|
+
| <------ ACK [MID=1236], 2.05 Content, 2/3/1/64 |
|
548
|
+
| |
|
549
|
+
| CON [MID=1237], GET, /status, 2/4/0/64 ------> |
|
550
|
+
| |
|
551
|
+
| <------ ACK [MID=1237], 2.05 Content, 2/4/1/64 |
|
552
|
+
| |
|
553
|
+
| CON [MID=1238], GET, /status, 2/5/0/64 ------> |
|
554
|
+
| |
|
555
|
+
| <------ ACK [MID=1238], 2.05 Content, 2/5/0/64 |
|
556
|
+
....
|
557
|
+
====
|
558
|
+
|
559
|
+
In all these (and the following) cases, retransmissions are handled by
|
560
|
+
the CoAP message exchange layer, so they don't influence the block
|
561
|
+
operations (<<late-get-lost-con>>, <<late-get-lost-ack>>).
|
562
|
+
|
563
|
+
[#late-get-lost-con]
|
564
|
+
.Blockwise GET with late negotiation and lost CON
|
565
|
+
====
|
566
|
+
....
|
567
|
+
CLIENT SERVER
|
568
|
+
| |
|
569
|
+
| CON [MID=1234], GET, /status ------> |
|
570
|
+
| |
|
571
|
+
| <------ ACK [MID=1234], 2.05 Content, 2/0/1/128 |
|
572
|
+
| |
|
573
|
+
| CON [MID=1235], GE///////////////////////// |
|
574
|
+
| |
|
575
|
+
| (timeout) |
|
576
|
+
| |
|
577
|
+
| CON [MID=1235], GET, /status, 2/2/0/64 ------> |
|
578
|
+
| |
|
579
|
+
| <------ ACK [MID=1235], 2.05 Content, 2/2/1/64 |
|
580
|
+
: :
|
581
|
+
: ... :
|
582
|
+
: :
|
583
|
+
| CON [MID=1238], GET, /status, 2/5/0/64 ------> |
|
584
|
+
| |
|
585
|
+
| <------ ACK [MID=1238], 2.05 Content, 2/5/0/64 |
|
586
|
+
....
|
587
|
+
====
|
588
|
+
|
589
|
+
|
590
|
+
[#late-get-lost-ack]
|
591
|
+
.Blockwise GET with late negotiation and lost ACK
|
592
|
+
====
|
593
|
+
....
|
594
|
+
CLIENT SERVER
|
595
|
+
| |
|
596
|
+
| CON [MID=1234], GET, /status ------> |
|
597
|
+
| |
|
598
|
+
| <------ ACK [MID=1234], 2.05 Content, 2/0/1/128 |
|
599
|
+
| |
|
600
|
+
| CON [MID=1235], GET, /status, 2/2/0/64 ------> |
|
601
|
+
| |
|
602
|
+
| //////////////////////////////////tent, 2/2/1/64 |
|
603
|
+
| |
|
604
|
+
| (timeout) |
|
605
|
+
| |
|
606
|
+
| CON [MID=1235], GET, /status, 2/2/0/64 ------> |
|
607
|
+
| |
|
608
|
+
| <------ ACK [MID=1235], 2.05 Content, 2/2/1/64 |
|
609
|
+
: :
|
610
|
+
: ... :
|
611
|
+
: :
|
612
|
+
| CON [MID=1238], GET, /status, 2/5/0/64 ------> |
|
613
|
+
| |
|
614
|
+
| <------ ACK [MID=1238], 2.05 Content, 2/5/0/64 |
|
615
|
+
....
|
616
|
+
====
|
617
|
+
|
618
|
+
The following examples demonstrate a PUT exchange; a POST exchange
|
619
|
+
looks the same, with different requirements on atomicity/idempotence.
|
620
|
+
To ensure that the blocks relate to the same version of the resource
|
621
|
+
representation carried in the request, the client in
|
622
|
+
<<simple-put-atomic>> sets the Token to
|
623
|
+
"v17" in all requests. Note that, as with the GET, the responses to
|
624
|
+
the requests that have a more bit in the request Block2 Option are
|
625
|
+
provisional; only the final response tells the client that the PUT
|
626
|
+
succeeded.
|
627
|
+
|
628
|
+
[#simple-put-atomic]
|
629
|
+
.Simple atomic blockwise PUT
|
630
|
+
====
|
631
|
+
....
|
632
|
+
CLIENT SERVER
|
633
|
+
| |
|
634
|
+
| CON [MID=1234], PUT, /options, v17, 1/0/1/128 ------> |
|
635
|
+
| |
|
636
|
+
| <------ ACK [MID=1234], 2.04 Changed, 1/0/1/128 |
|
637
|
+
| |
|
638
|
+
| CON [MID=1235], PUT, /options, v17, 1/1/1/128 ------> |
|
639
|
+
| |
|
640
|
+
| <------ ACK [MID=1235], 2.04 Changed, 1/1/1/128 |
|
641
|
+
| |
|
642
|
+
| CON [MID=1236], PUT, /options, v17, 1/2/0/128 ------> |
|
643
|
+
| |
|
644
|
+
| <------ ACK [MID=1236], 2.04 Changed, 1/2/0/128 |
|
645
|
+
....
|
646
|
+
====
|
647
|
+
|
648
|
+
A stateless server that simply builds/updates the resource in place
|
649
|
+
(statelessly) may indicate this by not setting the more bit in the
|
650
|
+
response (<<simple-put-stateless>>); in this case, the response codes are valid separately for
|
651
|
+
each block being updated. This is of course only an acceptable
|
652
|
+
behavior of the server if the potential inconsistency present during
|
653
|
+
the run of the message exchange sequence does not lead to problems,
|
654
|
+
e.g. because the resource being created or changed is not yet or not currently in
|
655
|
+
use.
|
656
|
+
|
657
|
+
[#simple-put-stateless]
|
658
|
+
.Simple stateless blockwise PUT
|
659
|
+
====
|
660
|
+
....
|
661
|
+
CLIENT SERVER
|
662
|
+
| |
|
663
|
+
| CON [MID=1234], PUT, /options, v17, 1/0/1/128 ------> |
|
664
|
+
| |
|
665
|
+
| <------ ACK [MID=1234], 2.04 Changed, 1/0/0/128 |
|
666
|
+
| |
|
667
|
+
| CON [MID=1235], PUT, /options, v17, 1/1/1/128 ------> |
|
668
|
+
| |
|
669
|
+
| <------ ACK [MID=1235], 2.04 Changed, 1/1/0/128 |
|
670
|
+
| |
|
671
|
+
| CON [MID=1236], PUT, /options, v17, 1/2/0/128 ------> |
|
672
|
+
| |
|
673
|
+
| <------ ACK [MID=1236], 2.04 Changed, 1/2/0/128 |
|
674
|
+
....
|
675
|
+
====
|
676
|
+
|
677
|
+
Finally, a server receiving a blockwise PUT or POST may want to indicate a
|
678
|
+
smaller block size preference (<<simple-put-atomic-nego>>).
|
679
|
+
In this case, the client **SHOULD** continue with a smaller block size; if
|
680
|
+
it does, it **MUST** adjust the block number to properly count in that smaller size.
|
681
|
+
|
682
|
+
[#simple-put-atomic-nego]
|
683
|
+
.Simple atomic blockwise PUT with negotiation
|
684
|
+
====
|
685
|
+
....
|
686
|
+
CLIENT SERVER
|
687
|
+
| |
|
688
|
+
| CON [MID=1234], PUT, /options, v17, 1/0/1/128 ------> |
|
689
|
+
| |
|
690
|
+
| <------ ACK [MID=1234], 2.04 Changed, 1/0/1/32 |
|
691
|
+
| |
|
692
|
+
| CON [MID=1235], PUT, /options, v17, 1/4/1/32 ------> |
|
693
|
+
| |
|
694
|
+
| <------ ACK [MID=1235], 2.04 Changed, 1/4/1/32 |
|
695
|
+
| |
|
696
|
+
| CON [MID=1236], PUT, /options, v17, 1/5/1/32 ------> |
|
697
|
+
| |
|
698
|
+
| <------ ACK [MID=1235], 2.04 Changed, 1/5/1/32 |
|
699
|
+
| |
|
700
|
+
| CON [MID=1237], PUT, /options, v17, 1/6/0/32 ------> |
|
701
|
+
| |
|
702
|
+
| <------ ACK [MID=1236], 2.04 Changed, 1/6/0/32 |
|
703
|
+
....
|
704
|
+
====
|
705
|
+
|
706
|
+
[#http-mapping]
|
707
|
+
== HTTP Mapping Considerations
|
708
|
+
|
709
|
+
In this subsection, we give some brief examples for the influence the
|
710
|
+
Block options might have on intermediaries that map between CoAP and
|
711
|
+
HTTP.
|
712
|
+
|
713
|
+
For mapping CoAP requests to HTTP, the intermediary may want to map
|
714
|
+
the sequence of block-wise transfers into a single HTTP transfer.
|
715
|
+
E.g., for a GET request, the intermediary could perform the HTTP
|
716
|
+
request once the first block has been requested and could then fulfill
|
717
|
+
all further block requests out of its cache.
|
718
|
+
A constrained implementation may not be able to cache the entire
|
719
|
+
object and may use a combination of TCP flow control and (in
|
720
|
+
particular if timeouts occur) HTTP range requests to obtain the
|
721
|
+
information necessary for the next block transfer at the right time.
|
722
|
+
|
723
|
+
For PUT or POST requests, there is more variation in how HTTP servers
|
724
|
+
might implement ranges. Some WebDAV servers do, but in general the
|
725
|
+
CoAP-to-HTTP intermediary will have to try sending the payload of all
|
726
|
+
the blocks of a block-wise transfer within one HTTP request. If
|
727
|
+
enough buffering is available, this request can be started when the
|
728
|
+
last CoAP block is received. A constrained implementation may want to
|
729
|
+
relieve its buffering by already starting to send the HTTP request at
|
730
|
+
the time the first CoAP block is received; any HTTP 408 status code
|
731
|
+
that indicates that the HTTP server became impatient with the
|
732
|
+
resulting transfer can then be mapped into a CoAP 4.08 response code
|
733
|
+
(similarly, 413 maps to 4.13).
|
734
|
+
|
735
|
+
For mapping HTTP to CoAP, the intermediary may want to map a single
|
736
|
+
HTTP transfer into a sequence of block-wise transfers.
|
737
|
+
If the HTTP client is too slow delivering a request body on a PUT or
|
738
|
+
POST, the CoAP server might time out and return a 4.08
|
739
|
+
response code, which in turn maps well to an HTTP 408 status code
|
740
|
+
(again, 4.13 maps to 413).
|
741
|
+
HTTP range requests received on the HTTP side may be served out of a
|
742
|
+
cache and/or mapped to GET
|
743
|
+
requests that request a sequence of blocks overlapping the range.
|
744
|
+
|
745
|
+
(Note that, while the semantics of CoAP 4.08 and HTTP 408 differ, this
|
746
|
+
difference is largely due to the different way the two protocols are
|
747
|
+
mapped to transport. HTTP has an underlying TCP connection, which
|
748
|
+
supplies connection state, so a HTTP 408 status code can immediately
|
749
|
+
be used to indicate that a timeout occurred during transmitting a
|
750
|
+
request through that active TCP connection.
|
751
|
+
The CoAP 4.08 response code indicates one or more missing blocks,
|
752
|
+
which may be due to timeouts or resource constraints; as there is no
|
753
|
+
connection state, there is no way to deliver such a response
|
754
|
+
immediately; instead, it is delivered on the next block transfer.
|
755
|
+
Still, HTTP 408 is probably the best mapping back to HTTP, as the
|
756
|
+
timeout is the most likely cause for a CoAP 4.08.
|
757
|
+
Note that there is no way to distinguish a timeout from a missing
|
758
|
+
block for a server without creating additional state, the need for
|
759
|
+
which we want to avoid.)
|
760
|
+
|
761
|
+
|
762
|
+
== IANA Considerations
|
763
|
+
|
764
|
+
This draft adds the following option numbers to the CoAP Option
|
765
|
+
Numbers registry of
|
766
|
+
<<I-D.ietf-core-coap>>:
|
767
|
+
|
768
|
+
[#tab-option-registry]
|
769
|
+
.CoAP Option Numbers
|
770
|
+
[cols=">,<,<",grid=cols]
|
771
|
+
|===
|
772
|
+
| Number | Name | Reference
|
773
|
+
|
774
|
+
| 17 | Block2 | <<RFCXXXX>>
|
775
|
+
| 19 | Block1 | <<RFCXXXX>>
|
776
|
+
|===
|
777
|
+
|
778
|
+
This draft adds the following response code to the CoAP Response Codes registry of
|
779
|
+
<<I-D.ietf-core-coap>>:
|
780
|
+
|
781
|
+
[#tab-response-code-registry]
|
782
|
+
.CoAP Response Codes
|
783
|
+
[cols=">,<,<"]
|
784
|
+
|===
|
785
|
+
| Code | Description | Reference
|
786
|
+
|
787
|
+
| 136 | 4.08 Request Entity Incomplete | <<RFCXXXX>>
|
788
|
+
|===
|
789
|
+
|
790
|
+
|
791
|
+
== Security Considerations
|
792
|
+
|
793
|
+
Providing access to blocks within a resource may lead to
|
794
|
+
surprising vulnerabilities.
|
795
|
+
Where requests are not implemented atomically, an attacker may be able
|
796
|
+
to exploit a race condition or confuse a server by inducing it to use
|
797
|
+
a partially updated resource representation.
|
798
|
+
Partial transfers may also make certain problematic data invisible to
|
799
|
+
intrusion detection systems; it is **RECOMMENDED** that an intrusion
|
800
|
+
detection system (IDS) that analyzes resource representations transferred by
|
801
|
+
CoAP implement the Block options to gain access to entire resource representations.
|
802
|
+
Still, approaches such as transferring even-numbered blocks on one path and odd-numbered
|
803
|
+
blocks on another path, or even transferring blocks multiple times
|
804
|
+
with different content and
|
805
|
+
obtaining a different interpretation of temporal order at the IDS than
|
806
|
+
at the server, may prevent an IDS from seeing the whole picture.
|
807
|
+
These kinds of attacks are well understood from IP fragmentation and
|
808
|
+
TCP segmentation; CoAP does not add fundamentally new considerations.
|
809
|
+
|
810
|
+
Where access to a resource is only granted to clients making use of a specific security
|
811
|
+
association, all blocks of that resource **MUST** be subject to the same
|
812
|
+
security checks; it **MUST NOT** be possible for unprotected exchanges to
|
813
|
+
influence blocks of an otherwise protected resource.
|
814
|
+
As a related consideration, where object security is employed,
|
815
|
+
PUT/POST should be implemented in the atomic fashion, unless the
|
816
|
+
object security operation is performed on each access and the
|
817
|
+
creation of unusable resources can be tolerated.
|
818
|
+
|
819
|
+
[#mitigating-exhaustion-attacks]
|
820
|
+
=== Mitigating Resource Exhaustion Attacks
|
821
|
+
|
822
|
+
Certain blockwise requests may induce the server to create state, e.g. to
|
823
|
+
create a snapshot for the blockwise GET of a fast-changing resource
|
824
|
+
to enable consistent access to the same
|
825
|
+
version of a resource for all blocks, or to create temporary
|
826
|
+
resource representations that are collected until pressed into
|
827
|
+
service by a final PUT or POST with the more bit unset.
|
828
|
+
All mechanisms that induce a server to create state that cannot simply
|
829
|
+
be cleaned up create opportunities for denial-of-service attacks.
|
830
|
+
Servers **SHOULD** avoid being subject to resource exhaustion based on state
|
831
|
+
created by untrusted sources.
|
832
|
+
But even if this is done, the mitigation may cause a denial-of-service
|
833
|
+
to a legitimate request when it is drowned out by other state-creating
|
834
|
+
requests.
|
835
|
+
Wherever possible, servers should therefore minimize the opportunities
|
836
|
+
to create state for untrusted sources, e.g. by using stateless approaches.
|
837
|
+
|
838
|
+
Performing segmentation at the application layer is almost always
|
839
|
+
better in this respect than at the transport layer or lower (IP fragmentation,
|
840
|
+
adaptation layer fragmentation), e.g. because there is application
|
841
|
+
layer semantics that can be used for mitigation or because lower
|
842
|
+
layers provide security associations that can prevent attacks.
|
843
|
+
However, it is less common to apply timeouts and keepalive mechanisms
|
844
|
+
at the application layer than at lower layers. Servers **MAY** want to
|
845
|
+
clean up accumulated state by timing it out (cf. response code 4.08), and
|
846
|
+
clients **SHOULD** be prepared to run blockwise transfers in an expedient
|
847
|
+
way to minimize the likelihood of running into such a timeout.
|
848
|
+
|
849
|
+
[#mitigating-amplification-attacks]
|
850
|
+
=== Mitigating Amplification Attacks
|
851
|
+
|
852
|
+
<<I-D.ietf-core-coap>> discusses the susceptibility of
|
853
|
+
CoAP end-points for use in amplification attacks.
|
854
|
+
|
855
|
+
A CoAP server can reduce the amount of amplification it provides to an
|
856
|
+
attacker by offering large resource representations only in relatively
|
857
|
+
small blocks. With this, e.g., for a 1000 byte resource, a 10-byte request might
|
858
|
+
result in an 80-byte response (with a 64-byte block) instead of a
|
859
|
+
1016-byte response, considerably reducing the amplification provided.
|
860
|
+
|
861
|
+
|
862
|
+
== Acknowledgements
|
863
|
+
|
864
|
+
Much of the content of this draft is the result of
|
865
|
+
discussions with the <<I-D.ietf-core-coap>> authors, and via many CoRE
|
866
|
+
WG discussions. Tokens were suggested by Gilman Tolle and refined by
|
867
|
+
Klaus Hartke.
|
868
|
+
|
869
|
+
Charles Palmer provided extensive editorial comments to a previous
|
870
|
+
version of this draft, some of which the authors hope to have covered
|
871
|
+
in this version.
|
872
|
+
|
873
|
+
[bibliography]
|
874
|
+
== Normative References
|
875
|
+
++++
|
876
|
+
<reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
|
877
|
+
<front>
|
878
|
+
<title>
|
879
|
+
Key words for use in RFCs to Indicate Requirement Levels
|
880
|
+
</title>
|
881
|
+
<author initials="S." surname="Bradner" fullname="S. Bradner">
|
882
|
+
<organization/>
|
883
|
+
</author>
|
884
|
+
<date year="1997" month="March"/>
|
885
|
+
<abstract>
|
886
|
+
<t>
|
887
|
+
In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.
|
888
|
+
</t>
|
889
|
+
</abstract>
|
890
|
+
</front>
|
891
|
+
<seriesInfo name="BCP" value="14"/>
|
892
|
+
<seriesInfo name="RFC" value="2119"/>
|
893
|
+
<seriesInfo name="DOI" value="10.17487/RFC2119"/>
|
894
|
+
</reference>
|
895
|
+
|
896
|
+
<reference anchor="RFC2616" target="https://www.rfc-editor.org/info/rfc2616">
|
897
|
+
<front>
|
898
|
+
<title>Hypertext Transfer Protocol -- HTTP/1.1</title>
|
899
|
+
<author initials="R." surname="Fielding" fullname="R. Fielding">
|
900
|
+
<organization/>
|
901
|
+
</author>
|
902
|
+
<author initials="J." surname="Gettys" fullname="J. Gettys">
|
903
|
+
<organization/>
|
904
|
+
</author>
|
905
|
+
<author initials="J." surname="Mogul" fullname="J. Mogul">
|
906
|
+
<organization/>
|
907
|
+
</author>
|
908
|
+
<author initials="H." surname="Frystyk" fullname="H. Frystyk">
|
909
|
+
<organization/>
|
910
|
+
</author>
|
911
|
+
<author initials="L." surname="Masinter" fullname="L. Masinter">
|
912
|
+
<organization/>
|
913
|
+
</author>
|
914
|
+
<author initials="P." surname="Leach" fullname="P. Leach">
|
915
|
+
<organization/>
|
916
|
+
</author>
|
917
|
+
<author initials="T." surname="Berners-Lee" fullname="T. Berners-Lee">
|
918
|
+
<organization/>
|
919
|
+
</author>
|
920
|
+
<date year="1999" month="June"/>
|
921
|
+
<abstract>
|
922
|
+
<t>
|
923
|
+
HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as "HTTP/1.1", and is an update to RFC 2068. [STANDARDS-TRACK]
|
924
|
+
</t>
|
925
|
+
</abstract>
|
926
|
+
</front>
|
927
|
+
<seriesInfo name="RFC" value="2616"/>
|
928
|
+
<seriesInfo name="DOI" value="10.17487/RFC2616"/>
|
929
|
+
</reference>
|
930
|
+
|
931
|
+
<reference anchor="I-D.ietf-core-coap">
|
932
|
+
<front>
|
933
|
+
<title>Constrained Application Protocol (CoAP)</title>
|
934
|
+
<author initials="Z" surname="Shelby" fullname="Zach Shelby">
|
935
|
+
<organization/>
|
936
|
+
</author>
|
937
|
+
<author initials="K" surname="Hartke" fullname="Klaus Hartke">
|
938
|
+
<organization/>
|
939
|
+
</author>
|
940
|
+
<author initials="C" surname="Bormann" fullname="Carsten Bormann">
|
941
|
+
<organization/>
|
942
|
+
</author>
|
943
|
+
<date month="June" day="28" year="2013"/>
|
944
|
+
<abstract>
|
945
|
+
<t>
|
946
|
+
The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained (e.g., low-power, lossy) networks. The nodes often have 8-bit microcontrollers with small amounts of ROM and RAM, while constrained networks such as 6LoWPAN 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. CoAP provides a request/response interaction model between application endpoints, supports built-in discovery of services and resources, and includes key concepts of the Web such as URIs and Internet media types. CoAP is designed to easily interface with HTTP for integration with the Web while meeting specialized requirements such as multicast support, very low overhead and simplicity for constrained environments.
|
947
|
+
</t>
|
948
|
+
</abstract>
|
949
|
+
</front>
|
950
|
+
<seriesInfo name="Internet-Draft" value="draft-ietf-core-coap-18"/>
|
951
|
+
<format type="TXT" target="http://www.ietf.org/internet-drafts/draft-ietf-core-coap-18.txt"/>
|
952
|
+
</reference>
|
953
|
+
|
954
|
+
<reference anchor="RFCXXXX" target="https://www.rfc-editor.org/info/rfc7959">
|
955
|
+
<front>
|
956
|
+
<title>
|
957
|
+
Block-Wise Transfers in the Constrained Application Protocol (CoAP)
|
958
|
+
</title>
|
959
|
+
<author initials="C." surname="Bormann" fullname="C. Bormann">
|
960
|
+
<organization/>
|
961
|
+
</author>
|
962
|
+
<author initials="Z." surname="Shelby" fullname="Z. Shelby" role="editor">
|
963
|
+
<organization/>
|
964
|
+
</author>
|
965
|
+
<date year="2016" month="August"/>
|
966
|
+
<abstract>
|
967
|
+
<t>
|
968
|
+
The Constrained Application Protocol (CoAP) is a RESTful transfer protocol for constrained nodes and networks. Basic CoAP messages work well for small payloads from sensors and actuators; however, applications will need to transfer larger payloads occasionally -- for instance, for firmware updates. In contrast to HTTP, where TCP does the grunt work of segmenting and resequencing, CoAP is based on datagram transports such as UDP or Datagram Transport Layer Security (DTLS). These transports only offer fragmentation, which is even more problematic in constrained nodes and networks, limiting the maximum size of resource representations that can practically be transferred.
|
969
|
+
</t>
|
970
|
+
<t>
|
971
|
+
Instead of relying on IP fragmentation, this specification extends basic CoAP with a pair of "Block" options for transferring multiple blocks of information from a resource representation in multiple request-response pairs. In many important cases, the Block options enable a server to be truly stateless: the server can handle each block transfer separately, with no need for a connection setup or other server-side memory of previous block transfers. Essentially, the Block options provide a minimal way to transfer larger representations in a block-wise fashion.
|
972
|
+
</t>
|
973
|
+
<t>
|
974
|
+
A CoAP implementation that does not support these options generally is limited in the size of the representations that can be exchanged, so there is an expectation that the Block options will be widely used in CoAP implementations. Therefore, this specification updates RFC 7252.
|
975
|
+
</t>
|
976
|
+
</abstract>
|
977
|
+
</front>
|
978
|
+
<seriesInfo name="RFC" value="7959"/>
|
979
|
+
<seriesInfo name="DOI" value="10.17487/RFC7959"/>
|
980
|
+
</reference>
|
981
|
+
++++
|
982
|
+
|
983
|
+
[bibliography]
|
984
|
+
== Informative References
|
985
|
+
++++
|
986
|
+
<reference anchor="REST">
|
987
|
+
<front>
|
988
|
+
<title>Architectural Styles and the Design of Network-based Software Architectures</title>
|
989
|
+
<author initials="R." surname="Fielding" fullname="Roy Fielding">
|
990
|
+
<organization>University of California, Irvine</organization>
|
991
|
+
</author>
|
992
|
+
<date year="2000"/>
|
993
|
+
</reference>
|
994
|
+
++++
|
995
|
+
|
996
|
+
[#compat]
|
997
|
+
== Historical Note
|
998
|
+
|
999
|
+
(This appendix to be deleted by the RFC editor.)
|
1000
|
+
|
1001
|
+
An earlier version of this draft used a single option:
|
1002
|
+
|
1003
|
+
[cols=">,<,<,<,<,<"]
|
1004
|
+
|===
|
1005
|
+
| Type | C/E | Name | Format | Length | Default
|
1006
|
+
|
1007
|
+
| 13 | Critical | Block | uint | 1-3 B | 0 (see below)
|
1008
|
+
|===
|
1009
|
+
|
1010
|
+
Note that this option number has since been reallocated in
|
1011
|
+
<<I-D.ietf-core-coap>>; no backwards compatibility is provided after
|
1012
|
+
July 1st, 2011.
|
1013
|
+
|