blob: a694721c478beefc514539970c3f7e51122d8ce4 [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
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -070075 Scope
76 NackType
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -070077 InterestLifetime
78 Name
79 Selectors
80 Options
81
82Minumum size of the Interest packet: 1 + 4 + 2 + 1 + (2 + 0) + (2 + 0) + (2 + 0) = 14
83
84Maximum size of the Interest packet: 1 + 4 + 2 + 1 + (2 + 65535) + (2 + 65535) + (2 + 65535) = 196619
85
86::
87
88 0 1 2 3
89 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
90 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
91 | Nonce |
92 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -070093 | Scope | NackType | InterestLifetime |
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -070094 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95 | Length | |
96 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
97 ~ ~
98 ~ Name ~
99 | |
100 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
101 | Length | |
102 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
103 ~ ~
104 ~ Selectors ~
105 | |
106 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
107 | Length | |
108 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
109 ~ ~
110 ~ Options ~
111 | |
112 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
113
114
115Nonce
116~~~~~
117
118::
119
120 Nonce ::= uint32_t
121
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700122NackType
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700123~~~~~~~~
124
125::
126
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700127 NackType := uint8_t
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700128
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700129Currently, ndnSIM defines following NackTypes:
130
131- 0: NORMAL_INTEREST
132- 10: NACK_LOOP
133- 11: NACK_CONGESTION
134- 12: NACK_GIVEUP_PIT
135
136Values 128-255 are reserved for any application-specific and experimental purposes.
137
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700138
139InterestLifetime
140~~~~~~~~~~~~~~~~
141
142::
143
144 InterestLifetime := uint16_t
145
146Interest lifetime is specified in seconds. Max value is about 18 hours.
147
148Scope
149~~~~~
150
151::
152
153 Scope ::= uint8_t
154
155Scope 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.
156
157Name
158~~~~
159
160::
161
162 Name ::= Length (NameComponent)*
163
164 NameComponent ::= Blob
165
166
167Selectors
168~~~~~~~~~
169
170::
171
172 Selectors ::= Length (Selector)*
173
174 Selector ::= MinSuffixComponents | MaxSuffixComponents | Publisher | Exclude | ChildSelector | AnswerOriginKind
175
176All selectors are for now undefined
177
178Options
179~~~~~~~
180
181::
182
183 Options ::= Length (Option)*
184
185
186.. .................................................................................................. ..
187.. .................................................................................................. ..
188.. .................................................................................................. ..
189.. .................................................................................................. ..
190
191
192ContentObject
193+++++++++++++
194
195::
196
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700197 ContentObject ::= Name
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700198 Content
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700199 Signature
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700200
201::
202
203 0 1 2 3
204 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
205 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
206 | Length | |
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700207 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
208 ~ ~
209 ~ Name ~
210 | |
211 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
212 | Length | |
213 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
214 ~ ~
215 ~ Content ~
216 | |
217 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700218 | Length | |
219 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
220 ~ ~
221 ~ Signature ~
222 | |
223 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700224
225
226Signature
227~~~~~~~~~
228
229::
230
231 Signature ::= Length
232 SignatureType
233 <type-dependeds signature data>
234
235Length 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.
236
237::
238
239 0 1 2 3
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 4 5 6 7 8 9 0 1
241 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
242 | Length | SignatureType |
243 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
244 ~ ~
245 ~ <type-dependeds signature data> ~
246 | |
247 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
248
249
250SignatureType
251^^^^^^^^^^^^^
252
253::
254
255 SignatureType ::= uint16_t
256
257The current version specifies three type of signatures:
258
259- 0x0000: empty signature
260- 0x0001: SHA256 (not a real signature, but just a digest of the content)
261- 0x0002: SHA256withRSA (real public-key signature based on SHA-256 digest)
262
263Other values may be defined in future.
264
265- Values greater or equal to 0xFF00 are for experimental purposes (e.g., for simulations)
266
267<type-dependeds signature data>
268^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
269
270+-------------------+---------------------------+
271| SignatureType | SignatureData definition |
272+===================+===========================+
273| 0 (empty) | empty sequence |
274+-------------------+---------------------------+
275| 1 (sha256) | CHAR{32} |
276+-------------------+---------------------------+
277| 2 (SHA256withRSA) | CHAR{32} KeyLocator |
278+-------------------+---------------------------+
279
280KeyLocator
281^^^^^^^^^^
282
283::
284
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700285 KeyLocator ::= CertName
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700286
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700287 CertName ::= Name
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700288
289
290Content
291^^^^^^^
292
293::
294
295 Content ::= Length
296 ContentInfo
297 ContentData
298
299Content length can be computed as: Length - (1 - ContentInfo.Length)
300
301::
302
303 0 1 2 3
304 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
305 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
306 | Length | Length (content Info) |
307 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
308 | Timestamp |
309 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
310 | Freshness | Reserved |
311 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
312 | Length (ContentInfoOptions) | |
313 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
314 ~ ~
315 ~ ContentInfoOptions ~
316 | |
317 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
318 ~ ~
319 ~ ContentData ~
320 | |
321 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
322
323
324ContentInfo
325^^^^^^^^^^^
326
327::
328
329 ContentInfo ::= Length
330 Timestamp
331 Freshness
332 ContentOptions
333
334Timestamp
335~~~~~~~~~
336
337::
338
339 Timestamp ::= uint32_t
340
341Timestamp specifies content generation time as Unix time timestamp (number of seconds since midnight 1/1/1970).
342
343Freshness
344~~~~~~~~~
345
346::
347
348 Freshness ::= uint16_t
349
350Freshness specifies time in seconds (since Timestamp) for which the content is considered valid.
351
352Value 0xFFFF means that content is always valid.
353
354
355ContentOptions
356~~~~~~~~~~~~~~
357
358::
359
360 ContentOptions ::= Length
361 ContentOption*
362
363 ContentOption ::= Type |
364 FinalBlockID
365
366
367Not currently defined
368