blob: e985f30a910227f977ba5f03bccc1b6a4678a602 [file] [log] [blame]
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -07001.. _ndnSIM packet format:
2
3ndnSIM packet format
4====================
5
6Basic field types
7+++++++++++++++++
8
9::
10
11 uint8_t ::= 8-bit unsigned integer
12
13 uint16_t ::= 16-bit unsigned integer
14
15 uint32_t ::= 32-bit unsigned integer
16
17 CHAR ::= 8-bit binary data
18
19 Blob ::= Length CHAR{Length}
20
21 Length ::= uint16_t
22
23NDN Packet Type
24+++++++++++++++
25
26::
27
28 Packet ::= Version
29 PacketType
30 (Interest | ContentObject)
31
32 0 1
33 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
34 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35 | Version | PacketType |
36 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37
38For ccnb-encoding compatibility, ``Version`` / ``PacketType`` has two reserved values to denote ccnb-encoded packet:
39
40Version 0x01, PacketType 0xD2 --- ccnb-encoded ``Interest`` packet
41Version 0x04, PacketType 0x82 --- ccnb-encoded ``ContentObject`` packet
42
43
44Version
45~~~~~~~
46
47::
48
49 Version ::= uint8_t
50
51The current version of the packet format. Right only value 0x80 is allowed.
52
53PacketType
54~~~~~~~~~~
55
56::
57
58 PacketType ::= uint8_t
59
60In the current version, two packet types are defined:
61
62- ``Interest`` (``PacketType`` = 0)
63- ``ContentObject`` (``PacketType`` = 1)
64
65Any other value of PacketType is invalid and such a packet should be discarded.
66
67Interest
68++++++++
69
70The objective of the new format is to optimize encoding/decoding operations.
71
72::
73
74 Interest ::= Nonce
75 Scope
76 InterestLifetime
77 Name
78 Selectors
79 Options
80
81Minumum size of the Interest packet: 1 + 4 + 2 + 1 + (2 + 0) + (2 + 0) + (2 + 0) = 14
82
83Maximum size of the Interest packet: 1 + 4 + 2 + 1 + (2 + 65535) + (2 + 65535) + (2 + 65535) = 196619
84
85::
86
87 0 1 2 3
88 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
89 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
90 | Nonce |
91 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
92 | Scope | Reserved | InterestLifetime |
93 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
94 | Length | |
95 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
96 ~ ~
97 ~ Name ~
98 | |
99 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
100 | Length | |
101 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
102 ~ ~
103 ~ Selectors ~
104 | |
105 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
106 | Length | |
107 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
108 ~ ~
109 ~ Options ~
110 | |
111 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
112
113
114Nonce
115~~~~~
116
117::
118
119 Nonce ::= uint32_t
120
121Reserved
122~~~~~~~~
123
124::
125
126 Reserved := uint8_t
127
128Currently does not have meaning and should be zero
129
130InterestLifetime
131~~~~~~~~~~~~~~~~
132
133::
134
135 InterestLifetime := uint16_t
136
137Interest lifetime is specified in seconds. Max value is about 18 hours.
138
139Scope
140~~~~~
141
142::
143
144 Scope ::= uint8_t
145
146Scope 0 prevents propagation beyond the local ccnd (even to other applications on the same host). Scope 1 limits propagation to the applications on the originating host. Scope 2 limits propagation to no further than the next host.
147
148Name
149~~~~
150
151::
152
153 Name ::= Length (NameComponent)*
154
155 NameComponent ::= Blob
156
157
158Selectors
159~~~~~~~~~
160
161::
162
163 Selectors ::= Length (Selector)*
164
165 Selector ::= MinSuffixComponents | MaxSuffixComponents | Publisher | Exclude | ChildSelector | AnswerOriginKind
166
167All selectors are for now undefined
168
169Options
170~~~~~~~
171
172::
173
174 Options ::= Length (Option)*
175
176
177.. .................................................................................................. ..
178.. .................................................................................................. ..
179.. .................................................................................................. ..
180.. .................................................................................................. ..
181
182
183ContentObject
184+++++++++++++
185
186::
187
188 ContentObject ::= Signature
189 Name
190 Content
191
192::
193
194 0 1 2 3
195 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
196 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
197 | Length | |
198 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
199 ~ ~
200 ~ Signature ~
201 | |
202 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
203 | Length | |
204 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
205 ~ ~
206 ~ Name ~
207 | |
208 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
209 | Length | |
210 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
211 ~ ~
212 ~ Content ~
213 | |
214 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
215
216
217Signature
218~~~~~~~~~
219
220::
221
222 Signature ::= Length
223 SignatureType
224 <type-dependeds signature data>
225
226Length specifies cumulative size of SignatureInfo and SignatureBits. If SignatureType is not recognized, the received can either discard the packet or ignore the signature using Length field, specified combined length of SignatureType and SignatureType-dependent fields.
227
228::
229
230 0 1 2 3
231 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
232 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
233 | Length | SignatureType |
234 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
235 ~ ~
236 ~ <type-dependeds signature data> ~
237 | |
238 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
239
240
241SignatureType
242^^^^^^^^^^^^^
243
244::
245
246 SignatureType ::= uint16_t
247
248The current version specifies three type of signatures:
249
250- 0x0000: empty signature
251- 0x0001: SHA256 (not a real signature, but just a digest of the content)
252- 0x0002: SHA256withRSA (real public-key signature based on SHA-256 digest)
253
254Other values may be defined in future.
255
256- Values greater or equal to 0xFF00 are for experimental purposes (e.g., for simulations)
257
258<type-dependeds signature data>
259^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
260
261+-------------------+---------------------------+
262| SignatureType | SignatureData definition |
263+===================+===========================+
264| 0 (empty) | empty sequence |
265+-------------------+---------------------------+
266| 1 (sha256) | CHAR{32} |
267+-------------------+---------------------------+
268| 2 (SHA256withRSA) | CHAR{32} KeyLocator |
269+-------------------+---------------------------+
270
271KeyLocator
272^^^^^^^^^^
273
274::
275
276 KeyLocator ::= KeyLocatorType
277 (Key | Certificate | KeyName)
278
279 Key ::= Blob
280
281 Certificate ::= Blob
282
283 KeyName ::= Name
284
285
286Content
287^^^^^^^
288
289::
290
291 Content ::= Length
292 ContentInfo
293 ContentData
294
295Content length can be computed as: Length - (1 - ContentInfo.Length)
296
297::
298
299 0 1 2 3
300 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
301 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
302 | Length | Length (content Info) |
303 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
304 | Timestamp |
305 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
306 | Freshness | Reserved |
307 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
308 | Length (ContentInfoOptions) | |
309 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
310 ~ ~
311 ~ ContentInfoOptions ~
312 | |
313 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
314 ~ ~
315 ~ ContentData ~
316 | |
317 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
318
319
320ContentInfo
321^^^^^^^^^^^
322
323::
324
325 ContentInfo ::= Length
326 Timestamp
327 Freshness
328 ContentOptions
329
330Timestamp
331~~~~~~~~~
332
333::
334
335 Timestamp ::= uint32_t
336
337Timestamp specifies content generation time as Unix time timestamp (number of seconds since midnight 1/1/1970).
338
339Freshness
340~~~~~~~~~
341
342::
343
344 Freshness ::= uint16_t
345
346Freshness specifies time in seconds (since Timestamp) for which the content is considered valid.
347
348Value 0xFFFF means that content is always valid.
349
350
351ContentOptions
352~~~~~~~~~~~~~~
353
354::
355
356 ContentOptions ::= Length
357 ContentOption*
358
359 ContentOption ::= Type |
360 FinalBlockID
361
362
363Not currently defined
364