blob: cde727beb85299ac4a4af8cade25633d17b5d45a [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
173 Selectors ::= Length (Selector)*
174
175 Selector ::= MinSuffixComponents | MaxSuffixComponents | Publisher | Exclude | ChildSelector | AnswerOriginKind
176
177All selectors are for now undefined
178
179Options
180~~~~~~~
181
182::
183
184 Options ::= Length (Option)*
185
186
187.. .................................................................................................. ..
188.. .................................................................................................. ..
189.. .................................................................................................. ..
190.. .................................................................................................. ..
191
192
193ContentObject
194+++++++++++++
195
196::
197
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700198 ContentObject ::= Name
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700199 Content
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700200 Signature
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700201
202::
203
204 0 1 2 3
205 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
206 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
207 | Length | |
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700208 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
209 ~ ~
210 ~ Name ~
211 | |
212 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
213 | Length | |
214 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
215 ~ ~
216 ~ Content ~
217 | |
218 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700219 | Length | |
220 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
221 ~ ~
222 ~ Signature ~
223 | |
224 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700225
226
227Signature
228~~~~~~~~~
229
230::
231
232 Signature ::= Length
233 SignatureType
234 <type-dependeds signature data>
235
236Length 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.
237
238::
239
240 0 1 2 3
241 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
242 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
243 | Length | SignatureType |
244 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
245 ~ ~
246 ~ <type-dependeds signature data> ~
247 | |
248 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
249
250
251SignatureType
252^^^^^^^^^^^^^
253
254::
255
256 SignatureType ::= uint16_t
257
258The current version specifies three type of signatures:
259
260- 0x0000: empty signature
261- 0x0001: SHA256 (not a real signature, but just a digest of the content)
262- 0x0002: SHA256withRSA (real public-key signature based on SHA-256 digest)
263
264Other values may be defined in future.
265
266- Values greater or equal to 0xFF00 are for experimental purposes (e.g., for simulations)
267
268<type-dependeds signature data>
269^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
270
271+-------------------+---------------------------+
272| SignatureType | SignatureData definition |
273+===================+===========================+
274| 0 (empty) | empty sequence |
275+-------------------+---------------------------+
276| 1 (sha256) | CHAR{32} |
277+-------------------+---------------------------+
278| 2 (SHA256withRSA) | CHAR{32} KeyLocator |
279+-------------------+---------------------------+
280
281KeyLocator
282^^^^^^^^^^
283
284::
285
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700286 KeyLocator ::= CertName
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700287
Alexander Afanasyevb70a6c52013-06-05 10:02:32 -0700288 CertName ::= Name
Alexander Afanasyev9fb2e3d2013-03-30 21:11:07 -0700289
290
291Content
292^^^^^^^
293
294::
295
296 Content ::= Length
297 ContentInfo
298 ContentData
299
300Content length can be computed as: Length - (1 - ContentInfo.Length)
301
302::
303
304 0 1 2 3
305 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
306 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
307 | Length | Length (content Info) |
308 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
309 | Timestamp |
310 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
311 | Freshness | Reserved |
312 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
313 | Length (ContentInfoOptions) | |
314 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
315 ~ ~
316 ~ ContentInfoOptions ~
317 | |
318 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
319 ~ ~
320 ~ ContentData ~
321 | |
322 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
323
324
325ContentInfo
326^^^^^^^^^^^
327
328::
329
330 ContentInfo ::= Length
331 Timestamp
332 Freshness
333 ContentOptions
334
335Timestamp
336~~~~~~~~~
337
338::
339
340 Timestamp ::= uint32_t
341
342Timestamp specifies content generation time as Unix time timestamp (number of seconds since midnight 1/1/1970).
343
344Freshness
345~~~~~~~~~
346
347::
348
349 Freshness ::= uint16_t
350
351Freshness specifies time in seconds (since Timestamp) for which the content is considered valid.
352
353Value 0xFFFF means that content is always valid.
354
355
356ContentOptions
357~~~~~~~~~~~~~~
358
359::
360
361 ContentOptions ::= Length
362 ContentOption*
363
364 ContentOption ::= Type |
365 FinalBlockID
366
367
368Not currently defined
369