blob: 666eca050864f6f39904a120fbfd96ed4c6dedb4 [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
Alexander Afanasyeve6bf47e2013-06-24 11:51:52 -070030 Length
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -070031 (Interest | ContentObject)
32
Alexander Afanasyeve6bf47e2013-06-24 11:51:52 -070033 0 1 2 3
34 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
35 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 | Version | PacketType | Length |
37 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -070038
39For ccnb-encoding compatibility, ``Version`` / ``PacketType`` has two reserved values to denote ccnb-encoded packet:
40
41Version 0x01, PacketType 0xD2 --- ccnb-encoded ``Interest`` packet
42Version 0x04, PacketType 0x82 --- ccnb-encoded ``ContentObject`` packet
43
44
45Version
46~~~~~~~
47
48::
49
50 Version ::= uint8_t
51
52The current version of the packet format. Right only value 0x80 is allowed.
53
54PacketType
55~~~~~~~~~~
56
57::
58
59 PacketType ::= uint8_t
60
61In the current version, two packet types are defined:
62
63- ``Interest`` (``PacketType`` = 0)
64- ``ContentObject`` (``PacketType`` = 1)
65
66Any other value of PacketType is invalid and such a packet should be discarded.
67
68Interest
69++++++++
70
71The objective of the new format is to optimize encoding/decoding operations.
72
73::
74
75 Interest ::= Nonce
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -070076 Scope
77 NackType
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -070078 InterestLifetime
79 Name
80 Selectors
81 Options
82
83Minumum size of the Interest packet: 1 + 4 + 2 + 1 + (2 + 0) + (2 + 0) + (2 + 0) = 14
84
85Maximum size of the Interest packet: 1 + 4 + 2 + 1 + (2 + 65535) + (2 + 65535) + (2 + 65535) = 196619
86
87::
88
89 0 1 2 3
90 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
91 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
92 | Nonce |
93 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -070094 | Scope | NackType | InterestLifetime |
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -070095 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
96 | Length | |
97 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
98 ~ ~
99 ~ Name ~
100 | |
101 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
102 | Length | |
103 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
104 ~ ~
105 ~ Selectors ~
106 | |
107 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
108 | Length | |
109 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
110 ~ ~
111 ~ Options ~
112 | |
113 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
114
115
116Nonce
117~~~~~
118
119::
120
121 Nonce ::= uint32_t
122
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700123NackType
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700124~~~~~~~~
125
126::
127
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700128 NackType := uint8_t
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700129
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700130Currently, ndnSIM defines following NackTypes:
131
132- 0: NORMAL_INTEREST
133- 10: NACK_LOOP
134- 11: NACK_CONGESTION
135- 12: NACK_GIVEUP_PIT
136
137Values 128-255 are reserved for any application-specific and experimental purposes.
138
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700139
140InterestLifetime
141~~~~~~~~~~~~~~~~
142
143::
144
145 InterestLifetime := uint16_t
146
147Interest lifetime is specified in seconds. Max value is about 18 hours.
148
149Scope
150~~~~~
151
152::
153
154 Scope ::= uint8_t
155
156Scope 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.
157
158Name
159~~~~
160
161::
162
163 Name ::= Length (NameComponent)*
164
165 NameComponent ::= Blob
166
167
168Selectors
169~~~~~~~~~
170
171::
172
Alexander Afanasyevabb493a2013-07-19 15:31:33 -0700173 Selectors ::= Length (SelectorType Selector)*
174
175 SelectorType ::= uint8_t
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700176
177 Selector ::= MinSuffixComponents | MaxSuffixComponents | Publisher | Exclude | ChildSelector | AnswerOriginKind
178
Alexander Afanasyevabb493a2013-07-19 15:31:33 -0700179Currently, ndnSIM defines following SelectorTypes:
180
181- 0x01: Exclude
182
183Other types are currently undefined
184
185Exclude
186~~~~~~~
187
188::
189
190 Exclude ::= Length (ExcludeComponent)*
191
192 ExcludeComponent ::= ExcludeNameType NameComponent ExcludeAnyType? |
193 ExcludeAnyType
194
195 ExcludeNameType ::= uint8_t (==0x01)
196
197 ExcludeAnyType ::= uint8_t (==0x02)
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700198
199Options
200~~~~~~~
201
202::
203
204 Options ::= Length (Option)*
205
206
207.. .................................................................................................. ..
208.. .................................................................................................. ..
209.. .................................................................................................. ..
210.. .................................................................................................. ..
211
212
213ContentObject
214+++++++++++++
215
216::
217
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700218 ContentObject ::= Name
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700219 Content
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700220 Signature
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700221
222::
223
224 0 1 2 3
225 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
226 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
227 | Length | |
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700228 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
229 ~ ~
230 ~ Name ~
231 | |
232 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
233 | Length | |
234 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
235 ~ ~
236 ~ Content ~
237 | |
238 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700239 | Length | |
240 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
241 ~ ~
242 ~ Signature ~
243 | |
244 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700245
246
247Signature
248~~~~~~~~~
249
250::
251
252 Signature ::= Length
253 SignatureType
254 <type-dependeds signature data>
255
256Length 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.
257
258::
259
260 0 1 2 3
261 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
262 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
263 | Length | SignatureType |
264 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
265 ~ ~
266 ~ <type-dependeds signature data> ~
267 | |
268 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
269
270
271SignatureType
272^^^^^^^^^^^^^
273
274::
275
276 SignatureType ::= uint16_t
277
278The current version specifies three type of signatures:
279
280- 0x0000: empty signature
281- 0x0001: SHA256 (not a real signature, but just a digest of the content)
282- 0x0002: SHA256withRSA (real public-key signature based on SHA-256 digest)
283
284Other values may be defined in future.
285
286- Values greater or equal to 0xFF00 are for experimental purposes (e.g., for simulations)
287
288<type-dependeds signature data>
289^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
290
291+-------------------+---------------------------+
292| SignatureType | SignatureData definition |
293+===================+===========================+
294| 0 (empty) | empty sequence |
295+-------------------+---------------------------+
296| 1 (sha256) | CHAR{32} |
297+-------------------+---------------------------+
298| 2 (SHA256withRSA) | CHAR{32} KeyLocator |
299+-------------------+---------------------------+
300
301KeyLocator
302^^^^^^^^^^
303
304::
305
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700306 KeyLocator ::= CertName
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700307
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700308 CertName ::= Name
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700309
310
311Content
312^^^^^^^
313
314::
315
316 Content ::= Length
317 ContentInfo
318 ContentData
319
320Content length can be computed as: Length - (1 - ContentInfo.Length)
321
322::
323
324 0 1 2 3
325 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
326 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
327 | Length | Length (content Info) |
328 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
329 | Timestamp |
330 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
331 | Freshness | Reserved |
332 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
333 | Length (ContentInfoOptions) | |
334 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
335 ~ ~
336 ~ ContentInfoOptions ~
337 | |
338 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
339 ~ ~
340 ~ ContentData ~
341 | |
342 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
343
344
345ContentInfo
346^^^^^^^^^^^
347
348::
349
350 ContentInfo ::= Length
351 Timestamp
352 Freshness
353 ContentOptions
354
355Timestamp
356~~~~~~~~~
357
358::
359
360 Timestamp ::= uint32_t
361
362Timestamp specifies content generation time as Unix time timestamp (number of seconds since midnight 1/1/1970).
363
364Freshness
365~~~~~~~~~
366
367::
368
369 Freshness ::= uint16_t
370
371Freshness specifies time in seconds (since Timestamp) for which the content is considered valid.
372
373Value 0xFFFF means that content is always valid.
374
375
376ContentOptions
377~~~~~~~~~~~~~~
378
379::
380
381 ContentOptions ::= Length
382 ContentOption*
383
384 ContentOption ::= Type |
385 FinalBlockID
386
387
388Not currently defined
389