Deliverable item #1 - sow-2021-0006
[deliverable/ctf.git] / CTF2-SPECRC-3.0.adoc
1 // Please render with Asciidoctor
2 :doc-id: CTF2-SPECRC-3.0
3
4 = **{doc-id}**: Common Trace Format version{nbsp}2 release candidate
5 Philippe Proulx <pproulx@efficios.com>
6 v3.0, 17 December 2021
7 :attribute-missing: warn
8 :icons: font
9 :nofooter:
10 :sectnums:
11 :sectnumlevels: 5
12 :toc: left
13 :toclevels: 3
14 :nbh: &#8209;
15 :minus: −
16 :times: ×
17 :noteq: â‰
18 :ieee754: https://standards.ieee.org/standard/754-2008.html[IEEE 754-2008] binary interchange format
19 :ctf1-nl: CTF{nbsp}1
20 :ctf1: https://diamon.org/ctf/v1.8.3/[{ctf1-nl}]
21 :ctf2: CTF{nbsp}2
22 :fl-ba: fixed-length bit array
23 :c-fl-ba: Fixed-length bit array
24 :vl-ba: variable-length bit array
25 :c-vl-ba: Variable-length bit array
26 :fl-bool: fixed-length boolean
27 :c-fl-bool: Fixed-length boolean
28 :fl-int: fixed-length integer
29 :c-fl-int: Fixed-length integer
30 :fl-uint: fixed-length unsigned integer
31 :c-fl-uint: Fixed-length unsigned integer
32 :fl-sint: fixed-length signed integer
33 :c-fl-sint: Fixed-length signed integer
34 :vl-int: variable-length integer
35 :c-vl-int: Variable-length integer
36 :vl-uint: variable-length unsigned integer
37 :c-vl-uint: Variable-length unsigned integer
38 :vl-sint: variable-length signed integer
39 :c-vl-sint: Variable-length signed integer
40 :fl-enum: fixed-length enumeration
41 :c-fl-enum: Fixed-length enumeration
42 :fl-uenum: fixed-length unsigned enumeration
43 :c-fl-uenum: Fixed-length unsigned enumeration
44 :fl-senum: fixed-length signed enumeration
45 :c-fl-senum: Fixed-length signed enumeration
46 :vl-enum: variable-length enumeration
47 :c-vl-enum: Variable-length enumeration
48 :vl-uenum: variable-length unsigned enumeration
49 :c-vl-uenum: Variable-length unsigned enumeration
50 :vl-senum: variable-length signed enumeration
51 :c-vl-senum: Variable-length signed enumeration
52 :fl-fp: fixed-length floating point number
53 :c-fl-fp: Fixed-length floating point number
54 :str: null-terminated string
55 :c-str: Null-terminated string
56 :sl-array: static-length array
57 :c-sl-array: Static-length array
58 :sl-str: static-length string
59 :c-sl-str: Static-length string
60 :dl-array: dynamic-length array
61 :c-dl-array: Dynamic-length array
62 :dl-str: dynamic-length string
63 :c-dl-str: Dynamic-length string
64 :sl-blob: static-length BLOB
65 :c-sl-blob: Static-length BLOB
66 :dl-blob: dynamic-length BLOB
67 :c-dl-blob: Dynamic-length BLOB
68 :fl-ba-fc: <<fl-ba-fc,fixed-length bit array field class>>
69 :c-fl-ba-fc: <<fl-ba-fc,Fixed-length bit array field class>>
70 :vl-ba-fc: <<vl-ba-fc,variable-length bit array field class>>
71 :c-vl-ba-fc: <<vl-ba-fc,Variable-length bit array field class>>
72 :fl-bool-fc: <<fl-bool-fc,fixed-length boolean field class>>
73 :c-fl-bool-fc: <<fl-bool-fc,Fixed-length boolean field class>>
74 :fl-int-fc: <<fl-int-fc,fixed-length integer field class>>
75 :c-fl-int-fc: <<fl-int-fc,Fixed-length integer field class>>
76 :fl-uint-fc: <<fl-int-fc,fixed-length unsigned integer field class>>
77 :c-fl-uint-fc: <<fl-int-fc,Fixed-length unsigned integer field class>>
78 :fl-sint-fc: <<fl-int-fc,fixed-length signed integer field class>>
79 :c-fl-sint-fc: <<fl-int-fc,Fixed-length signed integer field class>>
80 :vl-int-fc: <<vl-int-fc,variable-length integer field class>>
81 :c-vl-int-fc: <<vl-int-fc,Variable-length integer field class>>
82 :vl-uint-fc: <<vl-int-fc,variable-length unsigned integer field class>>
83 :c-vl-uint-fc: <<vl-int-fc,Variable-length unsigned integer field class>>
84 :vl-sint-fc: <<vl-int-fc,variable-length signed integer field class>>
85 :c-vl-sint-fc: <<vl-int-fc,Variable-length signed integer field class>>
86 :fl-enum-fc: <<fl-enum-fc,fixed-length enumeration field class>>
87 :c-fl-enum-fc: <<fl-enum-fc,Fixed-length enumeration field class>>
88 :fl-uenum-fc: <<fl-enum-fc,fixed-length unsigned enumeration field class>>
89 :c-fl-uenum-fc: <<fl-enum-fc,Fixed-length unsigned enumeration field class>>
90 :fl-senum-fc: <<fl-enum-fc,fixed-length signed enumeration field class>>
91 :c-fl-senum-fc: <<fl-enum-fc,Fixed-length signed enumeration field class>>
92 :vl-enum-fc: <<vl-enum-fc,variable-length enumeration field class>>
93 :c-vl-enum-fc: <<vl-enum-fc,Variable-length enumeration field class>>
94 :vl-uenum-fc: <<vl-enum-fc,variable-length unsigned enumeration field class>>
95 :c-vl-uenum-fc: <<vl-enum-fc,Variable-length unsigned enumeration field class>>
96 :vl-senum-fc: <<vl-enum-fc,variable-length signed enumeration field class>>
97 :c-vl-senum-fc: <<vl-enum-fc,Variable-length signed enumeration field class>>
98 :fl-fp-fc: <<fl-fp-fc,fixed-length floating point number field class>>
99 :c-fl-fp-fc: <<fl-fp-fc,Fixed-length floating point number field class>>
100 :str-fc: <<str-fc,null-terminated string field class>>
101 :c-str-fc: <<str-fc,Null-terminated string field class>>
102 :sl-array-fc: <<sl-array-fc,static-length array field class>>
103 :c-sl-array-fc: <<sl-array-fc,Static-length array field class>>
104 :sl-str-fc: <<sl-str-fc,static-length string field class>>
105 :c-sl-str-fc: <<sl-str-fc,Static-length string field class>>
106 :dl-array-fc: <<dl-array-fc,dynamic-length array field class>>
107 :c-dl-array-fc: <<dl-array-fc,Dynamic-length array field class>>
108 :dl-str-fc: <<dl-str-fc,dynamic-length string field class>>
109 :c-dl-str-fc: <<dl-str-fc,Dynamic-length string field class>>
110 :sl-blob-fc: <<sl-blob-fc,static-length BLOB field class>>
111 :c-sl-blob-fc: <<sl-blob-fc,Static-length BLOB field class>>
112 :dl-blob-fc: <<dl-blob-fc,dynamic-length BLOB field class>>
113 :c-dl-blob-fc: <<dl-blob-fc,Dynamic-length BLOB field class>>
114 :struct-fc: <<struct-fc,structure field class>>
115 :c-struct-fc: <<struct-fc,Structure field class>>
116 :opt-fc: <<opt-fc,optional field class>>
117 :c-opt-fc: <<opt-fc,Optional field class>>
118 :var-fc: <<var-fc,variant field class>>
119 :c-var-fc: <<var-fc,Variant field class>>
120 :diamon: https://diamon.org/[DiaMon Workgroup]
121 :c-bo: https://en.wikipedia.org/wiki/Endianness[Byte order]
122 :rfc-7464: https://datatracker.ietf.org/doc/html/rfc7464[RFC&#160;7464]
123 :must: pass:q[__MUST__]
124 :must-not: pass:q[__MUST&#160;NOT__]
125 :required: pass:q[__REQUIRED__]
126 :should: pass:q[__SHOULD__]
127 :should-not: pass:q[__SHOULD&#160;NOT__]
128 :may: pass:q[__MAY__]
129 :optional: pass:q[__OPTIONAL__]
130 :var-f: pass:q[__**F**__]
131 :var-o: pass:q[__**O**__]
132 :var-v: pass:q[__**V**__]
133 :var-p: pass:q[__**P**__]
134 :var-s: pass:q[__**S**__]
135 :var-dec-po: pass:q[__**PO**__]
136 :var-dec-o: pass:q[__**O**__]
137 :var-dec-o-minus-po: pass:q[__**O**__&#160;−&#160;__**PO**__]
138
139 This document is a release candidate of the Common Trace Format (CTF)
140 version{nbsp}2 specification (_**CTF2-SPEC-2.0**_).
141
142 .RFC 2119
143 IMPORTANT: The key words {must}, {must-not}, {required},
144 {should}, {should-not}, {may}, and {optional} in this document, when
145 emphasized, are to be interpreted as described in
146 https://www.ietf.org/rfc/rfc2119.txt[RFC{nbsp}2119].
147
148 == Revision history
149
150 .Revision history.
151 [%header%autowidth, cols="d,d,a"]
152 |===
153 |Document |Publication date |Changes
154
155 |_**{doc-id}**_
156 |{revdate}
157 |
158 Add the optional `minimum-alignment` property to the
159 <<array-fc,abstract array field class>>.
160
161 Such a minimum alignment is needed when the <<align-dec,alignment
162 requirement>> of contained array field elements wouldn't be enough. For
163 example, a <<producer-def,producer>> could write a single
164 32-bit-aligned, 32-bit little-endian integer value, but use the
165 following {sl-array-fc} for <<consumer-def,consumers>>:
166
167 [source,json]
168 ----
169 {
170 "type": "static-length-array",
171 "length": 32,
172 "minimum-alignment": 32,
173 "element-field-class": {
174 "type": "fixed-length-boolean",
175 "length": 1,
176 "byte-order": "little-endian"
177 }
178 }
179 ----
180
181 While the producer writes a single integer value, consumers decode said
182 datum as an array of 32{nbsp}individual flags (booleans).
183
184 Update the <<align-dec>> section accordingly.
185
186 |_**CTF2&#8209;SPECRC&#8209;2.0**_
187 |9 December 2021
188 |
189 * Describe how to use a <<field-loc,field location>> with a procedure in
190 a new <<field-loc-dec>> section to make constraints easier to
191 understand.
192
193 * Rename the `members` property of a {struct-fc} to `member-classes`
194 as this JSON array contains
195 <<struct-member-cls,structure field member classes>>.
196
197 * Make an <<opt-fc,optional field>> require that _all_ its
198 possible selector fields be boolean fields, unsigned integer fields,
199 or signed integer fields.
200 +
201 Correspondingly, make a <<var-fc,variant field>> require that _all_ its
202 possible selector fields be either unsigned integer fields or signed
203 integer fields.
204 +
205 This constraint exists to accomodate some consumer implementations, in
206 particular the ones with limited integer types.
207
208 * Add the "`nil`" <<dec-val-type,decoding value type>> so that
209 <<opt-field-dec,decoding an optional field>> always generates a value.
210
211 * Specify that an "`array`" decoding value contains a sequence of values,
212 whatever their types.
213 +
214 Indeed, an <<array-fc,array field>> {may} contain <<var-fc,variant
215 fields>>, making it possible for a resulting array value to contain
216 values having different types.
217
218 |_**CTF2&#8209;SPECRC&#8209;1.0**_
219 |25 November 2021
220 |Initial {ctf2} specification release candidate.
221 |===
222
223 == What's {ctf2}?
224
225 The _**Common Trace Format**_ version{nbsp}2 is a binary
226 https://en.wikipedia.org/wiki/Tracing_(software)[trace] format designed
227 to be very fast to write without compromising great flexibility.
228
229 The intention of {ctf2} is that applications written in any programming
230 language, and running on any system (be it Linux or bare metal, for
231 example), can generate traces natively.
232
233 A {ctf2} trace has all its <<ds,data streams>> described by a
234 <<metadata-stream-overview,metadata stream>>. Given the rich set of
235 supported <<fc,data field types>>, this makes it possible for a {ctf2}
236 <<producer-def,producer>> to append data structures as is to data
237 streams without further "`data massaging`". Indeed, the size, alignment,
238 and byte order of fixed-length fields are all configurable parameters
239 within the metadata stream.
240
241 {ctf2} is transport agnostic: this document doesn't specify how to
242 transport or store {ctf2} streams. Other documents can specify such
243 conventions, and conform {ctf2} producers and <<consumer-def,consumers>>
244 may or may not adhere to them.
245
246 {ctf2} is a major revision of {ctf1}, bringing many improvements, such
247 as:
248
249 * Using JSON text sequences for the metadata stream.
250
251 * Adding <<aux-stream,auxiliary streams>> (also JSON text sequences).
252
253 * Simplifying the metadata stream.
254
255 * Adding new <<fc,field classes>>.
256
257 * Using <<roles,roles>> instead of reserved structure member names to
258 identify "`special`" fields.
259
260 and more, while remaining backward compatible at the data stream level.
261
262 == Common definitions
263
264 Common {ctf2} definitions:
265
266 [[byte-def]] <<byte-def,Byte>>::
267 A group of eight https://en.wikipedia.org/wiki/Bit[bits] operated on
268 as a unit.
269 +
270 The bits are indexed such that, if the byte represents an 8-bit unsigned
271 integer, bit{nbsp}0 is the
272 https://en.wikipedia.org/wiki/Bit_numbering#Least_significant_bit[least
273 significant] and bit{nbsp}7 is the
274 https://en.wikipedia.org/wiki/Bit_numbering#Most_significant_bit[most
275 significant].
276
277 [[class-def]] <<class-def,Class>>::
278 A set of values (instances) which share common properties.
279 +
280 For example, a {fl-uint-fc} with an 8-bit length property is the set of
281 the all the {fl-uint} fields from binary `00000000` to `11111111`
282 (integers 0{nbsp}to{nbsp}255).
283 +
284 This specification often states that some class _describes_ instances.
285 For example, an <<erc-frag,event record class>> describes <<er,event
286 records>>.
287
288 [[consumer-def]] <<consumer-def,Consumer>>::
289 A software or hardware system which consumes (reads) the streams of
290 a <<trace,trace>>.
291 +
292 A trace consumer is often a _trace viewer_ or a _trace analyzer_.
293
294 [[ns-def]] <<ns-def,Namespace>>::
295 A string of which the purpose is to avoid naming conflicts.
296 +
297 This document doesn't specify the format of a namespace. A producer
298 {should} use a URI, or at least include a domain name owned by the
299 organization defining the objects under a namespace.
300 +
301 IMPORTANT: The `std` namespace is reserved for the {ctf2} specification.
302
303 [[producer-def]] <<producer-def,Producer>>::
304 A software or hardware system which produces (writes) the streams of
305 a <<trace,trace>>.
306 +
307 A trace producer is often a _tracer_.
308
309 [[seq-def]] <<seq-def,Sequence>>::
310 A set of related items which follow each other in a particular
311 order.
312
313 [[stream-def]] <<stream-def,Stream>>::
314 A <<seq-def,sequence>> of <<byte-def,bytes>>.
315
316 [[trace]]
317 == Trace composition
318
319 A trace is:
320
321 * One <<metadata-stream-overview,metadata stream>>.
322 * One or more <<data-stream,data streams>>.
323 * Zero or more <<aux-stream,auxiliary streams>>.
324
325 As a reminder, this specification defines a <<stream-def,stream>> as a
326 sequence of bytes.
327
328 NOTE: This document doesn't specify how to transport or store {ctf2}
329 streams. A <<producer-def,producer>> could serialize all streams as a
330 single file on the file system, or it could send the streams over the
331 network using TCP, to name a few examples.
332
333 [[metadata-stream-overview]]
334 === Metadata stream (overview)
335
336 A metadata stream describes trace <<ds,data streams>> with JSON objects.
337
338 A metadata stream describes things such as:
339
340 * The <<cc-frag,class>> of the data stream <<def-clk,default clocks>>.
341 * The names of <<erc-frag,event record classes>>.
342 * The <<fc,classes>> of event record fields.
343
344 Multiple traces {may} share the same metadata stream: a given trace
345 {may} contain specific information in its own <<aux-stream,auxiliary
346 streams>>.
347
348 See <<metadata-stream>> for the full metadata stream specification.
349
350 [[ds]]
351 === Data stream
352
353 A _data stream_ is a <<seq-def,sequence>> of one or more data
354 <<pkt,packets>>:
355
356 image::{doc-id}-images/ctf-trace-all.svg[]
357
358 In the <<metadata-stream,metadata stream>>, a
359 <<dsc-frag,data stream class>> describes data streams.
360
361 A packet {must} contain one or more bytes of data.
362
363 Although a packet {may} contain padding (garbage data) at the end
364 itself, from the point of view of a data stream, there's no padding
365 between packets. In other words, the byte following the last byte of a
366 packet is the first byte of the next packet.
367
368 A data stream {may} have, conceptually:
369
370 [[def-clk]] One default, monotonic clock::
371 Described by a <<cc-frag,clock class>> in the metadata stream.
372 +
373 <<pkt,Packets>> and <<er,event records>> {may} contain snapshots, named
374 _timestamps_, of the default clock of their data stream.
375
376 [[disc-er-counter]] One counter of discarded event records::
377 Indicates the number of event records which the
378 <<producer-def,producer>> needed to discard for different reasons.
379 +
380 For example, a tracer could discard an event record when it doesn't fit
381 some buffer and there's no other available buffer.
382 +
383 A packet {may} contain a snapshot of this counter.
384
385 See <<ds-dec>> to learn how to decode a {ctf2} data stream.
386
387 [[pkt]]
388 ==== Packet
389
390 A _packet_ is a segment of a <<ds,data stream>>.
391
392 A packet contains a <<seq-def,sequence>> of data _fields_ or padding
393 (garbage data). In the metadata stream, <<fc,field classes>> describe
394 data fields.
395
396 A packet {var-p}, contained in a data stream{nbsp}{var-s}, contains,
397 in this order:
398
399 . [[pkt-header]] {optional}: A **header** <<struct-fc,structure>> field,
400 described at the <<tc-frag,trace class>> level in the
401 <<metadata-stream,metadata stream>>, which contains, in this order:
402 .. {optional}: A packet magic number field (0xc1fc1fc1, or 3254525889).
403 .. In any order:
404 *** {optional}: A trace class UUID field.
405 *** {optional}: One or more fields which contain the numeric ID of the
406 <<dsc-frag,class>> of{nbsp}{var-s}.
407 *** {optional}: One or more fields which contain the numeric ID
408 of{nbsp}{var-s}.
409
410 . [[pkt-ctx]] {optional}: A **context** <<struct-fc,structure>> field,
411 described at the <<dsc-frag,data stream class>> level in the metadata
412 stream, which contains, in any order:
413 ** {optional}: A field which contains the total size of{nbsp}{var-p},
414 in bits (always a multiple of 8).
415 ** {optional}: A field which contains the content size of{nbsp}{var-p},
416 in bits.
417 ** {optional}: A field which contains the beginning timestamp
418 of{nbsp}{var-p}.
419 ** {optional}: A field which contains the end timestamp of{nbsp}{var-p}.
420 ** {optional}: A field which contains a snapshot of the
421 <<disc-er-counter,discarded event record counter>> of{nbsp}{var-s} at
422 the end of{nbsp}{var-p}.
423 ** {optional}: A field which contains the sequence number
424 of{nbsp}{var-p} within{nbsp}{var-s}.
425 ** {optional}: User fields.
426
427 . Zero or more <<er,event records>>.
428
429 A packet {must} contain one or more bytes of data.
430
431 A packet {may} contain padding (garbage data) after its _last_ event
432 record. The size of this padding is the difference between its total
433 size and its content size (as found in its <<pkt-ctx,context structure
434 field>>).
435
436 Packets are independent of each other: if one removes a packet from a
437 data stream, a <<consumer-def,consumer>> can still decode the whole data
438 stream. This is why:
439
440 * Packets {may} contain _snapshots_ of the <<disc-er-counter,discarded
441 event record counter>> of their data stream.
442
443 * Packets and event records {may} contain _timestamps_ which are
444 snapshots of the <<def-clk,default clock>> of their data stream.
445
446 If the <<pkt-ctx,packet context>> fields of the packets of a data stream
447 contain a <<pkt-seq-num-role,packet sequence number>> field, a consumer
448 can recognize missing packets.
449
450 See <<pkt-dec>> to learn how to decode a {ctf2} packet.
451
452 [[er]]
453 ==== Event record
454
455 An _event record_ is the result of a <<producer-def,producer>> writing a
456 record with {optional} user data when an event occurs during its
457 execution.
458
459 A <<pkt,packet>> contains zero or more event records.
460
461 An <<erc-frag,event record class>> describes the specific parts of event
462 records.
463
464 An event record _**E**_, contained in a <<ds,data stream>>{nbsp}{var-s},
465 contains, in this order:
466
467 . [[er-header]] {optional}: A **header** <<struct-fc,structure>> field,
468 described at the <<dsc-frag,data stream class>> level in the metadata
469 stream, which contains, in any order:
470 ** {optional}: One or more fields which contain the numeric ID of the
471 <<erc-frag,class>> of{nbsp}__**E**__ which has the class
472 of{nbsp}{var-s} as its parent.
473 ** {optional}: One or more fields which contain a timestamp or a partial
474 timestamp.
475
476 . [[er-common-ctx]] {optional}: A **common context**
477 <<struct-fc,structure>> field, described at the data stream class
478 level in the metadata stream, which contains user fields.
479
480 . [[er-spec-ctx]] {optional}: A **specific context**
481 <<struct-fc,structure>> field, described at the event record class
482 level in the metadata stream, which contains user fields.
483
484 . [[er-payload]] {optional}: A **payload** <<struct-fc,structure>> field,
485 described at the event record class level in the metadata stream,
486 which contains user fields.
487
488 An event record {must} contain one or more bits of data.
489
490 The <<def-clk,default clock>> timestamp of an event record, that is, the
491 value of the default clock of its <<ds,data stream>> _after_ its
492 <<er-header,header field>>, if any, is encoded/decoded {must} be greater
493 than or equal to the default clock timestamp of the previous event
494 record, if any, within the _same_ data stream.
495
496 See <<er-dec>> to learn how to decode a {ctf2} event record.
497
498 [[aux-stream]]
499 === Auxiliary stream
500
501 An auxiliary stream is a JSON text sequence, as specified by {rfc-7464},
502 which contains extra, structured information about the trace which
503 doesn't fit the <<ds,data stream>> model.
504
505 Each element of an auxiliary stream is a JSON object which has a single
506 property:
507
508 [horizontal]
509 Name::
510 <<ns-def,Namespace>> of the auxiliary stream.
511
512 Value::
513 A JSON value.
514
515 .Auxiliary stream element with the `my.tracer` namespace.
516 ====
517 [source,json]
518 ----
519 {
520 "my.tracer": {
521 "version": [1, 3, 2],
522 "session-name": "amqui"
523 }
524 }
525 ----
526 ====
527
528 .Auxiliary stream element of which the value is just `42`.
529 ====
530 [source,json]
531 ----
532 {
533 "328c7a2d-a959-4f60-bd22-cca74359326f": 42
534 }
535 ----
536 ====
537
538 [[env]]
539 ==== Trace environment
540
541 To remain backward compatible with {ctf1}, a trace {may} contain an
542 auxiliary stream having an element with the `std` namespace which
543 contains trace environment variables under the `environment` property.
544
545 The trace environment variables are a single JSON object where each
546 property is:
547
548 [horizontal]
549 Name::
550 Trace environment variable name.
551
552 Value::
553 Trace environment variable value (any JSON value).
554
555 This document doesn't specify trace environment variable names.
556
557 .`std` auxiliary stream element with trace environment variables.
558 ====
559 [source,json]
560 ----
561 {
562 "std": {
563 "environment": {
564 "hostname": "amqui",
565 "domain": "kernel",
566 "sysname": "Linux",
567 "kernel_release": "4.12.12-1-ARCH",
568 "kernel_version": "#1 SMP PREEMPT Sun Sep 10 09:41:14 CEST 2017",
569 "tracer_name": "lttng-modules",
570 "tracer_major": 2,
571 "tracer_minor": 10,
572 "tracer_patchlevel": 0
573 }
574 }
575 }
576 ----
577 ====
578
579 [[metadata-stream]]
580 == Metadata stream
581
582 A metadata stream is a JSON text sequence, as specified by {rfc-7464},
583 of _fragments_.
584
585 Together, the fragments of a metadata stream contain all the information
586 about the <<ds,data streams>> of one or more <<trace,traces>>.
587
588 [[frag]] A _fragment_ is a JSON object; its allowed properties depend on
589 its `type` property.
590
591 .Common properties of a fragment {var-f}.
592 [%header%autowidth,cols="d,d,a,d,d"]
593 |===
594 |Name |Type |Description |Required? |Default
595
596 |`type`
597 |JSON string
598 |Type of{nbsp}{var-f}.
599
600 The value of this property {must} be one of:
601
602 `"preamble"`::
603 {var-f} is a <<preamble-frag,preamble fragment>>.
604
605 `"trace-class"`::
606 {var-f} is a <<tc-frag,trace class fragment>>.
607
608 `"clock-class"`::
609 {var-f} is a <<cc-frag,clock class fragment>>.
610
611 `"data-stream-class"`::
612 {var-f} is a <<dsc-frag,data stream class fragment>>.
613
614 `"event-record-class"`::
615 {var-f} is a <<erc-frag,event record class fragment>>.
616 |Yes
617 |
618
619 |`user-attributes`
620 |<<user-attrs,User attributes>>
621 |User attributes of{nbsp}{var-f}.
622 |No
623 |`+{}+`
624
625 |`extensions`
626 |<<ext,Extensions>>
627 |Extensions of{nbsp}{var-f}.
628
629 For any fragment except a <<preamble-frag,preamble fragment>>, any
630 extension which exists under this property {must} also be declared in
631 the preamble fragment of the same metadata stream.
632 |No
633 |`+{}+`
634 |===
635
636 The metadata stream is a JSON text sequence of fragments instead of a
637 single JSON object containing nested objects to enable real-time, or
638 "`live`", tracing: a <<consumer-def,consumer>> can always decode
639 <<er,event records>> having known <<erc-frag,event record classes>>
640 while a <<producer-def,producer>> can always add new event record
641 classes to a <<dsc-frag,data stream class>> by appending additional
642 fragments to the metadata stream. Once a producer appends a fragment to
643 a metadata stream, the fragment is considered "`frozen`", in that it
644 never needs to change.
645
646 A metadata stream:
647
648 * {must} start with a preamble fragment.
649 * {must} contain exactly one <<preamble-frag,preamble fragment>>.
650 * {may} contain one <<tc-frag,trace class fragment>>.
651 * {must} contain one or more <<dsc-frag,data stream class fragments>>
652 which {must} follow the trace class fragment, if any.
653 * {may} contain one or more <<er-frag,event record class fragments>>
654 which {must} follow their parent data stream class, if any.
655
656 .Partial metadata stream.
657 ====
658 In the sample below, the string `<RS>` represents a single record
659 separator character (U+001E) and the string `[pass:[...]]` represents
660 continuation.
661 ----
662 <RS>{
663 "type": "preamble",
664 "version": 2
665 }
666 <RS>[...]
667 ----
668 ====
669
670 [NOTE]
671 ====
672 This section doesn't specify how a metadata stream translates into
673 <<ds,data stream>> encoding and decoding rules; it only describes
674 objects and their properties.
675
676 See <<ds-dec>> to learn how to decode a data stream.
677 ====
678
679 [[uuid]]
680 === UUID
681
682 Both a <<tc-frag,trace class fragment>> and a <<cc-frag,clock class
683 fragment>> {may} have a
684 https://en.wikipedia.org/wiki/Universally_unique_identifier[_UUID_]
685 property.
686
687 Within a metadata stream, a UUID is a JSON array of 16{nbsp}JSON
688 integers which are the numeric values of the 16{nbsp}bytes of the
689 UUID.
690
691 .`e53e0ab8-50a1-4f0a-b710-b5f0bba9c4ac` UUID.
692 ====
693 [source,json]
694 ----
695 [229, 62, 10, 184, 80, 161, 79, 10, 183, 16, 181, 240, 187, 169, 196, 172]
696 ----
697 ====
698
699 [[ext]]
700 === Extensions
701
702 A <<producer-def,producer>> {may} add _extensions_ to many metadata
703 stream JSON objects.
704
705 The purpose of an extension is to add core features to {ctf2} or to
706 modify existing core features, as specified by this document. In other
707 words, an extension {may} **alter** the format itself.
708
709 This document doesn't specify what an extension exactly is.
710
711 The <<preamble-frag,preamble fragment>> of the metadata stream contains
712 _extension declarations_:
713
714 * Any extension in metadata stream objects {must} be declared, by
715 namespace and name, in the preamble fragment.
716 +
717 Declaring an extension is said to _enable_ it.
718
719 * If a <<consumer-def,consumer>> doesn't support _any_ declared
720 extension, it {must-not} consume the <<ds,data streams>> of the
721 <<trace,trace>>.
722 +
723 The consumer {should} report unsupported extensions as an error.
724
725 Extensions are a single JSON object, where each property is:
726
727 [horizontal]
728 Name::
729 A <<ns-def,namespace>>
730
731 Value::
732 A <<ns-exts-obj,namespaced extensions object>>
733
734 [[ns-exts-obj]] A _namespaced extensions object_ is a JSON object, where
735 each property is:
736
737 [horizontal]
738 Name::
739 An extension name
740
741 Value::
742 A JSON value
743
744 The metadata stream JSON objects which {may} contain extensions as their
745 `extensions` property are:
746
747 * Any <<frag,fragment>>.
748 +
749 An extension in the <<preamble-frag,preamble fragment>> also makes it
750 _declared_/_enabled_.
751
752 * Any <<fc,field class>>.
753
754 * A <<struct-member-cls,structure field member class>>.
755
756 * A <<var-fc-opt,variant field class option>>.
757
758 .Three extensions under two namespaces.
759 ====
760 [source,json]
761 ----
762 {
763 "my.tracer": {
764 "piano": {
765 "keys": 88,
766 "temperament": "equal"
767 },
768 "ramen": 23
769 },
770 "abc/xyz": {
771 "sax": {
772 "variant": "alto"
773 }
774 }
775 }
776 ----
777 ====
778
779 [[user-attrs]]
780 === User attributes
781
782 A <<producer-def,producer>> {may} add custom _user attributes_ to many
783 metadata stream JSON objects.
784
785 This document doesn't specify what a user attribute exactly is.
786
787 Unlike <<ext,extensions>>, a <<consumer-def,consumer>> {must-not}
788 consider user attributes to decode <<ds,data streams>>.
789
790 User attributes are a single JSON object, where each property is:
791
792 [horizontal]
793 Name::
794 A <<ns-def,namespace>>
795
796 Value::
797 A JSON value
798
799 The metadata stream JSON objects which {may} contain user attributes
800 as their `user-attributes` property are:
801
802 * Any <<frag,fragment>>.
803 * Any <<fc,field class>>.
804 * A <<struct-member-cls,structure field member class>>.
805 * A <<var-fc-opt,variant field class option>>.
806
807 .User attributes under two namespaces.
808 ====
809 [source,json]
810 ----
811 {
812 "my.tracer": {
813 "max-count": 45,
814 "module": "sys"
815 },
816 "abc/xyz": true
817 }
818 ----
819 ====
820
821 [[fc]]
822 === Field classes
823
824 A _field class_ describes fields, that is, <<seq-def,sequences>> of bits
825 as found in a <<ds,data stream>>.
826
827 A field class contains all the properties a <<consumer-def,consumer>>
828 needs to <<ds-dec,decode>> a given field.
829
830 A _field_ is a field class instance.
831
832 This document specifies the following types of field classes:
833
834 Abstract field classes::
835 One cannot use the following field classes directly: they are bases
836 for other, concrete field classes:
837 +
838 * <<int-fc,Abstract integer field class>>
839 * <<enum-fc,Abstract enumeration field class>>
840 * <<array-fc,Abstract array field class>>
841 * <<blob-fc,Abstract BLOB field class>>
842
843 Fixed/static-length field classes::
844 +
845 * {c-fl-ba-fc}
846 * {c-fl-bool-fc}
847 * {c-fl-int-fc}
848 * {c-fl-enum-fc}
849 * {c-fl-fp-fc}
850 * {c-sl-str-fc}
851 * {c-sl-blob-fc}
852
853 Variable/dynamic-length field classes::
854 +
855 * {c-vl-ba-fc}
856 * {c-vl-int-fc}
857 * {c-vl-enum-fc}
858 * {c-str-fc}
859 * {c-dl-str-fc}
860 * {c-dl-blob-fc}
861
862 Compound field classes::
863 The following field classes contain one or more field classes.
864 +
865 * {c-struct-fc}
866 * {c-sl-array-fc}
867 * {c-dl-array-fc}
868 * {c-opt-fc}
869 * {c-var-fc}
870
871 A field class is a JSON object; its properties depend on its `type`
872 property.
873
874 .Common properties of a field class {var-f}.
875 [%header%autowidth, cols="d,d,a,d,d"]
876 |===
877 |Name |Type |Description |Required? |Default
878
879 |`type`
880 |JSON string
881 |Type of{nbsp}{var-f}.
882
883 The value of this property {must} be one of:
884
885 `"fixed-length-bit-array"`::
886 {var-f} is a {fl-ba-fc}.
887
888 `"fixed-length-boolean"`::
889 {var-f} is a {fl-bool-fc}.
890
891 `"fixed-length-unsigned-integer"`::
892 `"fixed-length-signed-integer"`::
893 {var-f} is a {fl-int-fc}.
894
895 `"fixed-length-unsigned-enumeration"`::
896 `"fixed-length-signed-enumeration"`::
897 {var-f} is a {fl-enum-fc}.
898
899 `"fixed-length-floating-point-number"`::
900 {var-f} is a {fl-fp-fc}.
901
902 `"variable-length-bit-array"`::
903 {var-f} is a {vl-ba-fc}.
904
905 `"variable-length-unsigned-integer"`::
906 `"variable-length-signed-integer"`::
907 {var-f} is a {vl-int-fc}.
908
909 `"variable-length-unsigned-enumeration"`::
910 `"variable-length-signed-enumeration"`::
911 {var-f} is a {vl-enum-fc}.
912
913 `"null-terminated-string"`::
914 {var-f} is a {str-fc}.
915
916 `"static-length-string"`::
917 {var-f} is a {sl-str-fc}.
918
919 `"static-length-blob"`::
920 {var-f} is a {sl-blob-fc}.
921
922 `"dynamic-length-string"`::
923 {var-f} is a {dl-str-fc}.
924
925 `"dynamic-length-blob"`::
926 {var-f} is a {dl-blob-fc}.
927
928 `"structure"`::
929 {var-f} is a {struct-fc}.
930
931 `"static-length-array"`::
932 {var-f} is a {sl-array-fc}.
933
934 `"dynamic-length-array"`::
935 {var-f} is a {dl-array-fc}.
936
937 `"optional"`::
938 {var-f} is a {opt-fc}.
939
940 `"variant"`::
941 {var-f} is a {var-fc}.
942 |Yes
943 |
944
945 |`roles`
946 |<<roles,Roles>>
947 |Roles of an instance of{nbsp}{var-f}.
948
949 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
950 root field classes.
951 |No
952 |`+[]+`
953
954 |`user-attributes`
955 |<<user-attrs,User attributes>>
956 |User attributes of{nbsp}{var-f}.
957 |No
958 |`+{}+`
959
960 |`extensions`
961 |<<ext,Extensions>>
962 |Extensions of{nbsp}{var-f}.
963
964 Any extension which exists under this property {must} also be declared
965 in the <<preamble-frag,preamble fragment>> of the metadata stream.
966 |No
967 |`+{}+`
968 |===
969
970 The following <<frag,fragment>> properties {must} have a {struct-fc} as
971 their value:
972
973 <<tc-frag,Trace class fragment>>::
974 `packet-header-field-class`
975
976 <<dsc-frag,Data stream class fragment>>::
977 +
978 * `packet-context-field-class`
979 * `event-record-header-field-class`
980 * `event-record-common-context-field-class`
981
982 <<erc-frag,Event record class fragment>>::
983 +
984 * `specific-context-field-class`
985 * `payload-field-class`
986
987 [[field-loc]]
988 ==== Field location
989
990 A _field location_ is a means for a <<consumer-def,consumer>> to locate
991 a field which it needs to <<ds-dec,decode>> another, subsequent field.
992
993 A consumer needs to locate another field to decode instances of the
994 following <<fc,classes>>:
995
996 {c-dl-array-fc}::
997 {c-dl-str-fc}::
998 {c-dl-blob-fc}::
999 Needs a <<fl-int-fc,{fl-uint}>> or
1000 <<vl-int-fc,{vl-uint}>> length field.
1001
1002 {c-opt-fc}::
1003 Needs a <<fl-bool-fc,{fl-bool}>>, <<fl-int-fc,{fl-int}>>, or
1004 <<vl-int-fc,{vl-int}>> selector field.
1005
1006 {c-var-fc}::
1007 Needs a <<fl-int-fc,{fl-int}>> or <<vl-int-fc,{vl-int}>> selector
1008 field.
1009
1010 Let _**T**_ be an anteriorly decoded field which a consumer needs to
1011 decode another field{nbsp}{var-s}. A field location is a JSON array
1012 where, in this order:
1013
1014 . The first element is the name (JSON string) of a root field from
1015 where to start the lookup of{nbsp}__**T**__, amongst:
1016 +
1017 --
1018 [horizontal]
1019 `"packet-header"`::
1020 <<pkt-header,Header>> of the <<pkt,packet>> of{nbsp}{var-s}.
1021 `"packet-context"`::
1022 <<pkt-ctx,Context>> of the packet of{nbsp}{var-s}.
1023 `"event-record-header"`::
1024 <<er-header,Header>> of the <<er,event record>> of{nbsp}{var-s}.
1025 `"event-record-common-context"`::
1026 <<er-common-ctx,Common context>> of the event record of{nbsp}{var-s}.
1027 `"event-record-specific-context"`::
1028 <<er-spec-ctx,Specific context>> of the event record of{nbsp}{var-s}.
1029 `"event-record-payload"`::
1030 <<er-payload,Payload>> of the event record of{nbsp}{var-s}.
1031 --
1032 +
1033 In other words, __**T**__ {must} be in the same packet or event record
1034 as{nbsp}{var-s}.
1035
1036 . The following elements are <<struct-fc,structure>> field member names
1037 (JSON strings) to follow to locate the target field.
1038
1039 The length of a field location {must} be greater than or equal to two.
1040
1041 See <<field-loc-dec>> to learn how to locate a field with a field
1042 location.
1043
1044 [[int-range-set]]
1045 ==== Integer range set
1046
1047 An _integer range set_ is a JSON array of integer ranges.
1048
1049 An integer range set {must} contain one or more integer ranges.
1050
1051 An _integer range_ is a JSON array of two elements:
1052
1053 . The lower bound of the range (JSON integer, included).
1054 . The upper bound of the range (JSON integer, included).
1055
1056 An integer range represents all the integer values from the lower bound
1057 of the range to its upper bound.
1058
1059 The upper bound of an integer range {must} be greater than or equal to
1060 its lower bound.
1061
1062 If both the lower and upper bounds of an integer range are equal, then
1063 the integer range represents a single integer value.
1064
1065 .Integer ranges.
1066 ====
1067 [source,json]
1068 ----
1069 [3, 67]
1070 ----
1071
1072 [source,json]
1073 ----
1074 [-45, 101]
1075 ----
1076
1077 .Single integer value.
1078 [source,json]
1079 ----
1080 [42, 42]
1081 ----
1082 ====
1083
1084 .Integer range set containing three integer ranges.
1085 ====
1086 [source,json]
1087 ----
1088 [[3, 67], [-45, 1], [42, 42]]
1089 ----
1090 ====
1091
1092 [[roles]]
1093 ==== Roles
1094
1095 Some <<fc,field class>> instances can have _roles_.
1096
1097 A role is specific semantics attached to the fields (instances) of a
1098 field class. For example, the `packet-magic-number` role of a
1099 {fl-int-fc} indicates that the value of its instances {must} be the
1100 <<pkt,packet>> magic number (0xc1fc1fc1).
1101
1102 Roles are a JSON array of role names (JSON strings).
1103
1104 See <<tc-frag>> and <<dsc-frag>> which indicate accepted roles within
1105 their root field classes.
1106
1107 [[fl-ba-fc]]
1108 ==== {c-fl-ba} field class
1109
1110 A _{fl-ba}_ field class describes _{fl-ba}_ fields.
1111
1112 A {fl-ba} field is a simple array of contiguous bits, without any
1113 attached integer type semantics.
1114
1115 The length, or number of bits, of a {fl-ba} field is a property
1116 (`length`) of its class.
1117
1118 A {fl-ba} field class acts as a base of a {fl-bool-fc}, a {fl-int-fc},
1119 and a {fl-fp-fc}.
1120
1121 .Common properties of a {fl-ba} field class {var-f}.
1122 [%header%autowidth, cols="d,d,a,d,d"]
1123 |===
1124 |Name |Type |Description |Required? |Default
1125
1126 |`type`
1127 |JSON string
1128 |Type of{nbsp}{var-f}.
1129
1130 The value of this property {must} be `"fixed-length-bit-array"`.
1131 |Yes
1132 |
1133
1134 |`length`
1135 |JSON integer
1136 |Number of bits of an instance of{nbsp}{var-f}.
1137
1138 The value of this property {must} be greater than zero.
1139 |Yes
1140 |
1141
1142 |`byte-order`
1143 |JSON string
1144 |{c-bo} of an instance of{nbsp}{var-f}.
1145
1146 The value of this property {must} be one of:
1147
1148 `"big-endian"`::
1149 Big-endian.
1150
1151 `"little-endian"`::
1152 Little-endian.
1153 |Yes
1154 |
1155
1156 |`alignment`
1157 |JSON integer
1158 |Alignment of the first bit of an instance of{nbsp}{var-f}
1159 relative to the beginning of the <<pkt,packet>> which
1160 contains this instance.
1161
1162 The value of this property {must} be a positive power of two.
1163 |No
1164 |`1`
1165
1166 |`roles`
1167 |<<roles,Roles>>
1168 |Roles of an instance of{nbsp}{var-f}.
1169
1170 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
1171 root field classes.
1172 |No
1173 |`+[]+`
1174
1175 |`user-attributes`
1176 |<<user-attrs,User attributes>>
1177 |User attributes of{nbsp}{var-f}.
1178 |No
1179 |`+{}+`
1180
1181 |`extensions`
1182 |<<ext,Extensions>>
1183 |Extensions of{nbsp}{var-f}.
1184
1185 Any extension which exists under this property {must} also be declared
1186 in the <<preamble-frag,preamble fragment>> of the metadata stream.
1187 |No
1188 |`+{}+`
1189 |===
1190
1191 .Minimal {fl-ba} field class.
1192 ====
1193 [source,json]
1194 ----
1195 {
1196 "type": "fixed-length-bit-array",
1197 "length": 16,
1198 "byte-order": "little-endian"
1199 }
1200 ----
1201 ====
1202
1203 .{c-fl-ba} field class with instances aligned to 32{nbsp}bits.
1204 ====
1205 [source,json]
1206 ----
1207 {
1208 "type": "fixed-length-bit-array",
1209 "length": 48,
1210 "byte-order": "big-endian",
1211 "alignment": 32
1212 }
1213 ----
1214 ====
1215
1216 .{c-fl-ba} field class with <<user-attrs,user attributes>>.
1217 ====
1218 [source,json]
1219 ----
1220 {
1221 "type": "fixed-length-bit-array",
1222 "length": 16,
1223 "byte-order": "little-endian",
1224 "user-attributes": {
1225 "my.tracer": {
1226 "is-nice": true
1227 }
1228 }
1229 }
1230 ----
1231 ====
1232
1233 [[fl-bool-fc]]
1234 ==== {c-fl-bool} field class
1235
1236 A _{fl-bool}_ field class is a {fl-ba-fc} which describes _{fl-bool}_
1237 fields.
1238
1239 A {fl-bool} field is a {fl-ba} field which has the following semantics:
1240
1241 If all the bits of the bit array field are cleared (zero)::
1242 The value of the {fl-bool} field is _false_.
1243
1244 Otherwise::
1245 The value of the {fl-bool} field is _true_.
1246
1247 .Properties of a {fl-bool} field class {var-f}.
1248 [%header%autowidth, cols="d,d,a,d,d"]
1249 |===
1250 |Name |Type |Description |Required? |Default
1251
1252 |`type`
1253 |JSON string
1254 |Type of{nbsp}{var-f}.
1255
1256 The value of this property {must} be `"fixed-length-boolean"`.
1257 |Yes
1258 |
1259
1260 |`length`
1261 |JSON integer
1262 |Number of bits of an instance of{nbsp}{var-f}.
1263
1264 The value of this property {must} be greater than zero.
1265
1266 Property inherited from the {fl-ba-fc}.
1267 |Yes
1268 |
1269
1270 |`byte-order`
1271 |JSON string
1272 |{c-bo} of an instance
1273 of{nbsp}{var-f}.
1274
1275 The value of this property {must} be one of:
1276
1277 `"big-endian"`::
1278 Big-endian.
1279
1280 `"little-endian"`::
1281 Little-endian.
1282
1283 Property inherited from the {fl-ba-fc}.
1284 |Yes
1285 |
1286
1287 |`alignment`
1288 |JSON integer
1289 |Alignment of the first bit of an instance of{nbsp}{var-f}
1290 relative to the beginning of the <<pkt,packet>> which
1291 contains this instance.
1292
1293 The value of this property {must} be a positive power of two.
1294
1295 Property inherited from the {fl-ba-fc}.
1296 |No
1297 |`1`
1298
1299 |`roles`
1300 |<<roles,Roles>>
1301 |Roles of an instance of{nbsp}{var-f}.
1302
1303 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
1304 root field classes.
1305 |No
1306 |`+[]+`
1307
1308 |`user-attributes`
1309 |<<user-attrs,User attributes>>
1310 |User attributes of{nbsp}{var-f}.
1311 |No
1312 |`+{}+`
1313
1314 |`extensions`
1315 |<<ext,Extensions>>
1316 |Extensions of{nbsp}{var-f}.
1317
1318 Any extension which exists under this property {must} also be declared
1319 in the <<preamble-frag,preamble fragment>> of the metadata stream.
1320 |No
1321 |`+{}+`
1322 |===
1323
1324 .Minimal {fl-bool} field class.
1325 ====
1326 [source,json]
1327 ----
1328 {
1329 "type": "fixed-length-boolean",
1330 "length": 16,
1331 "byte-order": "little-endian"
1332 }
1333 ----
1334 ====
1335
1336 .{c-fl-bool} field class with instances aligned to 32{nbsp}bits.
1337 ====
1338 [source,json]
1339 ----
1340 {
1341 "type": "fixed-length-boolean",
1342 "length": 48,
1343 "byte-order": "big-endian",
1344 "alignment": 32
1345 }
1346 ----
1347 ====
1348
1349 .{c-fl-bool} field class with <<user-attrs,user attributes>>.
1350 ====
1351 [source,json]
1352 ----
1353 {
1354 "type": "fixed-length-boolean",
1355 "length": 16,
1356 "byte-order": "little-endian",
1357 "user-attributes": {
1358 "my.tracer": {
1359 "is-nice": true
1360 }
1361 }
1362 }
1363 ----
1364 ====
1365
1366 [[int-fc]]
1367 ==== Abstract integer field class
1368
1369 An _abstract integer_ field class is a base of a {fl-int-fc} and a
1370 {vl-int-fc}.
1371
1372 This field class is abstract in that it only exists to show the relation
1373 between different integer field classes in this document: a
1374 <<pkt,packet>> cannot contain an abstract integer field.
1375
1376 .Common property of an integer field class {var-f}.
1377 [%header%autowidth, cols="d,d,a,d,d"]
1378 |===
1379 |Name |Type |Description |Required? |Default
1380
1381 |`preferred-display-base`
1382 |JSON integer
1383 |Preferred base to display the value of an instance of{nbsp}{var-f}.
1384
1385 The value of this property {must} be one of:
1386
1387 [horizontal]
1388 `2`::
1389 Binary base.
1390
1391 `8`::
1392 Octal base.
1393
1394 `10`::
1395 Decimal base.
1396
1397 `16`::
1398 Hexadecimal base.
1399
1400 This property exists to remain backward compatible with {ctf1}:
1401 it's not strictly needed to decode an instance of{nbsp}{var-f}.
1402 |No
1403 |`10`
1404 |===
1405
1406 [[fl-int-fc]]
1407 ==== {c-fl-int} field class
1408
1409 A _{fl-int}_ field class is both an <<int-fc,abstract integer field
1410 class>> and a {fl-ba-fc} which describes _{fl-int}_ fields.
1411
1412 A {fl-int} field is a {fl-ba} field which has integer semantics.
1413
1414 If the value of the `type` property of a {fl-int} is
1415 `"fixed-length-signed-integer"`, then its instances have the two's
1416 complement format.
1417
1418 A {fl-int} field class acts as a base of a {fl-enum-fc}.
1419
1420 .Common properties of a {fl-int} field class {var-f}.
1421 [%header%autowidth, cols="d,d,a,d,d"]
1422 |===
1423 |Name |Type |Description |Required? |Default
1424
1425 |`type`
1426 |JSON string
1427 |Type of{nbsp}{var-f}.
1428
1429 The value of this property {must} be one of:
1430
1431 `"fixed-length-unsigned-integer"`::
1432 The instances of{nbsp}{var-f} are {fl-uint} fields.
1433
1434 `"fixed-length-signed-integer"`::
1435 The instances of{nbsp}{var-f} are {fl-sint} fields.
1436 |Yes
1437 |
1438
1439 |`length`
1440 |JSON integer
1441 |Number of bits of an instance of{nbsp}{var-f}.
1442
1443 The value of this property {must} be greater than zero.
1444
1445 Property inherited from the {fl-ba-fc}.
1446 |Yes
1447 |
1448
1449 |`byte-order`
1450 |JSON string
1451 |{c-bo} of an instance
1452 of{nbsp}{var-f}.
1453
1454 The value of this property {must} be one of:
1455
1456 `"big-endian"`::
1457 Big-endian.
1458
1459 `"little-endian"`::
1460 Little-endian.
1461
1462 Property inherited from the {fl-ba-fc}.
1463 |Yes
1464 |
1465
1466 |`alignment`
1467 |JSON integer
1468 |Alignment of the first bit of an instance of{nbsp}{var-f}
1469 relative to the beginning of the <<pkt,packet>> which
1470 contains this instance.
1471
1472 The value of this property {must} be a positive power of two.
1473
1474 Property inherited from the {fl-ba-fc}.
1475 |No
1476 |`1`
1477
1478 |`preferred-display-base`
1479 |JSON integer
1480 |Preferred base to display the value of an instance of{nbsp}{var-f}.
1481
1482 The value of this property {must} be one of:
1483
1484 [horizontal]
1485 `2`::
1486 Binary base.
1487
1488 `8`::
1489 Octal base.
1490
1491 `10`::
1492 Decimal base.
1493
1494 `16`::
1495 Hexadecimal base.
1496
1497 This property exists to remain backward compatible with {ctf1}:
1498 it's not strictly needed to decode an instance of{nbsp}{var-f}.
1499
1500 Property inherited from the <<int-fc,abstract integer field class>>.
1501 |No
1502 |`10`
1503
1504 |`roles`
1505 |<<roles,Roles>>
1506 |Roles of an instance of{nbsp}{var-f}.
1507
1508 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
1509 root field classes.
1510 |No
1511 |`+[]+`
1512
1513 |`user-attributes`
1514 |<<user-attrs,User attributes>>
1515 |User attributes of{nbsp}{var-f}.
1516 |No
1517 |`+{}+`
1518
1519 |`extensions`
1520 |<<ext,Extensions>>
1521 |Extensions of{nbsp}{var-f}.
1522
1523 Any extension which exists under this property {must} also be declared
1524 in the <<preamble-frag,preamble fragment>> of the metadata stream.
1525 |No
1526 |`+{}+`
1527 |===
1528
1529 .Minimal {fl-uint} field class.
1530 ====
1531 [source,json]
1532 ----
1533 {
1534 "type": "fixed-length-unsigned-integer",
1535 "length": 16,
1536 "byte-order": "little-endian"
1537 }
1538 ----
1539 ====
1540
1541 .{c-fl-sint} field class with instances aligned to 32{nbsp}bits.
1542 ====
1543 [source,json]
1544 ----
1545 {
1546 "type": "fixed-length-signed-integer",
1547 "length": 48,
1548 "byte-order": "big-endian",
1549 "alignment": 32
1550 }
1551 ----
1552 ====
1553
1554 .{c-fl-uint} field class with instances to be preferably displayed with a hexadecimal base.
1555 ====
1556 [source,json]
1557 ----
1558 {
1559 "type": "fixed-length-unsigned-integer",
1560 "length": 48,
1561 "byte-order": "big-endian",
1562 "preferred-display-base": 16
1563 }
1564 ----
1565 ====
1566
1567 .{c-fl-sint} field class with <<user-attrs,user attributes>>.
1568 ====
1569 [source,json]
1570 ----
1571 {
1572 "type": "fixed-length-signed-integer",
1573 "length": 16,
1574 "byte-order": "little-endian",
1575 "user-attributes": {
1576 "my.tracer": {
1577 "is-nice": true
1578 }
1579 }
1580 }
1581 ----
1582 ====
1583
1584 [[enum-fc]]
1585 ==== Abstract enumeration field class
1586
1587 An _abstract enumeration_ field class is a base of a {fl-enum-fc} and a
1588 {vl-enum-fc}.
1589
1590 This field class is abstract in that it only exists to show the relation
1591 between different enumeration field classes in this document: a
1592 <<pkt,packet>> cannot contain an abstract enumeration field.
1593
1594 An abstract enumeration field class is an <<int-fc,abstract integer
1595 field class>>.
1596
1597 An enumeration field is an integer field which {may} have one or more
1598 associated names thanks to the `mappings` property of its class.
1599
1600 .Common property of an enumeration field class {var-f}.
1601 [%header%autowidth, cols="d,d,a,d,d"]
1602 |===
1603 |Name |Type |Description |Required? |Default
1604
1605 |`preferred-display-base`
1606 |JSON integer
1607 |Preferred base to display the value of an instance of{nbsp}{var-f}.
1608
1609 The value of this property {must} be one of:
1610
1611 [horizontal]
1612 `2`::
1613 Binary base.
1614
1615 `8`::
1616 Octal base.
1617
1618 `10`::
1619 Decimal base.
1620
1621 `16`::
1622 Hexadecimal base.
1623
1624 This property exists to remain backward compatible with {ctf1}:
1625 it's not strictly needed to decode an instance of{nbsp}{var-f}.
1626
1627 Property inherited from the <<int-fc,abstract integer field class>>.
1628 |No
1629 |`10`
1630
1631 |`mappings`
1632 |<<enum-fc-mappings,Enumeration field class mappings>>
1633 |Mappings of{nbsp}{var-f}.
1634
1635 The value of this property {must} contain one or more properties.
1636 |Yes
1637 |
1638 |===
1639
1640 [[enum-fc-mappings]]
1641 ===== Enumeration field class mappings
1642
1643 _Enumeration field class mappings_ map names to
1644 <<int-range-set,integer range sets>>.
1645
1646 Enumeration field class mappings are a JSON object, where each property
1647 is:
1648
1649 [horizontal]
1650 Name::
1651 Mapping name.
1652
1653 Value::
1654 Mapped ranges of integers (<<int-range-set,integer range set>>).
1655
1656 The integer ranges of two given mappings {may} overlap.
1657
1658 Enumeration field class mappings {must} contain one or more properties.
1659
1660 .Enumeration field class mappings with three mappings.
1661 ====
1662 In this example, the `fortune` and `building` mappings overlap with the
1663 values 4 and 5, and the `building` and `journal` mappings overlap with
1664 the value 80.
1665
1666 [source,json]
1667 ----
1668 {
1669 "fortune": [[3, 67], [-45, 1], [84, 84]],
1670 "building": [[4, 5], [75, 82]],
1671 "journal": [[100, 2305], [80, 80]]
1672 }
1673 ----
1674 ====
1675
1676 [[fl-enum-fc]]
1677 ==== {c-fl-enum} field class
1678
1679 A _{fl-enum}_ field class is both an <<enum-fc,abstract enumeration
1680 field class>> and a {fl-int-fc} which describes _{fl-enum}_ fields.
1681
1682 A {fl-enum} field is a {fl-int} field which {may} have one or more
1683 associated names thanks to the `mappings` property of its class.
1684
1685 If the value of the `type` property of a {fl-enum} field class is
1686 `"fixed-length-signed-enumeration"`, then its instances have the two's
1687 complement format.
1688
1689 .Properties of a {fl-enum} field class {var-f}.
1690 [%header%autowidth, cols="d,d,a,d,d"]
1691 |===
1692 |Name |Type |Description |Required? |Default
1693
1694 |`type`
1695 |JSON string
1696 |Type of{nbsp}{var-f}.
1697
1698 The value of this property {must} be one of:
1699
1700 `"fixed-length-unsigned-enumeration"`::
1701 The instances of{nbsp}{var-f} are {fl-uenum} fields.
1702
1703 `"fixed-length-signed-enumeration"`::
1704 The instances of{nbsp}{var-f} are {fl-senum} fields.
1705 |Yes
1706 |
1707
1708 |`length`
1709 |JSON integer
1710 |Number of bits of an instance of{nbsp}{var-f}.
1711
1712 The value of this property {must} be greater than zero.
1713
1714 Property inherited from the {fl-ba-fc}.
1715 |Yes
1716 |
1717
1718 |`byte-order`
1719 |JSON string
1720 |{c-bo} of an instance
1721 of{nbsp}{var-f}.
1722
1723 The value of this property {must} be one of:
1724
1725 `"big-endian"`::
1726 Big-endian.
1727
1728 `"little-endian"`::
1729 Little-endian.
1730
1731 Property inherited from the {fl-ba-fc}.
1732 |Yes
1733 |
1734
1735 |`alignment`
1736 |JSON integer
1737 |Alignment of the first bit of an instance of{nbsp}{var-f}
1738 relative to the beginning of the <<pkt,packet>> which
1739 contains this instance.
1740
1741 The value of this property {must} be a positive power of two.
1742
1743 Property inherited from the {fl-ba-fc}.
1744 |No
1745 |`1`
1746
1747 |`preferred-display-base`
1748 |JSON integer
1749 |Preferred base to display the value of an instance of{nbsp}{var-f}.
1750
1751 The value of this property {must} be one of:
1752
1753 [horizontal]
1754 `2`::
1755 Binary base.
1756
1757 `8`::
1758 Octal base.
1759
1760 `10`::
1761 Decimal base.
1762
1763 `16`::
1764 Hexadecimal base.
1765
1766 This property exists to remain backward compatible with {ctf1}:
1767 it's not strictly needed to decode an instance of{nbsp}{var-f}.
1768
1769 Property inherited from the <<int-fc,abstract integer field class>>.
1770 |No
1771 |`10`
1772
1773 |`mappings`
1774 |<<enum-fc-mappings,Enumeration field class mappings>>
1775 |Mappings of{nbsp}{var-f}.
1776
1777 The value of this property {must} contain one or more properties.
1778
1779 Property inherited from the <<enum-fc,abstract enumeration field class>>.
1780 |Yes
1781 |
1782
1783 |`roles`
1784 |<<roles,Roles>>
1785 |Roles of an instance of{nbsp}{var-f}.
1786
1787 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
1788 root field classes.
1789 |No
1790 |`+[]+`
1791
1792 |`user-attributes`
1793 |<<user-attrs,User attributes>>
1794 |User attributes of{nbsp}{var-f}.
1795 |No
1796 |`+{}+`
1797
1798 |`extensions`
1799 |<<ext,Extensions>>
1800 |Extensions of{nbsp}{var-f}.
1801
1802 Any extension which exists under this property {must} also be declared
1803 in the <<preamble-frag,preamble fragment>> of the metadata stream.
1804 |No
1805 |`+{}+`
1806 |===
1807
1808 .Minimal {fl-uenum} field class.
1809 ====
1810 [source,json]
1811 ----
1812 {
1813 "type": "fixed-length-unsigned-enumeration",
1814 "length": 16,
1815 "byte-order": "little-endian",
1816 "mappings": {
1817 "apple": [[1, 19]]
1818 }
1819 }
1820 ----
1821 ====
1822
1823 .{c-fl-senum} field class with instances aligned to 32{nbsp}bits.
1824 ====
1825 [source,json]
1826 ----
1827 {
1828 "type": "fixed-length-signed-enumeration",
1829 "length": 48,
1830 "byte-order": "big-endian",
1831 "alignment": 32,
1832 "mappings": {
1833 "banana": [[-27399, -1882], [8, 199], [101, 101]],
1834 "orange": [[67, 67], [43, 1534]]
1835 }
1836 }
1837 ----
1838 ====
1839
1840 .{c-fl-uenum} field class with instances to be preferably displayed with a hexadecimal base.
1841 ====
1842 [source,json]
1843 ----
1844 {
1845 "type": "fixed-length-unsigned-enumeration",
1846 "length": 8,
1847 "byte-order": "big-endian",
1848 "preferred-display-base": 16,
1849 "mappings": {
1850 "lime": [[3, 3]],
1851 "kiwi": [[8, 8]],
1852 "blueberry": [[11, 11]]
1853 }
1854 }
1855 ----
1856 ====
1857
1858 .{c-fl-senum} field class with <<user-attrs,user attributes>>.
1859 ====
1860 [source,json]
1861 ----
1862 {
1863 "type": "fixed-length-signed-enumeration",
1864 "length": 16,
1865 "byte-order": "little-endian",
1866 "mappings": {
1867 "mango": [[23, 42]]
1868 },
1869 "user-attributes": {
1870 "my.tracer": {
1871 "is-nice": true
1872 }
1873 }
1874 }
1875 ----
1876 ====
1877
1878 [[fl-fp-fc]]
1879 ==== {c-fl-fp} field class
1880
1881 A _{fl-fp}_ field class is a {fl-ba-fc} which describes _{fl-fp}_
1882 fields.
1883
1884 A {fl-fp} field is a {fl-ba} field which has floating point number
1885 semantics.
1886
1887 .Properties of a {fl-fp} field class {var-f}.
1888 [%header%autowidth, cols="d,d,a,d,d"]
1889 |===
1890 |Name |Type |Description |Required? |Default
1891
1892 |`type`
1893 |JSON string
1894 |Type of{nbsp}{var-f}.
1895
1896 The value of this property {must} be
1897 `"fixed-length-floating-point-number"`.
1898 |Yes
1899 |
1900
1901 |`length`
1902 |JSON integer
1903 |Number of bits of an instance of{nbsp}{var-f}.
1904
1905 The value of this property {must} be one of:
1906
1907 `16`::
1908 The instances of{nbsp}{var-f} are binary16 floating point numbers,
1909 as per the {ieee754}.
1910
1911 `32`::
1912 The instances of{nbsp}{var-f} are binary32 floating point numbers.
1913
1914 `64`::
1915 The instances of{nbsp}{var-f} are binary64 floating point numbers.
1916
1917 `128`::
1918 The instances of{nbsp}{var-f} are binary128 floating point
1919 numbers.
1920
1921 _**K**_, where _**K**_ is greater than{nbsp}128 and a multiple of{nbsp}32::
1922 The instances of{nbsp}{var-f} are binary__**K**__ floating point
1923 numbers.
1924
1925 Property inherited from the {fl-ba-fc}.
1926 |Yes
1927 |
1928
1929 |`byte-order`
1930 |JSON string
1931 |{c-bo} of an instance
1932 of{nbsp}{var-f}.
1933
1934 The value of this property {must} be one of:
1935
1936 `"big-endian"`::
1937 Big-endian.
1938
1939 `"little-endian"`::
1940 Little-endian.
1941
1942 Property inherited from the {fl-ba-fc}.
1943 |Yes
1944 |
1945
1946 |`alignment`
1947 |JSON integer
1948 |Alignment of the first bit of an instance of{nbsp}{var-f}
1949 relative to the beginning of the <<pkt,packet>> which
1950 contains this instance.
1951
1952 The value of this property {must} be a positive power of two.
1953
1954 Property inherited from the {fl-ba-fc}.
1955 |No
1956 |`1`
1957
1958 |`roles`
1959 |<<roles,Roles>>
1960 |Roles of an instance of{nbsp}{var-f}.
1961
1962 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
1963 root field classes.
1964 |No
1965 |`+[]+`
1966
1967 |`user-attributes`
1968 |<<user-attrs,User attributes>>
1969 |User attributes of{nbsp}{var-f}.
1970 |No
1971 |`+{}+`
1972
1973 |`extensions`
1974 |<<ext,Extensions>>
1975 |Extensions of{nbsp}{var-f}.
1976
1977 Any extension which exists under this property {must} also be declared
1978 in the <<preamble-frag,preamble fragment>> of the metadata stream.
1979 |No
1980 |`+{}+`
1981 |===
1982
1983 .Minimal binary32 {fl-fp} field class.
1984 ====
1985 [source,json]
1986 ----
1987 {
1988 "type": "fixed-length-floating-point-number",
1989 "length": 32,
1990 "byte-order": "little-endian"
1991 }
1992 ----
1993 ====
1994
1995 .binary64 {fl-fp} field class with instances aligned to 32{nbsp}bits.
1996 ====
1997 [source,json]
1998 ----
1999 {
2000 "type": "fixed-length-floating-point-number",
2001 "length": 64,
2002 "byte-order": "big-endian",
2003 "alignment": 32
2004 }
2005 ----
2006 ====
2007
2008 .binary192 {fl-fp} field class with <<user-attrs,user attributes>>.
2009 ====
2010 [source,json]
2011 ----
2012 {
2013 "type": "fixed-length-floating-point-number",
2014 "length": 192,
2015 "byte-order": "little-endian",
2016 "user-attributes": {
2017 "my.tracer": {
2018 "is-nice": true
2019 }
2020 }
2021 }
2022 ----
2023 ====
2024
2025 [[vl-ba-fc]]
2026 ==== {c-vl-ba} field class
2027
2028 A _{vl-ba}_ field class describes _{vl-ba}_ fields.
2029
2030 A {vl-ba} field is a <<seq-def,sequence>> of bytes with a variable
2031 length which contains an array of bits of which the length is a multiple
2032 of{nbsp}7. A {vl-ba} field is encoded as per
2033 https://en.wikipedia.org/wiki/LEB128[LEB128].
2034
2035 A {vl-ba} field class acts as a base of a {vl-int-fc}.
2036
2037 .Common properties of a {vl-ba} field class {var-f}.
2038 [%header%autowidth, cols="d,d,a,d,d"]
2039 |===
2040 |Name |Type |Description |Required? |Default
2041
2042 |`type`
2043 |JSON string
2044 |Type of{nbsp}{var-f}.
2045
2046 The value of this property {must} be `"variable-length-bit-array"`.
2047 |Yes
2048 |
2049
2050 |`roles`
2051 |<<roles,Roles>>
2052 |Roles of an instance of{nbsp}{var-f}.
2053
2054 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2055 root field classes.
2056 |No
2057 |`+[]+`
2058
2059 |`user-attributes`
2060 |<<user-attrs,User attributes>>
2061 |User attributes of{nbsp}{var-f}.
2062 |No
2063 |`+{}+`
2064
2065 |`extensions`
2066 |<<ext,Extensions>>
2067 |Extensions of{nbsp}{var-f}.
2068
2069 Any extension which exists under this property {must} also be declared
2070 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2071 |No
2072 |`+{}+`
2073 |===
2074
2075 .Minimal {vl-ba} field class.
2076 ====
2077 [source,json]
2078 ----
2079 {
2080 "type": "variable-length-bit-array"
2081 }
2082 ----
2083 ====
2084
2085 .{c-vl-ba} field class with <<user-attrs,user attributes>>.
2086 ====
2087 [source,json]
2088 ----
2089 {
2090 "type": "variable-length-bit-array",
2091 "user-attributes": {
2092 "my.tracer": {
2093 "is-nice": true
2094 }
2095 }
2096 }
2097 ----
2098 ====
2099
2100 [[vl-int-fc]]
2101 ==== {c-vl-int} field class
2102
2103 A _{vl-int}_ field class is both an <<int-fc,abstract integer field
2104 class>> and a {vl-ba-fc} which describes _{vl-int}_ fields.
2105
2106 A {vl-int} field is a {vl-ba} field which has integer semantics.
2107
2108 If the value of the `type` property of a {vl-int} field class is
2109 `"variable-length-signed-integer"`, then its instances have the two's
2110 complement format.
2111
2112 A {vl-int} field class acts as a base of a {vl-enum-fc}.
2113
2114 .Common properties of a {vl-int} field class {var-f}.
2115 [%header%autowidth, cols="d,d,a,d,d"]
2116 |===
2117 |Name |Type |Description |Required? |Default
2118
2119 |`type`
2120 |JSON string
2121 |Type of{nbsp}{var-f}.
2122
2123 The value of this property {must} be one of:
2124
2125 `"variable-length-unsigned-integer"`::
2126 The instances of{nbsp}{var-f} are {vl-uint} fields.
2127
2128 `"variable-length-signed-integer"`::
2129 The instances of{nbsp}{var-f} are {vl-sint} fields.
2130 |Yes
2131 |
2132
2133 |`preferred-display-base`
2134 |JSON integer
2135 |Preferred base to display the value of an instance of{nbsp}{var-f}.
2136
2137 The value of this property {must} be one of:
2138
2139 [horizontal]
2140 `2`::
2141 Binary base.
2142
2143 `8`::
2144 Octal base.
2145
2146 `10`::
2147 Decimal base.
2148
2149 `16`::
2150 Hexadecimal base.
2151
2152 This property exists to remain backward compatible with {ctf1}:
2153 it's not strictly needed to decode an instance of{nbsp}{var-f}.
2154
2155 Property inherited from the <<int-fc,abstract integer field class>>.
2156 |No
2157 |`10`
2158
2159 |`roles`
2160 |<<roles,Roles>>
2161 |Roles of an instance of{nbsp}{var-f}.
2162
2163 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2164 root field classes.
2165 |No
2166 |`+[]+`
2167
2168 |`user-attributes`
2169 |<<user-attrs,User attributes>>
2170 |User attributes of{nbsp}{var-f}.
2171 |No
2172 |`+{}+`
2173
2174 |`extensions`
2175 |<<ext,Extensions>>
2176 |Extensions of{nbsp}{var-f}.
2177
2178 Any extension which exists under this property {must} also be declared
2179 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2180 |No
2181 |`+{}+`
2182 |===
2183
2184 .Minimal {vl-uint} field class.
2185 ====
2186 [source,json]
2187 ----
2188 {
2189 "type": "variable-length-unsigned-integer"
2190 }
2191 ----
2192 ====
2193
2194 .{c-vl-sint} field class with instances to be preferably displayed with a hexadecimal base.
2195 ====
2196 [source,json]
2197 ----
2198 {
2199 "type": "variable-length-signed-integer",
2200 "preferred-display-base": 16
2201 }
2202 ----
2203 ====
2204
2205 .{c-vl-uint} field class with <<user-attrs,user attributes>>.
2206 ====
2207 [source,json]
2208 ----
2209 {
2210 "type": "variable-length-unsigned-integer",
2211 "user-attributes": {
2212 "my.tracer": {
2213 "is-nice": true
2214 }
2215 }
2216 }
2217 ----
2218 ====
2219
2220 [[vl-enum-fc]]
2221 ==== {c-vl-enum} field class
2222
2223 A _{vl-enum}_ field class is both an <<enum-fc,abstract enumeration
2224 field class>> and a {vl-int-fc} which describes _{vl-enum}_ fields.
2225
2226 A {vl-enum} field is a {vl-int} field which {may} have one or more
2227 associated names thanks to the `mappings` property of its class.
2228
2229 If the value of the `type` property of a {vl-enum} field class is
2230 `"variable-length-signed-enumeration"`, then its instances have the
2231 two's complement format.
2232
2233 .Properties of a {vl-enum} field class {var-f}.
2234 [%header%autowidth, cols="d,d,a,d,d"]
2235 |===
2236 |Name |Type |Description |Required? |Default
2237
2238 |`type`
2239 |JSON string
2240 |Type of{nbsp}{var-f}.
2241
2242 The value of this property {must} be one of:
2243
2244 `"variable-length-unsigned-enumeration"`::
2245 The instances of{nbsp}{var-f} are {vl-uenum} fields.
2246
2247 `"variable-length-signed-enumeration"`::
2248 The instances of{nbsp}{var-f} are {vl-senum} fields.
2249 |Yes
2250 |
2251
2252 |`preferred-display-base`
2253 |JSON integer
2254 |Preferred base to display the value of an instance of{nbsp}{var-f}.
2255
2256 The value of this property {must} be one of:
2257
2258 [horizontal]
2259 `2`::
2260 Binary base.
2261
2262 `8`::
2263 Octal base.
2264
2265 `10`::
2266 Decimal base.
2267
2268 `16`::
2269 Hexadecimal base.
2270
2271 This property exists to remain backward compatible with {ctf1}:
2272 it's not strictly needed to decode an instance of{nbsp}{var-f}.
2273
2274 Property inherited from the <<int-fc,abstract integer field class>>.
2275 |No
2276 |`10`
2277
2278 |`mappings`
2279 |<<enum-fc-mappings,Enumeration field class mappings>>
2280 |Mappings of{nbsp}{var-f}.
2281
2282 The value of this property {must} contain one or more properties.
2283
2284 Property inherited from the <<enum-fc,abstract enumeration field class>>.
2285 |Yes
2286 |
2287
2288 |`roles`
2289 |<<roles,Roles>>
2290 |Roles of an instance of{nbsp}{var-f}.
2291
2292 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2293 root field classes.
2294 |No
2295 |`+[]+`
2296
2297 |`user-attributes`
2298 |<<user-attrs,User attributes>>
2299 |User attributes of{nbsp}{var-f}.
2300 |No
2301 |`+{}+`
2302
2303 |`extensions`
2304 |<<ext,Extensions>>
2305 |Extensions of{nbsp}{var-f}.
2306
2307 Any extension which exists under this property {must} also be declared
2308 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2309 |No
2310 |`+{}+`
2311 |===
2312
2313 .Minimal {vl-uenum} field class.
2314 ====
2315 [source,json]
2316 ----
2317 {
2318 "type": "variable-length-unsigned-enumeration",
2319 "mappings": {
2320 "apple": [[1, 19]]
2321 }
2322 }
2323 ----
2324 ====
2325
2326 .{c-vl-uenum} field class with instances to be preferably displayed with a hexadecimal base.
2327 ====
2328 [source,json]
2329 ----
2330 {
2331 "type": "variable-length-unsigned-enumeration",
2332 "preferred-display-base": 16,
2333 "mappings": {
2334 "lime": [[3, 3]],
2335 "kiwi": [[8, 8]],
2336 "blueberry": [[11, 11]]
2337 }
2338 }
2339 ----
2340 ====
2341
2342 .{c-vl-senum} field class with <<user-attrs,user attributes>>.
2343 ====
2344 [source,json]
2345 ----
2346 {
2347 "type": "variable-length-signed-enumeration",
2348 "mappings": {
2349 "banana": [[-27399, -1882], [8, 199], [101, 101]],
2350 "orange": [[67, 67], [43, 1534]]
2351 },
2352 "user-attributes": {
2353 "my.tracer": {
2354 "is-nice": true
2355 }
2356 }
2357 }
2358 ----
2359 ====
2360
2361 [[str-fc]]
2362 ==== {c-str} field class
2363
2364 A _{str}_ field class describes _{str}_ fields.
2365
2366 A {str} field is, in this order:
2367
2368 . Zero or more contiguous non-null (non-zero) bytes which form a
2369 UTF-8-encoded string.
2370
2371 . One null (zero) byte.
2372
2373 .Properties of a {str} field class {var-f}.
2374 [%header%autowidth, cols="d,d,a,d,d"]
2375 |===
2376 |Name |Type |Description |Required? |Default
2377
2378 |`type`
2379 |JSON string
2380 |Type of{nbsp}{var-f}.
2381
2382 The value of this property {must} be `"null-terminated-string"`.
2383 |Yes
2384 |
2385
2386 |`roles`
2387 |<<roles,Roles>>
2388 |Roles of an instance of{nbsp}{var-f}.
2389
2390 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2391 root field classes.
2392 |No
2393 |`+[]+`
2394
2395 |`user-attributes`
2396 |<<user-attrs,User attributes>>
2397 |User attributes of{nbsp}{var-f}.
2398 |No
2399 |`+{}+`
2400
2401 |`extensions`
2402 |<<ext,Extensions>>
2403 |Extensions of{nbsp}{var-f}.
2404
2405 Any extension which exists under this property {must} also be declared
2406 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2407 |No
2408 |`+{}+`
2409 |===
2410
2411 .Minimal {str} field class.
2412 ====
2413 [source,json]
2414 ----
2415 {
2416 "type": "null-terminated-string"
2417 }
2418 ----
2419 ====
2420
2421 .{c-str} field class with <<user-attrs,user attributes>>.
2422 ====
2423 [source,json]
2424 ----
2425 {
2426 "type": "null-terminated-string",
2427 "user-attributes": {
2428 "my.tracer": {
2429 "is-nice": true
2430 }
2431 }
2432 }
2433 ----
2434 ====
2435
2436 [[sl-str-fc]]
2437 ==== {c-sl-str} field class
2438
2439 A _{sl-str}_ field class describes _{sl-str}_ fields.
2440
2441 A {sl-str} field is a <<seq-def,sequence>> of zero or more contiguous
2442 bytes. All the bytes of a {sl-str} before the first null (zero) byte, if
2443 any, form a UTF-8-encoded string. All the bytes after the first null
2444 (zero) byte, if any, are padding (garbage data).
2445
2446 The length, or number of bytes, of a {sl-str} field is a property
2447 (`length`) of its class.
2448
2449 .Properties of a {sl-str} field class {var-f}.
2450 [%header%autowidth, cols="d,d,a,d,d"]
2451 |===
2452 |Name |Type |Description |Required? |Default
2453
2454 |`type`
2455 |JSON string
2456 |Type of{nbsp}{var-f}.
2457
2458 The value of this property {must} be `"static-length-string"`.
2459 |Yes
2460 |
2461
2462 |`length`
2463 |JSON integer
2464 |Number of bytes contained in an instance of{nbsp}{var-f}.
2465
2466 The value of this property {must} be greater than or equal to zero.
2467 |Yes
2468 |
2469
2470 |`roles`
2471 |<<roles,Roles>>
2472 |Roles of an instance of{nbsp}{var-f}.
2473
2474 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2475 root field classes.
2476 |No
2477 |`+[]+`
2478
2479 |`user-attributes`
2480 |<<user-attrs,User attributes>>
2481 |User attributes of{nbsp}{var-f}.
2482 |No
2483 |`+{}+`
2484
2485 |`extensions`
2486 |<<ext,Extensions>>
2487 |Extensions of{nbsp}{var-f}.
2488
2489 Any extension which exists under this property {must} also be declared
2490 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2491 |No
2492 |`+{}+`
2493 |===
2494
2495 .Empty {sl-str} field class.
2496 ====
2497 [source,json]
2498 ----
2499 {
2500 "type": "static-length-string",
2501 "length": 0
2502 }
2503 ----
2504 ====
2505
2506 .{c-sl-str} field class with instances having 100{nbsp}bytes.
2507 ====
2508 [source,json]
2509 ----
2510 {
2511 "type": "static-length-string",
2512 "length": 100
2513 }
2514 ----
2515 ====
2516
2517 .{c-sl-str} field class with <<user-attrs,user attributes>>.
2518 ====
2519 [source,json]
2520 ----
2521 {
2522 "type": "static-length-string",
2523 "length": 13,
2524 "user-attributes": {
2525 "my.tracer": null
2526 }
2527 }
2528 ----
2529 ====
2530
2531 [[dl-str-fc]]
2532 ==== {c-dl-str} field class
2533
2534 A _{dl-str}_ field class describes _{dl-str}_ fields.
2535
2536 A {dl-str} field is a <<seq-def,sequence>> of zero or more contiguous
2537 bytes. All the bytes of a {dl-str} before the first null (zero) byte, if
2538 any, form a UTF-8-encoded string. All the bytes after the first null
2539 (zero) byte, if any, are padding (garbage data).
2540
2541 The length, or number of bytes, of a {dl-str} field is the value of
2542 another, anterior (already encoded/decoded) _length_ field. A
2543 <<consumer-def,consumer>> can locate this length field thanks to the
2544 `length-field-location` property of the {dl-str} field class.
2545
2546 .Properties of a {dl-str} field class {var-f}.
2547 [%header%autowidth, cols="d,d,a,d,d"]
2548 |===
2549 |Name |Type |Description |Required? |Default
2550
2551 |`type`
2552 |JSON string
2553 |Type of{nbsp}{var-f}.
2554
2555 The value of this property {must} be `"static-length-string"`.
2556 |Yes
2557 |
2558
2559 |`length-field-location`
2560 |<<field-loc,Field location>>
2561 |Location of the field of which the value is the number of bytes
2562 contained in an instance of{nbsp}{var-f}.
2563
2564 The class of the length field {must} be one of:
2565
2566 * {c-fl-uint-fc}
2567 * {c-vl-uint-fc}
2568 |Yes
2569 |
2570
2571 |`roles`
2572 |<<roles,Roles>>
2573 |Roles of an instance of{nbsp}{var-f}.
2574
2575 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2576 root field classes.
2577 |No
2578 |`+[]+`
2579
2580 |`user-attributes`
2581 |<<user-attrs,User attributes>>
2582 |User attributes of{nbsp}{var-f}.
2583 |No
2584 |`+{}+`
2585
2586 |`extensions`
2587 |<<ext,Extensions>>
2588 |Extensions of{nbsp}{var-f}.
2589
2590 Any extension which exists under this property {must} also be declared
2591 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2592 |No
2593 |`+{}+`
2594 |===
2595
2596 .{c-dl-str} field class.
2597 ====
2598 [source,json]
2599 ----
2600 {
2601 "type": "dynamic-length-string",
2602 "length-field-location": ["event-record-payload", "length"]
2603 }
2604 ----
2605 ====
2606
2607 .{c-dl-str} field class with <<user-attrs,user attributes>>.
2608 ====
2609 [source,json]
2610 ----
2611 {
2612 "type": "dynamic-length-string",
2613 "length-field-location": ["event-record-common-context", "name-length"],
2614 "user-attributes": {
2615 "my.tracer": 177
2616 }
2617 }
2618 ----
2619 ====
2620
2621 [[blob-fc]]
2622 ==== Abstract BLOB field class
2623
2624 An _abstract https://en.wikipedia.org/wiki/Binary_large_object[BLOB]_
2625 field class is a base of a {sl-blob-fc} and a {dl-blob-fc}.
2626
2627 This field class is abstract in that it only exists to show the relation
2628 between different BLOB field classes in this document: a <<pkt,packet>>
2629 cannot contain an abstract BLOB field.
2630
2631 .Common properties of a BLOB field class {var-f}.
2632 [%header%autowidth, cols="d,d,a,d,d"]
2633 |===
2634 |Name |Type |Description |Required? |Default
2635
2636 |`media-type`
2637 |JSON string
2638 |
2639 https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types[IANA
2640 media type] of an instance of{nbsp}{var-f}.
2641 |No
2642 |`"application/octet-stream"`
2643 |===
2644
2645 [[sl-blob-fc]]
2646 ==== {c-sl-blob} field class
2647
2648 A _{sl-blob}_ field class is an <<blob-fc,abstract BLOB field class>>
2649 which describes _{sl-blob}_ fields.
2650
2651 A {sl-blob} field is a <<seq-def,sequence>> of zero or more contiguous
2652 bytes with an associated IANA media type (given by the `media-type`
2653 property of its class).
2654
2655 The length, or number of bytes, of a {sl-blob} field is a property
2656 (`length`) of its class.
2657
2658 .Properties of a {sl-blob} field class {var-f}.
2659 [%header%autowidth, cols="d,d,a,d,d"]
2660 |===
2661 |Name |Type |Description |Required? |Default
2662
2663 |`type`
2664 |JSON string
2665 |Type of{nbsp}{var-f}.
2666
2667 The value of this property {must} be `"static-length-blob"`.
2668 |Yes
2669 |
2670
2671 |`length`
2672 |JSON integer
2673 |Number of bytes contained in an instance of{nbsp}{var-f}.
2674
2675 The value of this property {must} be greater than or equal to zero.
2676 |Yes
2677 |
2678
2679 |`media-type`
2680 |JSON string
2681 |
2682 https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types[IANA
2683 media type] of an instance of{nbsp}{var-f}.
2684
2685 Property inherited from the <<blob-fc,abstract BLOB field class>>.
2686 |No
2687 |`"application/octet-stream"`
2688
2689 |`roles`
2690 |<<roles,Roles>>
2691 |Roles of an instance of{nbsp}{var-f}.
2692
2693 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2694 root field classes.
2695 |No
2696 |`+[]+`
2697
2698 |`user-attributes`
2699 |<<user-attrs,User attributes>>
2700 |User attributes of{nbsp}{var-f}.
2701 |No
2702 |`+{}+`
2703
2704 |`extensions`
2705 |<<ext,Extensions>>
2706 |Extensions of{nbsp}{var-f}.
2707
2708 Any extension which exists under this property {must} also be declared
2709 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2710 |No
2711 |`+{}+`
2712 |===
2713
2714 .Empty {sl-blob} field class with instances having a default IANA media type.
2715 ====
2716 [source,json]
2717 ----
2718 {
2719 "type": "static-length-blob",
2720 "length": 0
2721 }
2722 ----
2723 ====
2724
2725 .Static-length TIFF BLOB field class with instances having 511,267{nbsp}bytes.
2726 ====
2727 [source,json]
2728 ----
2729 {
2730 "type": "static-length-blob",
2731 "length": 511267,
2732 "media-type": "image/tif"
2733 }
2734 ----
2735 ====
2736
2737 .Static-length CSV BLOB field class with <<user-attrs,user attributes>>.
2738 ====
2739 [source,json]
2740 ----
2741 {
2742 "type": "static-length-blob",
2743 "length": 2400,
2744 "media-type": "text/csv",
2745 "user-attributes": {
2746 "my.tracer": {
2747 "csv-cols": 12
2748 }
2749 }
2750 }
2751 ----
2752 ====
2753
2754 [[dl-blob-fc]]
2755 ==== {c-dl-blob} field class
2756
2757 A _{dl-blob}_ field class is an <<blob-fc,abstract BLOB field class>>
2758 which describes _{dl-blob}_ fields.
2759
2760 A {dl-blob} field is a <<seq-def,sequence>> of zero or more contiguous
2761 bytes with an associated IANA media type.
2762
2763 The length, or number of bytes, of a {dl-blob} field is the value of
2764 another, anterior (already encoded/decoded) _length_ field. A
2765 <<consumer-def,consumer>> can locate this length field thanks to the
2766 `length-field-location` property of the {dl-blob} field class.
2767
2768 .Properties of a {dl-blob} field class {var-f}.
2769 [%header%autowidth, cols="d,d,a,d,d"]
2770 |===
2771 |Name |Type |Description |Required? |Default
2772
2773 |`type`
2774 |JSON string
2775 |Type of{nbsp}{var-f}.
2776
2777 The value of this property {must} be `"dynamic-length-blob"`.
2778 |Yes
2779 |
2780
2781 |`length-field-location`
2782 |<<field-loc,Field location>>
2783 |Location of the field of which the value is the number of bytes
2784 contained in an instance of{nbsp}{var-f}.
2785
2786 The class of the length field {must} be one of:
2787
2788 * {c-fl-uint-fc}
2789 * {c-vl-uint-fc}
2790 |Yes
2791 |
2792
2793 |`media-type`
2794 |JSON string
2795 |https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types[IANA
2796 media type] of an instance of{nbsp}{var-f}.
2797
2798 Property inherited from the <<blob-fc,abstract BLOB field class>>.
2799 |No
2800 |`"application/octet-stream"`
2801
2802 |`roles`
2803 |<<roles,Roles>>
2804 |Roles of an instance of{nbsp}{var-f}.
2805
2806 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2807 root field classes.
2808 |No
2809 |`+[]+`
2810
2811 |`user-attributes`
2812 |<<user-attrs,User attributes>>
2813 |User attributes of{nbsp}{var-f}.
2814 |No
2815 |`+{}+`
2816
2817 |`extensions`
2818 |<<ext,Extensions>>
2819 |Extensions of{nbsp}{var-f}.
2820
2821 Any extension which exists under this property {must} also be declared
2822 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2823 |No
2824 |`+{}+`
2825 |===
2826
2827 .{c-dl-blob} field class with instances having a default IANA media type.
2828 ====
2829 [source,json]
2830 ----
2831 {
2832 "type": "dynamic-length-blob",
2833 "length-field-location": ["event-record-payload", "length"]
2834 }
2835 ----
2836 ====
2837
2838 .Dynamic-length JPEG BLOB field class with <<user-attrs,user attributes>>.
2839 ====
2840 [source,json]
2841 ----
2842 {
2843 "type": "dynamic-length-blob",
2844 "length-field-location": ["event-record-common-context", "length"],
2845 "media-type": "image/jpeg",
2846 "user-attributes": {
2847 "my.tracer": {
2848 "quality": 85
2849 }
2850 }
2851 }
2852 ----
2853 ====
2854
2855 [[struct-fc]]
2856 ==== Structure field class
2857
2858 A _structure field class_ describes _structure fields_.
2859
2860 A structure field is a <<seq-def,sequence>> of zero or more structure
2861 field _members_. A structure field member is a named field.
2862
2863 .Properties of a structure field class {var-f}.
2864 [%header%autowidth, cols="d,d,a,d,d"]
2865 |===
2866 |Name |Type |Description |Required? |Default
2867
2868 |`type`
2869 |JSON string
2870 |Type of{nbsp}{var-f}.
2871
2872 The value of this property {must} be `"structure"`.
2873 |Yes
2874 |
2875
2876 |`member-classes`
2877 |JSON array of <<struct-member-cls,structure field member classes>>
2878 |Classes of the members of an instance of{nbsp}{var-f}.
2879
2880 The `name` property of each member class {must} be unique within the
2881 member class names of{nbsp}{var-f}.
2882 |No
2883 |`+[]+`
2884
2885 |`minimum-alignment`
2886 |JSON integer
2887 |Minimum alignment of the first bit of an instance of{nbsp}{var-f}
2888 relative to the beginning of the <<pkt,packet>> which contains this
2889 instance.
2890
2891 The value of this property {must} be a positive power of two.
2892
2893 The <<align-dec,_effective_ alignment>> of the first bit of an instance
2894 of{nbsp}{var-f} {may} be greater than the value of this property.
2895 |No
2896 |`1`
2897
2898 |`roles`
2899 |<<roles,Roles>>
2900 |Roles of an instance of{nbsp}{var-f}.
2901
2902 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2903 root field classes.
2904 |No
2905 |`+[]+`
2906
2907 |`user-attributes`
2908 |<<user-attrs,User attributes>>
2909 |User attributes of{nbsp}{var-f}.
2910 |No
2911 |`+{}+`
2912
2913 |`extensions`
2914 |<<ext,Extensions>>
2915 |Extensions of{nbsp}{var-f}.
2916
2917 Any extension which exists under this property {must} also be declared
2918 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2919 |No
2920 |`+{}+`
2921 |===
2922
2923 .Empty structure field class: instances have no members.
2924 ====
2925 [source,json]
2926 ----
2927 {
2928 "type": "structure"
2929 }
2930 ----
2931 ====
2932
2933 .Structure field class with three member classes.
2934 ====
2935 [source,json]
2936 ----
2937 {
2938 "type": "structure",
2939 "member-classes": [
2940 {
2941 "name": "Villeray",
2942 "field-class": {
2943 "type": "null-terminated-string"
2944 }
2945 },
2946 {
2947 "name": "Berri",
2948 "field-class": {
2949 "type": "fixed-length-unsigned-integer",
2950 "length": 32,
2951 "byte-order": "little-endian",
2952 "preferred-display-base": 2
2953 },
2954 "user-attributes": {
2955 "my.tracer": {
2956 "is-mask": true
2957 }
2958 }
2959 },
2960 {
2961 "name": "Faillon",
2962 "field-class": {
2963 "type": "fixed-length-boolean",
2964 "length": 8,
2965 "byte-order": "little-endian"
2966 }
2967 }
2968 ]
2969 }
2970 ----
2971 ====
2972
2973 .Structure field class with instances minimally aligned to 64{nbsp}bits.
2974 ====
2975 [source,json]
2976 ----
2977 {
2978 "type": "structure",
2979 "member-classes": [
2980 {
2981 "name": "St-Denis",
2982 "field-class": {
2983 "type": "null-terminated-string"
2984 }
2985 },
2986 {
2987 "name": "Lajeunesse",
2988 "field-class": {
2989 "type": "fixed-length-unsigned-integer",
2990 "length": 32,
2991 "byte-order": "big-endian",
2992 "alignment": 32
2993 }
2994 }
2995 ],
2996 "minimum-alignment": 64
2997 }
2998 ----
2999 ====
3000
3001 .Structure field class with <<user-attrs,user attributes>>.
3002 ====
3003 [source,json]
3004 ----
3005 {
3006 "type": "structure",
3007 "member-classes": [
3008 {
3009 "name": "Henri-Julien",
3010 "field-class": {
3011 "type": "fixed-length-signed-integer",
3012 "length": 48,
3013 "byte-order": "little-endian"
3014 }
3015 },
3016 {
3017 "name": "Casgrain",
3018 "field-class": {
3019 "type": "static-length-string",
3020 "length": 32
3021 }
3022 }
3023 ],
3024 "user-attributes": {
3025 "my.tracer": {
3026 "version": 4
3027 }
3028 }
3029 }
3030 ----
3031 ====
3032
3033 [[struct-member-cls]]
3034 ===== Structure field member class
3035
3036 A _structure field member class_ describes _structure field members_.
3037
3038 A structure field member class is a JSON object.
3039
3040 .Properties of a structure field member class _**M**_.
3041 [%header%autowidth, cols="d,d,a,d,d"]
3042 |===
3043 |Name |Type |Description |Required? |Default
3044
3045 |`name`
3046 |JSON string
3047 |Name of{nbsp}__**M**__.
3048 |Yes
3049 |
3050
3051 |`field-class`
3052 |<<fc,Field class>>
3053 |Field class of{nbsp}__**M**__.
3054 |Yes
3055 |
3056
3057 |`user-attributes`
3058 |<<user-attrs,User attributes>>
3059 |User attributes of{nbsp}__**M**__.
3060 |No
3061 |`+{}+`
3062
3063 |`extensions`
3064 |<<ext,Extensions>>
3065 |Extensions of{nbsp}__**M**__.
3066
3067 Any extension which exists under this property {must} also be declared
3068 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3069 |No
3070 |`+{}+`
3071 |===
3072
3073 .<<str-fc,{c-str} field class>> member class named `cat`.
3074 ====
3075 [source,json]
3076 ----
3077 {
3078 "name": "cat",
3079 "field-class": {
3080 "type": "null-terminated-string"
3081 }
3082 }
3083 ----
3084 ====
3085
3086 .{c-vl-sint-fc} member class named `dog` with <<user-attrs,user attributes>>.
3087 ====
3088 [source,json]
3089 ----
3090 {
3091 "name": "dog",
3092 "field-class": {
3093 "type": "variable-length-signed-integer",
3094 "preferred-display-base": 8
3095 },
3096 "user-attributes": {
3097 "my.tracer": {
3098 "uuid": [
3099 243, 97, 0, 184, 236, 54, 72, 97,
3100 141, 107, 169, 214, 171, 137, 115, 201
3101 ],
3102 "is-pid": true
3103 }
3104 }
3105 }
3106 ----
3107 ====
3108
3109 [[array-fc]]
3110 ==== Abstract array field class
3111
3112 An _abstract array_ field class is a base of a {sl-array-fc} and a
3113 {dl-array-fc}.
3114
3115 This field class is abstract in that it only exists to show the relation
3116 between different array field classes in this document: a <<pkt,packet>>
3117 cannot contain an abstract array field.
3118
3119 .Common properties of an array field class {var-f}.
3120 [%header%autowidth, cols="d,d,a,d,d"]
3121 |===
3122 |Name |Type |Description |Required? |Default
3123
3124 |`element-field-class`
3125 |<<fc,Field class>>
3126 |Class of the element fields contained in an instance of{nbsp}{var-f}.
3127 |Yes
3128 |
3129
3130 |`minimum-alignment`
3131 |JSON integer
3132 |Minimum alignment of the first bit of an instance of{nbsp}{var-f}
3133 relative to the beginning of the <<pkt,packet>> which contains this
3134 instance.
3135
3136 The value of this property {must} be a positive power of two.
3137
3138 The <<align-dec,_effective_ alignment>> of the first bit of an instance
3139 of{nbsp}{var-f} {may} be greater than the value of this property.
3140 |No
3141 |`1`
3142 |===
3143
3144 [[sl-array-fc]]
3145 ==== {c-sl-array} field class
3146
3147 A _{sl-array}_ field class is an <<array-fc,abstract array field class>>
3148 which describes _{sl-array}_ fields.
3149
3150 A {sl-array} field is a sequence of zero or more element fields.
3151
3152 The length, or number of element fields, of a {sl-array} field is a
3153 property (`length`) of its class.
3154
3155 .Properties of a {sl-array} field class {var-f}.
3156 [%header%autowidth, cols="d,d,a,d,d"]
3157 |===
3158 |Name |Type |Description |Required? |Default
3159
3160 |`type`
3161 |JSON string
3162 |Type of{nbsp}{var-f}.
3163
3164 The value of this property {must} be `"static-length-array"`.
3165 |Yes
3166 |
3167
3168 |`element-field-class`
3169 |<<fc,Field class>>
3170 |Class of the element fields contained in an instance of{nbsp}{var-f}.
3171
3172 Property inherited from the <<array-fc,abstract array field class>>.
3173 |Yes
3174 |
3175
3176 |`minimum-alignment`
3177 |JSON integer
3178 |Minimum alignment of the first bit of an instance of{nbsp}{var-f}
3179 relative to the beginning of the <<pkt,packet>> which contains this
3180 instance.
3181
3182 The value of this property {must} be a positive power of two.
3183
3184 The <<align-dec,_effective_ alignment>> of the first bit of an instance
3185 of{nbsp}{var-f} {may} be greater than the value of this property.
3186
3187 Property inherited from the <<array-fc,abstract array field class>>.
3188 |No
3189 |`1`
3190
3191 |`length`
3192 |JSON integer
3193 |Number of element fields contained in an instance of{nbsp}{var-f}.
3194
3195 The value of this property {must} be greater than or equal to zero.
3196 |Yes
3197 |
3198
3199 |`roles`
3200 |<<roles,Roles>>
3201 |Roles of an instance of{nbsp}{var-f}.
3202
3203 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
3204 root field classes.
3205 |No
3206 |`+[]+`
3207
3208 |`user-attributes`
3209 |<<user-attrs,User attributes>>
3210 |User attributes of{nbsp}{var-f}.
3211 |No
3212 |`+{}+`
3213
3214 |`extensions`
3215 |<<ext,Extensions>>
3216 |Extensions of{nbsp}{var-f}.
3217
3218 Any extension which exists under this property {must} also be declared
3219 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3220 |No
3221 |`+{}+`
3222 |===
3223
3224 .Empty {sl-array} field class.
3225 ====
3226 [source,json]
3227 ----
3228 {
3229 "type": "static-length-array",
3230 "element-field-class": {
3231 "type": "fixed-length-signed-integer",
3232 "length": 16,
3233 "byte-order": "little-endian",
3234 "alignment": 16
3235 },
3236 "length": 0
3237 }
3238 ----
3239 ====
3240
3241 .{c-sl-array} field class with instances having 100{nbsp}<<str-fc,{str}>> fields.
3242 ====
3243 [source,json]
3244 ----
3245 {
3246 "type": "static-length-array",
3247 "element-field-class": {
3248 "type": "null-terminated-string"
3249 },
3250 "length": 100
3251 }
3252 ----
3253 ====
3254
3255 .{c-sl-array} field class with <<user-attrs,user attributes>>.
3256 ====
3257 [source,json]
3258 ----
3259 {
3260 "type": "static-length-array",
3261 "element-field-class": {
3262 "type": "variable-length-unsigned-integer"
3263 },
3264 "length": 13,
3265 "user-attributes": {
3266 "my.tracer": true
3267 }
3268 }
3269 ----
3270 ====
3271
3272 .{c-sl-array} field class with instances minimally aligned to 32{nbsp}bits.
3273 ====
3274 With the following {sl-array} field class, a <<producer-def,producer>>
3275 can write a single 32-bit-aligned, 32-bit little-endian integer value,
3276 and have <<consumer-def,consumers>> <<sl-array-field-dec,decode>> it as
3277 an array of 32{nbsp}flags (booleans).
3278
3279 [source,json]
3280 ----
3281 {
3282 "type": "static-length-array",
3283 "length": 32,
3284 "minimum-alignment": 32,
3285 "element-field-class": {
3286 "type": "fixed-length-boolean",
3287 "length": 1,
3288 "byte-order": "little-endian"
3289 }
3290 }
3291 ----
3292 ====
3293
3294 [[dl-array-fc]]
3295 ==== {c-dl-array} field class
3296
3297 A _{dl-array}_ field class is an <<array-fc,abstract array field class>>
3298 which describes _{dl-array}_ fields.
3299
3300 A {dl-array} field is a sequence of zero or more element fields.
3301
3302 The length, or number of element fields, of a {dl-array} field is the
3303 value of another, anterior (already encoded/decoded) _length_ field. A
3304 <<consumer-def,consumer>> can locate this length field thanks to the
3305 `length-field-location` property of the {dl-array} field class.
3306
3307 .Properties of a {dl-array} field class {var-f}.
3308 [%header%autowidth, cols="d,d,a,d,d"]
3309 |===
3310 |Name |Type |Description |Required? |Default
3311
3312 |`type`
3313 |JSON string
3314 |Type of{nbsp}{var-f}.
3315
3316 The value of this property {must} be `"dynamic-length-array"`.
3317 |Yes
3318 |
3319
3320 |`element-field-class`
3321 |<<fc,Field class>>
3322 |Class of the element fields contained in an instance of{nbsp}{var-f}.
3323
3324 Property inherited from the <<array-fc,abstract array field class>>.
3325 |Yes
3326 |
3327
3328 |`minimum-alignment`
3329 |JSON integer
3330 |Minimum alignment of the first bit of an instance of{nbsp}{var-f}
3331 relative to the beginning of the <<pkt,packet>> which contains this
3332 instance.
3333
3334 The value of this property {must} be a positive power of two.
3335
3336 The <<align-dec,_effective_ alignment>> of the first bit of an instance
3337 of{nbsp}{var-f} {may} be greater than the value of this property.
3338
3339 Property inherited from the <<array-fc,abstract array field class>>.
3340 |No
3341 |`1`
3342
3343 |`length-field-location`
3344 |<<field-loc,Field location>>
3345 |Location of the field of which the value is the number of element
3346 fields contained in an instance of{nbsp}{var-f}.
3347
3348 The class of the length field {must} be one of:
3349
3350 * {c-fl-uint-fc}
3351 * {c-vl-uint-fc}
3352 |Yes
3353 |
3354
3355 |`roles`
3356 |<<roles,Roles>>
3357 |Roles of an instance of{nbsp}{var-f}.
3358
3359 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
3360 root field classes.
3361 |No
3362 |`+[]+`
3363
3364 |`user-attributes`
3365 |<<user-attrs,User attributes>>
3366 |User attributes of{nbsp}{var-f}.
3367 |No
3368 |`+{}+`
3369
3370 |`extensions`
3371 |<<ext,Extensions>>
3372 |Extensions of{nbsp}{var-f}.
3373
3374 Any extension which exists under this property {must} also be declared
3375 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3376 |No
3377 |`+{}+`
3378 |===
3379
3380 .{c-dl-array} field class.
3381 ====
3382 [source,json]
3383 ----
3384 {
3385 "type": "dynamic-length-array",
3386 "element-field-class": {
3387 "type": "fixed-length-unsigned-integer",
3388 "length": 32,
3389 "byte-order": "big-endian",
3390 "alignment": 16
3391 },
3392 "length-field-location": ["event-record-payload", "length"]
3393 }
3394 ----
3395 ====
3396
3397 .{c-dl-array} field class with <<user-attrs,user attributes>>.
3398 ====
3399 [source,json]
3400 ----
3401 {
3402 "type": "dynamic-length-array",
3403 "element-field-class": {
3404 "type": "variable-length-unsigned-integer"
3405 },
3406 "length-field-location": ["packet-context", "common-length"],
3407 "user-attributes": {
3408 "my.tracer": 177
3409 }
3410 }
3411 ----
3412 ====
3413
3414 [[opt-fc]]
3415 ==== Optional field class
3416
3417 An _optional_ field class describes _optional_ fields.
3418
3419 An optional field is, depending on the value of another, anterior
3420 (already encoded/decoded) _selector_ field, one of:
3421
3422 * An instance of a given field class (`field-class` property of the
3423 optional field class).
3424 +
3425 In this case, the optional field is said to be _enabled_.
3426
3427 * A zero-bit field (no field).
3428 +
3429 In this case, the optional field is said to be _disabled_.
3430
3431 A <<consumer-def,consumer>> can locate the selector field thanks to the
3432 `selector-field-location` property of the optional field class.
3433
3434 .Properties of an optional field class {var-f}.
3435 [%header%autowidth, cols="d,d,a,d,d"]
3436 |===
3437 |Name |Type |Description |Required? |Default
3438
3439 |`type`
3440 |JSON string
3441 |Type of{nbsp}{var-f}.
3442
3443 The value of this property {must} be `"optional"`.
3444 |Yes
3445 |
3446
3447 |`field-class`
3448 |<<fc,Field class>>
3449 |Class of an instance of{nbsp}{var-f} when it's enabled.
3450 |Yes
3451 |
3452
3453 |`selector-field-location`
3454 |<<field-loc,Field location>>
3455 |Location of the field of which the value indicates whether or not an
3456 instance of{nbsp}{var-f} is enabled.
3457
3458 A selector field{nbsp}__**S**__ {must} be an instance of one of:
3459
3460 {c-fl-bool-fc}::
3461 An instance of{nbsp}{var-f} is enabled when{nbsp}__**S**__ is
3462 true.
3463
3464 {c-fl-int-fc}::
3465 {c-vl-int-fc}::
3466 An instance of{nbsp}{var-f} is enabled when the value
3467 of{nbsp}__**S**__ is an element of any of the integer ranges of the
3468 `selector-field-ranges` property of{nbsp}{var-f}.
3469
3470 For a given instance of{nbsp}{var-f}, the `type` property of the
3471 <<fc,classes>> of _all_ the possible selector fields {must} be
3472 one of:
3473
3474 * <<fl-bool-fc,``"fixed-length-boolean"``>>
3475 * Any of:
3476 ** <<fl-int-fc,``"fixed-length-unsigned-integer"``>>
3477 ** <<fl-enum-fc,``"fixed-length-unsigned-enumeration"``>>
3478 ** <<vl-int-fc,``"variable-length-unsigned-integer"``>>
3479 ** <<vl-enum-fc,``"variable-length-unsigned-enumeration"``>>
3480
3481 * Any of:
3482 ** <<fl-int-fc,``"fixed-length-signed-integer"``>>
3483 ** <<fl-enum-fc,``"fixed-length-signed-enumeration"``>>
3484 ** <<vl-int-fc,``"variable-length-signed-integer"``>>
3485 ** <<vl-enum-fc,``"variable-length-signed-enumeration"``>>
3486 |Yes
3487 |
3488
3489 |`selector-field-ranges`
3490 |<<int-range-set,Integer range set>>
3491 |Ranges of integers which the value of a selector field {must} be an
3492 element of to enable an instance of{nbsp}{var-f}.
3493 |Yes, if the selector field is an instance of a {fl-int-fc}
3494 or a {vl-int-fc}.
3495 |None if the selector field is an instance of a {fl-bool-fc}.
3496
3497 |`roles`
3498 |<<roles,Roles>>
3499 |Roles of{nbsp}{var-f}.
3500
3501 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
3502 root field classes.
3503 |No
3504 |`+[]+`
3505
3506 |`user-attributes`
3507 |<<user-attrs,User attributes>>
3508 |User attributes of{nbsp}{var-f}.
3509 |No
3510 |`+{}+`
3511
3512 |`extensions`
3513 |<<ext,Extensions>>
3514 |Extensions of{nbsp}{var-f}.
3515
3516 Any extension which exists under this property {must} also be declared
3517 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3518 |No
3519 |`+{}+`
3520 |===
3521
3522 .Optional {sl-array-fc} with a <<bool-fc,boolean>> selector field class.
3523 ====
3524 [source,json]
3525 ----
3526 {
3527 "type": "optional",
3528 "selector-field-location": ["event-record-payload", "has-ip"],
3529 "field-class": {
3530 "type": "static-length-array",
3531 "element-field-class": {
3532 "type": "fixed-length-unsigned-integer",
3533 "length": 8,
3534 "byte-order": "little-endian",
3535 "alignment": 8
3536 },
3537 "length": 16
3538 }
3539 }
3540 ----
3541 ====
3542
3543 .Optional {str} with a <<fl-int-fc,fixed-length signed integer>> selector field class.
3544 ====
3545 [source,json]
3546 ----
3547 {
3548 "type": "optional",
3549 "selector-field-location": ["event-record-payload", "has-ip"],
3550 "selector-field-ranges": [[-12, -12], [-5, 0], [15, 35]],
3551 "field-class": {
3552 "type": "null-terminated-string"
3553 }
3554 }
3555 ----
3556 ====
3557
3558 [[var-fc]]
3559 ==== Variant field class
3560
3561 A _variant_ field class describes _variant_ fields.
3562
3563 A variant field is, depending on the value of another, anterior (already
3564 encoded/decoded) _selector_ field, the instance of a specific, effective
3565 field class amongst one or more _variant field class options_.
3566
3567 A <<consumer-def,consumer>> can locate the selector field thanks to the
3568 `selector-field-location` property of the variant field class.
3569
3570 .Properties of a variant field class {var-f}.
3571 [%header%autowidth, cols="d,d,a,d,d"]
3572 |===
3573 |Name |Type |Description |Required? |Default
3574
3575 |`type`
3576 |JSON string
3577 |Type of{nbsp}{var-f}.
3578
3579 The value of this property {must} be `"variant"`.
3580 |Yes
3581 |
3582
3583 |`options`
3584 |JSON array of <<var-fc-opt,variant field class options>>
3585 |Options containing the possible effective classes of an instance
3586 of{nbsp}{var-f}.
3587
3588 This array {must} contain one or more elements.
3589
3590 The `name` property of each option, if it's set, {must} be unique within
3591 the option names of{nbsp}{var-f}.
3592
3593 The integer ranges (`selector-field-ranges` property) of two given
3594 options {must-not} intersect.
3595 |Yes
3596 |
3597
3598 |`selector-field-location`
3599 |<<field-loc,Field location>>
3600 |Location of the field of which the value indicates which option
3601 of{nbsp}{var-f} contains the effective class of an instance
3602 of{nbsp}{var-f}.
3603
3604 For a given instance of{nbsp}{var-f}, the `type` property of the
3605 <<fc,classes>> of _all_ the possible selector fields {must} be
3606 one of:
3607
3608 * Any of:
3609 ** <<fl-int-fc,``"fixed-length-unsigned-integer"``>>
3610 ** <<fl-enum-fc,``"fixed-length-unsigned-enumeration"``>>
3611 ** <<vl-int-fc,``"variable-length-unsigned-integer"``>>
3612 ** <<vl-enum-fc,``"variable-length-unsigned-enumeration"``>>
3613
3614 * Any of:
3615 ** <<fl-int-fc,``"fixed-length-signed-integer"``>>
3616 ** <<fl-enum-fc,``"fixed-length-signed-enumeration"``>>
3617 ** <<vl-int-fc,``"variable-length-signed-integer"``>>
3618 ** <<vl-enum-fc,``"variable-length-signed-enumeration"``>>
3619 |Yes
3620 |
3621
3622 |`roles`
3623 |<<roles,Roles>>
3624 |Roles of{nbsp}{var-f}.
3625
3626 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
3627 root field classes.
3628 |No
3629 |`+[]+`
3630
3631 |`user-attributes`
3632 |<<user-attrs,User attributes>>
3633 |User attributes of{nbsp}{var-f}.
3634 |No
3635 |`+{}+`
3636
3637 |`extensions`
3638 |<<ext,Extensions>>
3639 |Extensions of{nbsp}{var-f}.
3640
3641 Any extension which exists under this property {must} also be declared
3642 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3643 |No
3644 |`+{}+`
3645 |===
3646
3647 .Variant field class with two options.
3648 ====
3649 [source,json]
3650 ----
3651 {
3652 "type": "variant",
3653 "selector-field-location": ["event-record-payload", "sel"],
3654 "options": [
3655 {
3656 "selector-field-ranges": [[5, 5]],
3657 "field-class": {
3658 "type": "null-terminated-string"
3659 }
3660 },
3661 {
3662 "selector-field-ranges": [[8, 8]],
3663 "field-class": {
3664 "type": "fixed-length-signed-integer",
3665 "length": 16,
3666 "byte-order": "little-endian",
3667 "preferred-display-base": 8
3668 }
3669 }
3670 ]
3671 }
3672 ----
3673 ====
3674
3675 .Variant field class within an {opt-fc} which share the same selector field location.
3676 ====
3677 This example shows that an optional field class and a contained variant
3678 field class {may} share the same selector field location.
3679
3680 In this example, depending on the value of the selector field:
3681
3682 [horizontal]
3683 0::
3684 The optional field is _not_ enabled.
3685
3686 1::
3687 The optional field is enabled and is a variant field.
3688 +
3689 The variant field is an instance of a {str-fc} (effective class).
3690
3691 2::
3692 The optional field is enabled and is a variant field.
3693 +
3694 The variant field is an instance of a {vl-sint-fc} (effective class).
3695
3696 [source,json]
3697 ----
3698 {
3699 "type": "optional",
3700 "selector-field-location": ["event-record-payload", "sel"],
3701 "selector-field-ranges": [[1, 255]],
3702 "field-class": {
3703 "type": "variant",
3704 "selector-field-location": ["event-record-payload", "sel"],
3705 "options": [
3706 {
3707 "selector-field-ranges": [[1, 1]],
3708 "field-class": {
3709 "type": "null-terminated-string"
3710 }
3711 },
3712 {
3713 "selector-field-ranges": [[2, 2]],
3714 "field-class": {
3715 "type": "variable-length-signed-integer",
3716 "preferred-display-base": 16
3717 }
3718 }
3719 ]
3720 }
3721 }
3722 ----
3723 ====
3724
3725 .Variant field class with <<user-attrs,user attributes>>.
3726 ====
3727 [source,json]
3728 ----
3729 {
3730 "type": "variant",
3731 "selector-field-location": ["event-record-specific-context", "sel"],
3732 "options": [
3733 {
3734 "selector-field-ranges": [[5, 5], [10, 10], [15, 15]],
3735 "field-class": {
3736 "type": "static-length-string",
3737 "length": 20
3738 }
3739 },
3740 {
3741 "selector-field-ranges": [[0, 4], [6, 9], [11, 14], [16, 127]],
3742 "field-class": {
3743 "type": "fixed-length-floating-point-number",
3744 "length": 32,
3745 "byte-order": "big-endian"
3746 }
3747 }
3748 ],
3749 "user-attributes": {
3750 "my.tracer": {
3751 "owner": "Jimmy",
3752 "id": 199990
3753 }
3754 }
3755 }
3756 ----
3757 ====
3758
3759 [[var-fc-opt]]
3760 ===== Variant field class option
3761
3762 A _variant field class option_ contains a possible effective class of a
3763 variant field.
3764
3765 A variant field class option{nbsp}__**O**__ also contains the ranges of
3766 integer values (`selector-field-ranges` property) of which the value of
3767 a selector field {must} be an element of for the effective class of a
3768 variant field to be the field class of {var-o}.
3769
3770 A variant field class option is a JSON object.
3771
3772 .Properties of a variant field class option {var-o} contained in a variant field class{nbsp}{var-f}.
3773 [%header%autowidth, cols="d,d,a,d,d"]
3774 |===
3775 |Name |Type |Description |Required? |Default
3776
3777 |`field-class`
3778 |<<fc,Field class>>
3779 |Field class of{nbsp}{var-o}.
3780 |Yes
3781 |
3782
3783 |`selector-field-ranges`
3784 |<<int-range-set,Integer range set>>
3785 |Ranges of integers which the value of a selector field {must} be an
3786 element of for the effective class of an instance of{nbsp}{var-f}
3787 to be the field class (`field-class` property) of{nbsp}{var-o}.
3788 |Yes
3789 |
3790
3791 |`name`
3792 |JSON string
3793 |Name of{nbsp}{var-o}.
3794
3795 This property exists to remain backward compatible with {ctf1}:
3796 it's not strictly needed to decode an instance of{nbsp}{var-f}.
3797 |No
3798 |{var-o} is unnamed
3799
3800 |`user-attributes`
3801 |<<user-attrs,User attributes>>
3802 |User attributes of{nbsp}{var-o}.
3803 |No
3804 |`+{}+`
3805
3806 |`extensions`
3807 |<<ext,Extensions>>
3808 |Extensions of{nbsp}{var-o}.
3809
3810 Any extension which exists under this property {must} also be declared
3811 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3812 |No
3813 |`+{}+`
3814 |===
3815
3816 .Unnamed {str-fc} option.
3817 ====
3818 [source,json]
3819 ----
3820 {
3821 "field-class": {
3822 "type": "null-terminated-string"
3823 },
3824 "selector-field-ranges": [[3, 9]]
3825 }
3826 ----
3827 ====
3828
3829 .{c-vl-sint-fc} option named `juice` with <<user-attrs,user attributes>>.
3830 ====
3831 [source,json]
3832 ----
3833 {
3834 "name": "juice",
3835 "field-class": {
3836 "type": "variable-length-signed-integer",
3837 "preferred-display-base": 16
3838 },
3839 "selector-field-ranges": [[-4, 4], [9, 9], [100, 200]],
3840 "user-attributes": {
3841 "my.tracer": {
3842 "uuid": [
3843 243, 97, 0, 184, 236, 54, 72, 97,
3844 141, 107, 169, 214, 171, 137, 115, 201
3845 ],
3846 "is-did": true
3847 }
3848 }
3849 }
3850 ----
3851 ====
3852
3853 [[preamble-frag]]
3854 === Preamble fragment
3855
3856 A _preamble fragment_ indicates:
3857
3858 * The {ctf2} major version (2).
3859 +
3860 {ctf2} doesn't have a minor version: users can use
3861 <<user-attributes,user attributes>> and <<ext,extensions>> to add
3862 features to, or change features of, the format which this document
3863 specifies.
3864
3865 * <<ext,Extension>> declarations.
3866 +
3867 An extension declaration is an initial extension of which the purpose is
3868 to declare that it's _enabled_ within the <<metadata-stream,metadata
3869 stream>>.
3870 +
3871 Because an extension {may} alter the {ctf2} format itself, and because a
3872 preamble fragment is always the first metadata stream fragment, those
3873 extension declarations make it possible for a <<consumer-def,consumer>>
3874 to gracefully decline the <<ds,data streams>> of the trace if it doesn't
3875 support _any_ declared extension.
3876
3877 The first fragment of a metadata stream {must} be a preamble fragment.
3878
3879 .Properties of a preamble fragment {var-f}.
3880 [%header%autowidth]
3881 |===
3882 |Name |Type |Description |Required? |Default
3883
3884 |`type`
3885 |JSON string
3886 |Type of{nbsp}{var-f}.
3887
3888 The value of this property {must} be `"preamble"`.
3889 |Yes
3890 |
3891
3892 |`version`
3893 |JSON integer
3894 |{ctf2} major version.
3895
3896 The value of this property {must} be `2`.
3897 |Yes
3898 |
3899
3900 |`user-attributes`
3901 |<<user-attrs,User attributes>>
3902 |User attributes of{nbsp}{var-f}.
3903 |No
3904 |`+{}+`
3905
3906 |`extensions`
3907 |<<ext,Extensions>>
3908 |Extension declarations of{nbsp}{var-f}.
3909
3910 The name of each property is a <<ns-def,namespace>> and its value is a
3911 <<ns-exts-obj,namespaced extensions object>>.
3912
3913 Within a <<ns-exts-obj,namespaced extensions object>>, an extension
3914 named{nbsp}__**N**__ is _declared_ when it exists as a property
3915 named{nbsp}__**N**__, whatever the value of the property.
3916 |No
3917 |`+{}+`
3918 |===
3919
3920 .Minimal preamble fragment.
3921 ====
3922 [source,json]
3923 ----
3924 {
3925 "type": "preamble",
3926 "version": 2
3927 }
3928 ----
3929 ====
3930
3931 .Preamble fragment with <<ext,extension>> declarations.
3932 ====
3933 The following preamble fragment declares the `piano` and `ramen`
3934 extensions under the `my.tracer` namespace.
3935
3936 [source,json]
3937 ----
3938 {
3939 "type": "preamble",
3940 "version": 2,
3941 "extensions": {
3942 "my.tracer": {
3943 "piano": {
3944 "keys": 88,
3945 "temperament": "equal"
3946 },
3947 "ramen": null
3948 }
3949 }
3950 }
3951 ----
3952 ====
3953
3954 [[tc-frag]]
3955 === Trace class fragment
3956
3957 A _trace class_ describes <<trace,_traces_>>.
3958
3959 Within a metadata stream, a trace class fragment {must} occur, if any,
3960 before any <<dsc-frag,data stream class fragment>>.
3961
3962 .Properties of a trace class fragment {var-f}.
3963 [%header%autowidth,cols="d,d,a,d,d"]
3964 |===
3965 |Name |Type |Description |Required? |Default
3966
3967 |`type`
3968 |JSON string
3969 |Type of{nbsp}{var-f}.
3970
3971 The value of this property {must} be `"trace-class"`.
3972 |Yes
3973 |
3974
3975 |`uuid`
3976 |<<uuid,UUID>>
3977 |UUID of{nbsp}{var-f}.
3978 |No
3979 |{var-f}{nbsp}has no UUID
3980
3981 |`packet-header-field-class`
3982 |{c-struct-fc}
3983 |Class of all the <<pkt-header,packet header fields>> of an instance
3984 of{nbsp}{var-f}.
3985
3986 Any field class as the value of this property {must} satisfy _at least
3987 one of_:
3988
3989 * Have at least one valid <<pkt-header-roles,role>>.
3990 * Be a {struct-fc}.
3991 * Be an {opt-fc}.
3992 * Be a {var-fc}.
3993 * Be the class of a field which is the selector field of an optional
3994 or variant field.
3995 |No
3996 |{var-f}{nbsp}has no packet header field class
3997
3998 |`user-attributes`
3999 |<<user-attrs,User attributes>>
4000 |User attributes of{nbsp}{var-f}.
4001 |No
4002 |`+{}+`
4003
4004 |`extensions`
4005 |<<ext,Extensions>>
4006 |Extensions of{nbsp}{var-f}.
4007
4008 Any extension which exists under this property {must} also be declared
4009 in the <<preamble-frag,preamble fragment>> of the metadata stream.
4010 |No
4011 |`+{}+`
4012 |===
4013
4014 ==== Roles
4015
4016 [[pkt-header-roles]] If the `packet-header-field-class` property of a
4017 trace class fragment exists, then the <<fc,field classes>> of its
4018 <<struct-member-cls,member classes>> {may} have the following
4019 <<roles,roles>>:
4020
4021 .Roles of field classes of the member classes of a packet header field class.
4022 [%header%autowidth,cols="d,d,a,a"]
4023 |===
4024 |Name |Description |Field class ({var-f}) constraints |Other constraints
4025
4026 |`packet-magic-number`
4027 |<<pkt,Packet>> magic number.
4028
4029 The purpose of a packet magic number field is to confirm the beginning
4030 of a {ctf2} packet.
4031 |{c-fl-uint-fc} with the following property value:
4032
4033 [horizontal]
4034 `length`::
4035 `32`
4036 |An instance of{nbsp}{var-f} {must} be the _first_ member of the packet
4037 header structure field.
4038
4039 The value of an instance of{nbsp}{var-f} value {must} be 0xc1fc1fc1
4040 (3254525889).
4041
4042 |`trace-class-uuid`
4043 |Trace class UUID.
4044
4045 The purpose of a trace class UUID field is to confirm the association
4046 between a <<ds,data stream>> and a <<metadata-stream-overview,metadata
4047 stream>>.
4048 |{c-sl-blob-fc} with the following property value:
4049
4050 [horizontal]
4051 `length`::
4052 `16`
4053 |The `uuid` property of the trace class {must} exist.
4054
4055 The 16{nbsp}bytes of an instance of{nbsp}{var-f} {must} be equal to the
4056 16{nbsp}JSON integers of the `uuid` property of the trace class.
4057
4058 |`data-stream-class-id`
4059 |Data stream class ID.
4060
4061 The purpose of a data stream class ID field is to set the current ID of
4062 the class of the data stream of the current packet.
4063 |{c-fl-uint-fc} or {vl-uint-fc}.
4064 |
4065
4066 |`data-stream-id`
4067 |Data stream ID.
4068
4069 The purpose of a data stream ID field is to set the current ID of
4070 the data stream of the current packet.
4071
4072 Combined with the ID of its class, such a field makes it possible to
4073 uniquely identify a data stream within a <<trace,trace>>.
4074 |{c-fl-uint-fc} or {vl-uint-fc}.
4075 |
4076 |===
4077
4078 .Trace class fragment.
4079 ====
4080 [source,json]
4081 ----
4082 {
4083 "type": "trace-class",
4084 "uuid": [
4085 30, 201, 100, 148, 228, 2, 69, 70,
4086 147, 219, 233, 34, 43, 238, 108, 199
4087 ],
4088 "packet-header-field-class": {
4089 "type": "structure",
4090 "member-classes": [
4091 {
4092 "name": "the magic!",
4093 "field-class": {
4094 "type": "fixed-length-unsigned-integer",
4095 "length": 32,
4096 "byte-order": "little-endian",
4097 "preferred-display-base": 16,
4098 "roles": ["packet-magic-number"]
4099 }
4100 },
4101 {
4102 "name": "the UUID",
4103 "field-class": {
4104 "type": "static-length-blob",
4105 "length": 16,
4106 "roles": ["trace-class-uuid"]
4107 }
4108 },
4109 {
4110 "name": "my data stream class ID",
4111 "field-class": {
4112 "type": "fixed-length-unsigned-integer",
4113 "length": 8,
4114 "byte-order": "little-endian",
4115 "roles": ["data-stream-class-id"]
4116 }
4117 },
4118 {
4119 "name": "my data stream ID",
4120 "field-class": {
4121 "type": "variable-length-unsigned-integer",
4122 "roles": ["data-stream-id"]
4123 }
4124 }
4125 ]
4126 }
4127 }
4128 ----
4129 ====
4130
4131 [[cc-frag]]
4132 === Clock class fragment
4133
4134 A _clock class_ describes _clocks_.
4135
4136 A <<ds,data stream>> {may} have a <<def-clk,default clock>>.
4137
4138 Within a metadata stream, a clock class fragment {must} occur before any
4139 <<dsc-frag,data stream class fragment>> which refers to it by name with
4140 its `default-clock-class-name` property.
4141
4142 .Properties of a clock class fragment {var-f}.
4143 [%header%autowidth,cols="d,d,a,d,d"]
4144 |===
4145 |Name |Type |Description |Required? |Default
4146
4147 |`type`
4148 |JSON string
4149 |Type of{nbsp}{var-f}.
4150
4151 The value of this property {must} be `"clock-class"`.
4152 |Yes
4153 |
4154
4155 |`frequency`
4156 |JSON integer
4157 |Frequency of an instance of{nbsp}{var-f} (Hz).
4158
4159 The value of this property {must} be greater than zero.
4160 |Yes
4161 |
4162
4163 |`name`
4164 |JSON string
4165 |Name of{nbsp}{var-f}.
4166 |Yes
4167 |
4168
4169 |`description`
4170 |JSON string
4171 |Textual description of{nbsp}{var-f}.
4172
4173 This property exists to remain backward compatible with {ctf1}:
4174 it's not strictly needed to decode <<ds,data streams>>.
4175 |No
4176 |{var-f}{nbsp}has no textual description
4177
4178 |`uuid`
4179 |<<uuid,UUID>>
4180 |UUID of{nbsp}{var-f}.
4181
4182 This property exists to remain backward compatible with {ctf1}:
4183 it's not strictly needed to decode <<ds,data streams>>.
4184 |No
4185 |{var-f}{nbsp}has no UUID
4186
4187 |`origin-is-unix-epoch`
4188 |JSON boolean
4189 |Whether or not the origin of an instance of{nbsp}{var-f} is
4190 the https://en.wikipedia.org/wiki/Unix_time[Unix epoch].
4191
4192 If the value of this property is `false`, then the origin of
4193 an instance of{nbsp}{var-f} is unknown.
4194 |No
4195 |`true`
4196
4197 |`offset`
4198 |<<clock-offset,Clock offset>>
4199 |Offset of an instance of{nbsp}{var-f} relative to its origin.
4200
4201 Let:
4202
4203 . _**H**_ be the value of the `frequency` property of{nbsp}{var-f}.
4204 . {var-o} be the value of this property.
4205 . {var-s} be the value of the `seconds` property of{nbsp}{var-o}.
4206 . _**C**_ be the value of the `cycles` property of{nbsp}{var-o}.
4207
4208 Then the effective offset of an instance of{nbsp}{var-f}, in clock
4209 cycles,
4210 is{nbsp}{var-s}{nbsp}{times}{nbsp}__**H**__{nbsp}pass:[+]{nbsp}__**C**__.
4211 |No
4212 |`{"seconds":{nbsp}0, "cycles":{nbsp}0}`
4213
4214 |`precision`
4215 |JSON integer
4216 |Precision of an instance of{nbsp}{var-f} (clock cycles).
4217
4218 The value of this property {must} be greater than or equal to zero.
4219
4220 Let{nbsp}{var-p} be the value of this property and{nbsp}__**V**__
4221 the value of an instance of{nbsp}{var-f}: the range of possible
4222 values of the instance
4223 is{nbsp}[__**V**__{nbsp}{minus}{nbsp}{var-p},{nbsp}__**V**__{nbsp}pass:[+]{nbsp}{var-p}].
4224 |No
4225 |`0`
4226
4227 |`user-attributes`
4228 |<<user-attrs,User attributes>>
4229 |User attributes of{nbsp}{var-f}.
4230 |No
4231 |`+{}+`
4232
4233 |`extensions`
4234 |<<ext,Extensions>>
4235 |Extensions of{nbsp}{var-f}.
4236
4237 Any extension which exists under this property {must} also be declared
4238 in the <<preamble-frag,preamble fragment>> of the metadata stream.
4239 |No
4240 |`+{}+`
4241 |===
4242
4243 Within a metadata stream, two given clock class fragments {must-not}:
4244
4245 * Share the same `name` property value.
4246 * Share the same `uuid` property value.
4247
4248 .Minimal clock class fragment with 1-GHz instances.
4249 ====
4250 [source,json]
4251 ----
4252 {
4253 "type": "clock-class",
4254 "name": "my clock class",
4255 "frequency": 1000000000
4256 }
4257 ----
4258 ====
4259
4260 .Clock class fragment with a UUID property.
4261 ====
4262 [source,json]
4263 ----
4264 {
4265 "type": "clock-class",
4266 "name": "my clock class",
4267 "frequency": 1000000000,
4268 "uuid": [
4269 116, 210, 0, 140, 239, 255, 77, 3,
4270 129, 99, 233, 226, 134, 106, 207, 32
4271 ]
4272 }
4273 ----
4274 ====
4275
4276 .Clock class fragment with instances having a specific offset.
4277 ====
4278 [source,json]
4279 ----
4280 {
4281 "type": "clock-class",
4282 "name": "my clock class",
4283 "frequency": 1000000000,
4284 "offset": {
4285 "seconds": 1605112699,
4286 "cycles": 2878388
4287 }
4288 }
4289 ----
4290 ====
4291
4292 .Clock class fragment with instances having a specific precision.
4293 ====
4294 [source,json]
4295 ----
4296 {
4297 "type": "clock-class",
4298 "name": "my clock class",
4299 "frequency": 8000000,
4300 "precision": 100
4301 }
4302 ----
4303 ====
4304
4305 .Clock class fragment with instances having an origin which isn't the Unix epoch.
4306 ====
4307 [source,json]
4308 ----
4309 {
4310 "type": "clock-class",
4311 "name": "my clock class",
4312 "frequency": 1000000000,
4313 "origin-is-unix-epoch": false
4314 }
4315 ----
4316 ====
4317
4318 .Clock class fragment with <<user-attrs,user attributes>>.
4319 ====
4320 [source,json]
4321 ----
4322 {
4323 "type": "clock-class",
4324 "name": "my clock class",
4325 "frequency": 16000000,
4326 "user-attributes": {
4327 "my.tracer": {
4328 "sys-name": "SOC23",
4329 "bus": {
4330 "name": "LMB5",
4331 "index": 5
4332 },
4333 "propagation-delay-ps": 177
4334 }
4335 }
4336 }
4337 ----
4338 ====
4339
4340 [[clock-offset]]
4341 ==== Clock offset
4342
4343 A _clock offset_ contains the offset of the instances of a
4344 <<cc-frag,clock class>> relative to their origin.
4345
4346 A clock offset is a JSON object.
4347
4348 .Properties of a clock offset contained in a clock class fragment {var-f}.
4349 [%header%autowidth]
4350 |===
4351 |Name |Type |Description |Required? |Default
4352
4353 |`seconds`
4354 |JSON integer
4355 |Offset, in seconds, of an instance of{nbsp}{var-f} relative to its
4356 origin.
4357 |No
4358 |`0`
4359
4360 |`cycles`
4361 |JSON integer
4362 |Offset, in cycles, of an instance of{nbsp}{var-f} relative to its
4363 origin.
4364
4365 The value of this property {must} be greater than or equal to zero.
4366
4367 The value of this property {must} be less than the value of the
4368 `frequency` property of{nbsp}{var-f}.
4369 |No
4370 |`0`
4371 |===
4372
4373 .Minimal clock offset.
4374 ====
4375 [source,json]
4376 ----
4377 {}
4378 ----
4379 ====
4380
4381 .Clock offset with seconds and cycles.
4382 ====
4383 [source,json]
4384 ----
4385 {
4386 "seconds": 1605112699,
4387 "cycles": 2878388
4388 }
4389 ----
4390 ====
4391
4392 .Clock offset with seconds only.
4393 ====
4394 [source,json]
4395 ----
4396 {
4397 "seconds": 1605111293
4398 }
4399 ----
4400 ====
4401
4402 .Negative clock offset.
4403 ====
4404 This example shows that a clock offset {may} be negative, that is,
4405 _before_ the origin of the clock.
4406
4407 [source,json]
4408 ----
4409 {
4410 "seconds": -18003,
4411 "cycles": 11928547
4412 }
4413 ----
4414 ====
4415
4416 [[dsc-frag]]
4417 === Data stream class fragment
4418
4419 A _data stream class_ describes <<ds,_data streams_>>.
4420
4421 Within a metadata stream, a data stream class fragment {var-f} {must}
4422 occur before any <<erc-frag,event record class fragment>> of
4423 which{nbsp}{var-f} is the parent.
4424
4425 .Properties of a data stream class fragment {var-f}.
4426 [%header%autowidth,cols="d,d,a,d,d"]
4427 |===
4428 |Name |Type |Description |Required? |Default
4429
4430 |`type`
4431 |JSON string
4432 |Type of{nbsp}{var-f}.
4433
4434 The value of this property {must} be `"data-stream-class"`.
4435 |Yes
4436 |
4437
4438 |`id`
4439 |JSON integer
4440 |Numeric ID of{nbsp}{var-f}.
4441
4442 The value of this property {must} be greater than or equal to zero.
4443 |No
4444 |`0`
4445
4446 |`name`
4447 |JSON string
4448 |Name of{nbsp}{var-f}.
4449
4450 The purpose of this property, combined with the `namespace` property, is
4451 to uniquely identify a data stream class amongst many
4452 <<producer-def,producers>>.
4453 |No
4454 |{var-f}{nbsp}is unnamed
4455
4456 |`namespace`
4457 |JSON string
4458 |<<ns-def,Namespace>> of{nbsp}{var-f}.
4459
4460 The purpose of this property, combined with the `name` property, is to
4461 uniquely identify a data stream class amongst many
4462 <<producer-def,producers>>.
4463 |No
4464 |{var-f}{nbsp}has no namespace
4465
4466 |`default-clock-class-name`
4467 |JSON string
4468 |Name of the <<cc-frag,class>> of the <<def-clk,default clock>> of an
4469 instance of{nbsp}{var-f}.
4470
4471 Within the metadata stream containing{nbsp}{var-f}, the <<cc-frag,clock
4472 class fragment>> which has the value of this property as its `name`
4473 property {must} occur before{nbsp}{var-f}.
4474 |No
4475 |An instance of{nbsp}{var-f} has no default clock
4476
4477 |`packet-context-field-class`
4478 |{c-struct-fc}
4479 |Class of all the <<pkt-ctx,packet context fields>> of an instance
4480 of{nbsp}{var-f}.
4481 |No
4482 |{var-f}{nbsp}has no packet context field class
4483
4484 |`event-record-header-field-class`
4485 |{c-struct-fc}
4486 |Class of all the <<er-header,event record header fields>> of an
4487 instance of{nbsp}{var-f}.
4488
4489 Any field class as the value of this property {must} satisfy _at least
4490 one of_:
4491
4492 * Have at least one valid <<er-header-roles,role>>.
4493 * Be a {struct-fc}.
4494 * Be an {opt-fc}.
4495 * Be a {var-fc}.
4496 * Be the class of a field which is the selector field of an optional or
4497 variant field.
4498 |No
4499 |{var-f}{nbsp}has no event record header field class
4500
4501 |`event-record-common-context-field-class`
4502 |{c-struct-fc}
4503 |Class of all the <<er-common-ctx,event record common context fields>>
4504 of an instance of{nbsp}{var-f}.
4505 |No
4506 |{var-f}{nbsp}has no event record common context field class
4507
4508 |`user-attributes`
4509 |<<user-attrs,User attributes>>
4510 |User attributes of{nbsp}{var-f}.
4511 |No
4512 |`+{}+`
4513
4514 |`extensions`
4515 |<<ext,Extensions>>
4516 |Extensions of{nbsp}{var-f}.
4517
4518 Any extension which exists under this property {must} also be declared
4519 in the <<preamble-frag,preamble fragment>> of the metadata stream.
4520 |No
4521 |`+{}+`
4522 |===
4523
4524 Within a metadata stream, two given data stream class fragments
4525 {must-not} share the same `id` property value.
4526
4527 ==== Roles
4528
4529 [[pkt-ctx-roles]] If the `packet-context-field-class` property of a data
4530 stream class fragment exists, then the <<fc,field classes>> of its
4531 <<struct-member-cls,member classes>> {may} have the following
4532 <<roles,roles>>:
4533
4534 .Roles of field classes of the member classes of a packet context field class.
4535 [%header%autowidth,cols="d,d,a,a"]
4536 |===
4537 |Name |Description |Field class ({var-f}) constraints |Other constraints
4538
4539 |`packet-total-size`
4540 |Total size (bits) of the <<pkt,packet>>.
4541
4542 This size includes any padding after the packet contents.
4543 |{c-fl-uint-fc} or {vl-uint-fc}.
4544
4545 |The value of an instance of{nbsp}{var-f} {must} be greater than or
4546 equal to the value of an instance of a field class having the
4547 `packet-content-size` role, if any, within the _same_ packet context
4548 field.
4549
4550 |`packet-content-size`
4551 |Content size (bits) of the packet.
4552 |{c-fl-uint-fc} or {vl-uint-fc}.
4553 |The value of an instance of{nbsp}{var-f} {must} be less than or equal
4554 to the value of an instance of a field class having the
4555 `packet-total-size` role, if any, within the _same_ packet context
4556 field.
4557
4558 |`packet-beginning-default-clock-timestamp`
4559 |Timestamp of the <<def-clk,default clock>> of the <<ds,data stream>>
4560 when the packet begins.
4561 |{c-fl-uint-fc} or {vl-uint-fc}.
4562 |The timestamps of all the <<er,event records>> of the packet {must} be
4563 greater than or equal to the value of an instance of{nbsp}{var-f}.
4564
4565 The value of an instance of{nbsp}{var-f} {must} be less than or equal to
4566 the value of an instance of a field class having the
4567 `packet-end-default-clock-timestamp` role, if any, within the _same_
4568 packet context field.
4569
4570 |`packet-end-default-clock-timestamp`
4571 |Timestamp of the default clock of the data stream when the packet ends.
4572 |{c-fl-uint-fc} or {vl-uint-fc}.
4573 |The timestamps of all the <<er,event records>> of the packet {must} be
4574 less than or equal to the value of an instance of{nbsp}{var-f}.
4575
4576 The value of an instance of{nbsp}{var-f} {must} be greater than or equal
4577 to the value of an instance of a field class having the
4578 `packet-beginning-default-clock-timestamp` role, if any, within the
4579 _same_ packet context field.
4580
4581 |`discarded-event-record-counter-snapshot`
4582 |Snapshot of the <<disc-er-counter,discarded event record counter>> of
4583 the data stream when the packet ends.
4584 |{c-fl-uint-fc} or {vl-uint-fc}.
4585 |
4586
4587 |[[pkt-seq-num-role]] `packet-sequence-number`
4588 |Sequence number of the packet within its data stream.
4589 |{c-fl-uint-fc} or {vl-uint-fc}.
4590 |
4591 |===
4592
4593 [[er-header-roles]] If the `event-record-header-field-class` property of
4594 a data stream class fragment exists, then the <<fc,field classes>> of
4595 its <<struct-member-cls,member classes>> {may} have the following
4596 <<roles,roles>>:
4597
4598 .Roles of field classes of the member classes of an event record header field class.
4599 [%header%autowidth,cols="d,d,a"]
4600 |===
4601 |Name |Description |Field class ({var-f}) constraints
4602
4603 |`event-record-class-id`
4604 |Event record class ID.
4605
4606 The purpose of an event record class ID field is to set the current ID
4607 of the class of the event record within its parent <<dsc-frag,data
4608 stream class>>.
4609 |{c-fl-uint-fc} or {vl-uint-fc}.
4610
4611 |`default-clock-timestamp`
4612 |Current timestamp of the <<def-clk,default clock>> of the data stream
4613 when the event record occurs.
4614 |{c-fl-uint-fc} or {vl-uint-fc}.
4615 |===
4616
4617 [[erc-frag]]
4618 === Event record class fragment
4619
4620 An _event record class_ describes <<er,_event records_>>.
4621
4622 The <<dsc-frag,data stream class fragment>> of which the value of the
4623 `id` property matches the value of the `data-stream-class-id` property
4624 of an event record class fragment{nbsp}{var-f} is considered the
4625 _parent_ of{nbsp}{var-f}.
4626
4627 .Properties of an event record class fragment{nbsp}{var-f} having the data stream class{nbsp}{var-p} as its parent.
4628 [%header%autowidth,cols="d,d,a,d,d"]
4629 |===
4630 |Name |Type |Description |Required? |Default
4631
4632 |`type`
4633 |JSON string
4634 |Type of{nbsp}{var-f}.
4635
4636 The value of this property {must} be `"event-record-class"`.
4637 |Yes
4638 |
4639
4640 |`id`
4641 |JSON integer
4642 |Numeric ID of{nbsp}{var-f} within{nbsp}{var-p}.
4643
4644 The value of this property {must} be greater than or equal to zero.
4645 |No
4646 |`0`
4647
4648 |`data-stream-class-id`
4649 |JSON integer
4650 |Numeric ID of{nbsp}{var-p}.
4651
4652 The value of this property {must} be greater than or equal to zero.
4653
4654 Within the metadata stream,{nbsp}{var-p} {must} occur
4655 before{nbsp}{var-f}.
4656 |No
4657 |`0`
4658
4659 |`name`
4660 |JSON string
4661 |Name of{nbsp}{var-f}.
4662
4663 The purpose of this property, combined with the `namespace` property, is
4664 to uniquely identify an event record class amongst many
4665 <<producer-def,producers>>.
4666 |No
4667 |{var-f}{nbsp}is unnamed
4668
4669 |`namespace`
4670 |JSON string
4671 |<<ns-def,Namespace>> of{nbsp}{var-f}.
4672
4673 The purpose of this property, combined with the `name` property, is to
4674 uniquely identify an event record class amongst many
4675 <<producer-def,producers>>.
4676 |No
4677 |{var-f}{nbsp}has no namespace
4678
4679 |`specific-context-field-class`
4680 |{c-struct-fc}
4681 |Class of the <<er-spec-ctx,event record specific context field>>
4682 of an instance of{nbsp}{var-f}.
4683 |No
4684 |{var-f}{nbsp}has no event record specific context field class
4685
4686 |`payload-field-class`
4687 |{c-struct-fc}
4688 |Class of the <<er-payload,event record payload field>> of an
4689 instance of{nbsp}{var-f}.
4690 |No
4691 |{var-f}{nbsp}has no event record payload field class
4692
4693 |`user-attributes`
4694 |<<user-attrs,User attributes>>
4695 |User attributes of{nbsp}{var-f}.
4696 |No
4697 |`+{}+`
4698
4699 |`extensions`
4700 |<<ext,Extensions>>
4701 |Extensions of{nbsp}{var-f}.
4702
4703 Any extension which exists under this property {must} also be declared
4704 in the <<preamble-frag,preamble fragment>> of the metadata stream.
4705 |No
4706 |`+{}+`
4707 |===
4708
4709 Within a metadata stream, two given event record class fragments
4710 {must-not} share the same `id` property value _and_ the same
4711 `data-stream-class-id` property value.
4712
4713 [[ds-dec]]
4714 == Data stream decoding procedure
4715
4716 This section shows how to, procedurally, _decode_ a {ctf2} <<ds,data
4717 stream>>.
4718
4719 Decoding a data stream is the responsibility of a
4720 <<consumer-def,consumer>>.
4721
4722 This document doesn't specify how to encode a data stream, as this
4723 procedure implies much more freedom than decoding. One can deduce how to
4724 encode a data stream from the decoding procedure.
4725
4726 A consumer needs to keep a _data stream decoding state_ while decoding a
4727 data stream. A data stream decoding state comprises the following
4728 _variable_:
4729
4730 .Variable needed to decode a data stream{nbsp}{var-s}.
4731 [%header%autowidth]
4732 |===
4733 |Name |Type |Description |Initial value
4734
4735 |{var-dec-o}
4736 |Unsigned integer
4737 |Current decoding offset/position (bits) from the beginning
4738 of{nbsp}{var-s}.
4739 |0
4740 |===
4741
4742 To decode a data stream {var-s}:
4743
4744 * While there's remaining data in {var-s}:
4745 ** <<pkt-dec,Decode one packet>>.
4746
4747 [[pkt-dec]]
4748 === Packet decoding procedure
4749
4750 A <<consumer-def,consumer>> needs to keep a _packet decoding state_
4751 while decoding a <<pkt,packet>>. A packet decoding state comprises the
4752 following _variables_:
4753
4754 .Variables needed to decode a packet{nbsp}{var-p} within a data stream{nbsp}{var-s}.
4755 [%header%autowidth]
4756 |===
4757 |Name |Type |Description |Initial value
4758
4759 |_**DEF_CLK_VAL**_
4760 |Unsigned integer
4761 |Current value (clock cycles) of the <<def-clk,default
4762 clock>> of{nbsp}{var-s}, if any.
4763 |0
4764
4765 |_**DSC_ID**_
4766 |Unsigned integer
4767 |Current ID of the <<dsc-frag,class>> of{nbsp}{var-s}.
4768 |0
4769
4770 |_**DSC**_
4771 |Optional <<dsc-frag,data stream class>>
4772 |Current class of{nbsp}{var-s}.
4773 |None
4774
4775 |_**DS_ID**_
4776 |Optional unsigned integer
4777 |Current ID of{nbsp}{var-s}.
4778 |None
4779
4780 |_**PKT_TOTAL_SZ**_
4781 |Unsigned integer
4782 |Current total size (bits) of{nbsp}{var-p}.
4783 |∞
4784
4785 |_**PKT_CONTENT_SZ**_
4786 |Unsigned integer
4787 |Current content size (bits) of{nbsp}{var-p}.
4788 |∞
4789
4790 |_**LAST_BO**_
4791 |Optional string
4792 |Byte order of the last <<fl-ba-field-dec,decoded {fl-ba} field>>.
4793 |None
4794 |===
4795
4796 To decode a packet {var-p} within a data stream {var-s}:
4797
4798 . Let {var-dec-po} be the current value of {var-dec-o}.
4799 +
4800 While decoding the packet, {var-dec-o-minus-po} is the current decoding
4801 offset/position (bits) from the beginning of{nbsp}{var-p}.
4802
4803 . If the `packet-header-field-class` property of the <<tc-frag,trace
4804 class fragment>> of the metadata stream exists, then
4805 <<struct-field-dec,decode>> the <<pkt-header,header field>>
4806 of{nbsp}{var-p} using this property.
4807 +
4808 During the packet header field decoding procedure, after having decoded
4809 a field{nbsp}{var-f} having the class{nbsp}__**C**__ with a `roles`
4810 property:
4811 +
4812 ** If _**C**_ has the role `packet-magic-number`, then validate that the
4813 unsigned integer value of{nbsp}{var-f} is 0xc1fc1fc1 (3254525889).
4814 +
4815 A <<consumer-def,consumer>> {should} report an invalid packet magic
4816 number as an error.
4817
4818 ** If _**C**_ has the role `trace-type-uuid`, then validate that the
4819 value of{nbsp}{var-f} matches the `uuid` property of the trace
4820 class fragment.
4821 +
4822 A consumer {should} report a trace type UUID mismatch as an error.
4823
4824 ** If _**C**_ has the role `data-stream-class-id`, then
4825 set{nbsp}__**DSC_ID**__ to the unsigned integer value
4826 of{nbsp}{var-f}.
4827
4828 ** If _**C**_ has the role `data-stream-id`, then
4829 set{nbsp}__**DS_ID**__ to the unsigned integer value
4830 of{nbsp}{var-f}.
4831
4832 +
4833 After having decoded the whole packet header field,
4834 if{nbsp}__**DS_ID**__ is set, then it's the ID of{nbsp}{var-s} within
4835 its <<dsc-frag,class>>. In other words, two data streams {may} have the
4836 same ID if they are instances of different data stream classes.
4837
4838 . Set _**DSC**_ to the <<dsc-frag,data stream class>>
4839 having{nbsp}__**DSC_ID**__ as the value of its `id` property.
4840 +
4841 If no data stream class has the ID{nbsp}__**DSC_ID**__, then report an
4842 error and abort the data stream decoding process.
4843
4844 . If the `packet-context-field-class` property of{nbsp}__**DSC**__
4845 exists, then <<struct-field-dec,decode>> the <<pkt-ctx,context field>>
4846 of{nbsp}{var-p} using this property.
4847 +
4848 During the packet context field decoding procedure, after having decoded
4849 a field{nbsp}{var-f} having the class{nbsp}__**C**__ with a `roles`
4850 property:
4851 +
4852 ** If _**C**_ has the role `packet-total-size`, then
4853 set{nbsp}__**PKT_TOTAL_SZ**__ to the unsigned integer value
4854 of{nbsp}{var-f}.
4855
4856 ** If _**C**_ has the role `packet-content-size`, then
4857 set{nbsp}__**PKT_CONTENT_SZ**__ to the unsigned integer value
4858 of{nbsp}{var-f}.
4859
4860 ** If _**C**_ has the role `packet-beginning-default-clock-timestamp`,
4861 then set{nbsp}__**DEF_CLK_VAL**__ to the unsigned integer value
4862 of{nbsp}{var-f}.
4863
4864 ** If _**C**_ has the role `packet-end-default-clock-timestamp`, then
4865 the unsigned integer value of{nbsp}{var-f} is the value of the
4866 <<def-clk,default clock>> of{nbsp}{var-s} at the end of{nbsp}{var-p}.
4867
4868 ** If _**C**_ has the role `discarded-event-record-counter-snapshot`,
4869 then the unsigned integer value of{nbsp}{var-f} is a snapshot of the
4870 <<disc-er-counter,discarded event record counter>> of{nbsp}{var-s} at
4871 the end of{nbsp}{var-p}.
4872
4873 ** If _**C**_ has the role `packet-sequence-number`, then the unsigned
4874 integer value of{nbsp}{var-f} is the sequence number of{nbsp}{var-p}
4875 within{nbsp}{var-s}.
4876
4877 +
4878 A <<consumer-def,consumer>> {should} report a beginning default clock
4879 timestamp greater than an end default clock timestamp as an error.
4880
4881 . If __**PKT_TOTAL_SZ**__ is{nbsp}∞ and __**PKT_CONTENT_SZ**__ is
4882 __not__{nbsp}∞, then set{nbsp}__**PKT_TOTAL_SZ**__
4883 to{nbsp}__**PKT_CONTENT_SZ**__.
4884
4885 . If __**PKT_CONTENT_SZ**__ is{nbsp}∞ and __**PKT_TOTAL_SZ**__ is
4886 __not__{nbsp}∞, then set{nbsp}__**PKT_CONTENT_SZ**__
4887 to{nbsp}__**PKT_TOTAL_SZ**__.
4888
4889 . While {var-dec-o}{nbsp}<{nbsp}{var-dec-po}{nbsp}pass:[+]{nbsp}__**PKT_CONTENT_SZ**__
4890 and there's remaining data in{nbsp}{var-s}:
4891
4892 ** <<er-dec,Decode an event record>>.
4893
4894 . If __**PKT_TOTAL_SZ**__ and{nbsp}__**PKT_CONTENT_SZ**__ both are
4895 __not__{nbsp}∞, then set{nbsp}{var-dec-o} to
4896 {var-dec-po}{nbsp}pass:[+]{nbsp}__**PKT_TOTAL_SZ**__, effectively
4897 skipping end-of-packet padding.
4898
4899 [[er-dec]]
4900 === Event record decoding procedure
4901
4902 A <<consumer-def,consumer>> needs to keep an _event record decoding
4903 state_ while decoding an <<er,event record>>. An event record decoding
4904 state comprises the following _variables_:
4905
4906 .Variables needed to decode an event record{nbsp}__**E**__ within a data stream{nbsp}{var-s}.
4907 [%header%autowidth]
4908 |===
4909 |Name |Type |Description |Initial value
4910
4911 |_**ERC_ID**_
4912 |Unsigned integer
4913 |Current ID of the <<erc-frag,class>> of{nbsp}__**E**__ of which the
4914 parent is the <<dsc-frag,class>> of{nbsp}{var-s}.
4915 |0
4916
4917 |_**ERC**_
4918 |Optional <<erc-frag,event record class>>
4919 |Current class of{nbsp}__**E**__.
4920 |None
4921 |===
4922
4923 To decode an event record _**E**_ within a data stream {var-s}:
4924
4925 . If the `event-record-header-field-class` property of{nbsp}__**DSC**__
4926 exists, then <<struct-field-dec,decode>> the <<er-header,header
4927 field>> of{nbsp}__**E**__ using this property.
4928 +
4929 During the event record header field decoding procedure, after having
4930 decoded a field{nbsp}{var-f} having the class{nbsp}__**C**__ with a
4931 `roles` property:
4932 +
4933 ** If _**C**_ has the role `event-record-class-id`, then
4934 set{nbsp}__**ERC_ID**__ to the unsigned integer value
4935 of{nbsp}{var-f}.
4936
4937 ** If _**C**_ has the role `default-clock-timestamp`, then
4938 <<clk-val-update,update{nbsp}__**DEF_CLK_VAL**__>> from{nbsp}{var-f}.
4939
4940
4941 +
4942 After having decoded the whole event record header field,
4943 __**DEF_CLK_VAL**__ is the value of the <<def-clk,default clock>>
4944 of{nbsp}{var-s} when{nbsp}__**E**__ occurs.
4945
4946 . Set _**ERC**_ to the <<erc-frag,event record class>> having:
4947
4948 ** __**DSC_ID**__ as the value of its `data-stream-class-id` property.
4949 ** __**ERC_ID**__ as the value of its `id` property.
4950
4951 +
4952 If no event record class has the ID{nbsp}__**ERC_ID**__ within a data
4953 stream class having the ID{nbsp}__**DSC_ID**__, then report an error and
4954 abort the data stream decoding process.
4955
4956 . If the `event-record-common-context-field-class` property
4957 of{nbsp}__**DSC**__ exists, then <<struct-field-dec,decode>> the
4958 <<er-common-ctx,common context field>> of{nbsp}__**E**__ using this
4959 property.
4960
4961 . If the `specific-context-field-class` property of{nbsp}__**ERC**__
4962 exists, then <<struct-field-dec,decode>> the
4963 <<er-spec-ctx,specific context field>> of{nbsp}__**E**__
4964 using this property.
4965
4966 . If the `payload-field-class` property of{nbsp}__**ERC**__ exists, then
4967 <<struct-field-dec,decode>> the <<er-payload,payload field>>
4968 of{nbsp}__**E**__ using this property.
4969
4970 [[clk-val-update]]
4971 ==== Clock value update procedure
4972
4973 To update __**DEF_CLK_VAL**__ from an unsigned integer
4974 field{nbsp}{var-f} having the unsigned integer value{nbsp}__**V**__ and
4975 the <<fc,class>>{nbsp}__**C**__:
4976
4977 . Let __**L**__ be an unsigned integer initialized to,
4978 depending on the `type` property of{nbsp}__**C**__:
4979 +
4980 --
4981 <<fl-int-fc,`"fixed-length-unsigned-integer"`>>::
4982 <<fl-enum-fc,`"fixed-length-unsigned-enumeration"`>>::
4983 The value of the `length` property of{nbsp}__**C**__.
4984
4985 <<vl-int-fc,`"variable-length-unsigned-integer"`>>::
4986 <<vl-enum-fc,`"variable-length-unsigned-enumeration"`>>::
4987 __**S**__{nbsp}{times}7, where{nbsp}__**S**__ is the number of
4988 <<byte-def,bytes>> which{nbsp}{var-f} occupies
4989 with the <<ds,data stream>>.
4990 --
4991
4992 . Let _**MASK**_ be an unsigned integer initialized to
4993 2^__**L**__^{nbsp}{minus}{nbsp}1.
4994
4995 . Let _**H**_ be an unsigned integer initialized to
4996 __**DEF_CLK_VAL**__{nbsp}&{nbsp}pass:[~]__**MASK**__,
4997 where "`&`" is the bitwise _AND_ operator and
4998 "`pass:[~]`" is the bitwise _NOT_ operator.
4999
5000 . Let _**CUR**_ be an unsigned integer initialized to
5001 __**DEF_CLK_VAL**__{nbsp}&{nbsp}__**MASK**__, where "`&`" is the
5002 bitwise _AND_ operator.
5003
5004 . Set __**DEF_CLK_VAL**__ to:
5005 +
5006 --
5007 If __**V**__{nbsp}≥{nbsp}__**CUR**__::
5008 __**H**__{nbsp}pass:[+]{nbsp}__**V**__
5009
5010 Else::
5011 __**H**__{nbsp}pass:[+]{nbsp}__**MASK**__{nbsp}pass:[+]{nbsp}1{nbsp}pass:[+]{nbsp}__**V**__
5012 --
5013
5014 [[field-dec]]
5015 === Field decoding procedure
5016
5017 The <<fc,class>> of a field contains what's needed to decode it as a
5018 _value_.
5019
5020 While a field is an actual <<seq-def,sequence>> of bits within a
5021 <<ds,data stream>>, a value is its conceptual interpretation with
5022 attached semantics.
5023
5024 [[dec-val-type]] The types of values are:
5025
5026 [%header%autowidth,cols="a,a"]
5027 |===
5028 |Value type |Possible values
5029
5030 |Nil
5031 |None.
5032
5033 |Boolean
5034 |_True_ or _false_.
5035
5036 |Unsigned/signed integer
5037 |Integral quantity.
5038
5039 |Real
5040 |Continuous quantity.
5041
5042 |String
5043 |<<seq-def,Sequence>> of https://home.unicode.org/[Unicode] characters.
5044
5045 |Array
5046 |Sequence of values.
5047
5048 |Structure
5049 |Sequence of named values (members).
5050 |===
5051
5052 To decode an instance of a field class{nbsp}{var-f}, depending on the
5053 value of its `type` property:
5054
5055 [%header%autowidth,cols="a,a"]
5056 |===
5057 |Value of the `type` property of{nbsp}{var-f} |Decoding procedure of {var-f}
5058
5059 |<<fl-ba-fc,`"fixed-length-bit-array"`>>
5060 |<<fl-ba-field-dec,Decode a {fl-ba} field>>.
5061
5062 |<<fl-bool-fc,`"fixed-length-boolean"`>>
5063 |<<fl-bool-field-dec,Decode a {fl-bool} field>>.
5064
5065 |
5066 * <<fl-int-fc,`"fixed-length-unsigned-integer"`>>
5067 * <<fl-enum-fc,`"fixed-length-unsigned-enumeration"`>>
5068 |<<fl-uint-field-dec,Decode a {fl-uint} field>>.
5069
5070 |
5071 * <<fl-int-fc,`"fixed-length-signed-integer"`>>
5072 * <<fl-enum-fc,`"fixed-length-signed-enumeration"`>>
5073 |<<fl-sint-field-dec,Decode a {fl-sint} field>>.
5074
5075 |<<fl-fp-fc,`"fixed-length-floating-point-number"`>>
5076 |<<fl-fp-field-dec,Decode a {fl-fp} field>>.
5077
5078 |<<vl-ba-fc,`"variable-length-bit-array"`>>
5079 |<<vl-ba-field-dec,Decode a {vl-ba} field>>.
5080
5081 |
5082 * <<vl-int-fc,`"variable-length-unsigned-integer"`>>
5083 * <<vl-enum-fc,`"variable-length-unsigned-enumeration"`>>
5084 |<<vl-uint-field-dec,Decode a {vl-uint} field>>.
5085
5086 |
5087 * <<vl-int-fc,`"variable-length-signed-integer"`>>
5088 * <<vl-enum-fc,`"variable-length-signed-enumeration"`>>
5089 |<<vl-sint-field-dec,Decode a {vl-sint}>>.
5090
5091 |<<str-fc,`"null-terminated-string"`>>
5092 |<<str-field-dec,Decode a {str} field>>.
5093
5094 |<<sl-str-fc,`"static-length-string"`>>
5095 |<<sl-str-field-dec,Decode a {sl-str} field>>.
5096
5097 |<<sl-blob-fc,`"static-length-blob"`>>
5098 |<<sl-blob-field-dec,Decode a {sl-blob} field>>.
5099
5100 |<<dl-str-fc,`"dynamic-length-string"`>>
5101 |<<dl-str-field-dec,Decode a {dl-str} field>>.
5102
5103 |<<dl-blob-fc,`"dynamic-length-blob"`>>
5104 |<<dl-blob-field-dec,Decode a {dl-blob} field>>.
5105
5106 |<<struct-fc,`"structure"`>>
5107 |<<struct-field-dec,Decode a structure field>>.
5108
5109 |<<sl-array-fc,`"static-length-array"`>>
5110 |<<sl-array-field-dec,Decode a {sl-array} field>>.
5111
5112 |<<dl-array-fc,`"dynamic-length-array"`>>
5113 |<<dl-array-field-dec,Decode a {dl-array} field>>.
5114
5115 |<<opt-fc,`"optional"`>>
5116 |<<opt-field-dec,Decode an optional field>>.
5117
5118 |<<var-fc,`"variant"`>>
5119 |<<var-field-dec,Decode a variant field>>.
5120 |===
5121
5122 [[align-dec]]
5123 ==== Alignment procedure
5124
5125 The decoding procedure of many fields require
5126 {var-dec-o-minus-po} to have a specific _alignment_.
5127
5128 The alignment _requirement_ of an instance of a <<fc,field
5129 class>>{nbsp}{var-f} is, depending on the value of its `type` property:
5130
5131 [%header,cols="a,a"]
5132 |===
5133 |`type` property of {var-f} |Alignment requirement of {var-f}
5134
5135 |
5136 * <<fl-ba-fc,`"fixed-length-bit-array"`>>
5137 * <<fl-bool-fc,`"fixed-length-boolean"`>>
5138 * <<fl-int-fc,`"fixed-length-unsigned-integer"`>>
5139 * <<fl-int-fc,`"fixed-length-signed-integer"`>>
5140 * <<fl-enum-fc,`"fixed-length-unsigned-enumeration"`>>
5141 * <<fl-enum-fc,`"fixed-length-signed-enumeration"`>>
5142 * <<fl-fp-fc,`"fixed-length-floating-point-number"`>>
5143 |The value of the `alignment` property of{nbsp}{var-f}.
5144
5145 |
5146 * <<vl-ba-fc,`"variable-length-bit-array"`>>
5147 * <<vl-int-fc,`"variable-length-unsigned-integer"`>>
5148 * <<vl-int-fc,`"variable-length-signed-integer"`>>
5149 * <<vl-enum-fc,`"variable-length-unsigned-enumeration"`>>
5150 * <<vl-enum-fc,`"variable-length-signed-enumeration"`>>
5151 * <<str-fc,`"null-terminated-string"`>>
5152 * <<sl-str-fc,`"static-length-string"`>>
5153 * <<sl-blob-fc,`"static-length-blob"`>>
5154 * <<dl-str-fc,`"dynamic-length-string"`>>
5155 * <<dl-blob-fc,`"dynamic-length-blob"`>>
5156 |8
5157
5158 |<<struct-fc,`"structure"`>>
5159 |The _maximum_ value of:
5160
5161 * The value of the `minimum-alignment` property of{nbsp}{var-f}.
5162
5163 * The alignment requirements of the instances of the `field-class`
5164 property of each <<struct-member-cls,member class>> of the
5165 `member-classes` property of{nbsp}{var-f}.
5166
5167 |
5168 * <<sl-array-fc,`"static-length-array"`>>
5169 * <<dl-array-fc,`"dynamic-length-array"`>>
5170 |The _maximum_ value of:
5171
5172 * The value of the `minimum-alignment` property of{nbsp}{var-f}.
5173
5174 * The alignment requirement of an instance of the
5175 `element-field-class` property of{nbsp}{var-f}.
5176
5177 |
5178 * <<opt-fc,`"optional"`>>
5179 * <<var-fc,`"variant"`>>
5180 |1
5181 |===
5182
5183 To align {var-dec-o-minus-po} to some alignment
5184 requirement{nbsp}__**A**__ (bits):
5185
5186 * Set {var-dec-o} to
5187 {var-dec-po}{nbsp}pass:[+]{nbsp}(({var-dec-o-minus-po}{nbsp}pass:[+]{nbsp}__**A**__{nbsp}{minus}{nbsp}1){nbsp}&{nbsp}{minus}__**A**__),
5188 where "`&`" is the bitwise _AND_ operator.
5189
5190 [[field-loc-dec]]
5191 ==== Field location procedure
5192
5193 To locate a previously decoded field using a
5194 <<field-loc,field location>>{nbsp}__**FL**__:
5195
5196 . Let {var-v} be, depending on the first element of{nbsp}__**FL**__:
5197 +
5198 --
5199 `"packet-header"`::
5200 The <<pkt-header,header>> structure of{nbsp}__**P**__
5201 (<<pkt-dec,current packet>>).
5202
5203 `"packet-context"`::
5204 The <<pkt-ctx,context>> structure of{nbsp}__**P**__.
5205
5206 `"event-record-header"`::
5207 The <<er-header,header>> structure of{nbsp}__**E**__
5208 (<<er-dec,current event record>>).
5209
5210 `"event-record-common-context"`::
5211 The <<er-common-ctx,common context>> structure of{nbsp}__**E**__.
5212
5213 `"event-record-specific-context"`::
5214 The <<er-spec-ctx,specific context>> structure of{nbsp}__**E**__.
5215
5216 `"event-record-payload"`::
5217 The <<er-payload,payload>> structure of{nbsp}__**E**__.
5218 --
5219 +
5220 If the consumer cannot set {var-v} because there's no such structure or
5221 because it's not already decoded nor currently being decoded, then
5222 report an error and abort the data stream decoding process.
5223
5224 . For each element{nbsp}__**FLE**__ of{nbsp}__**FL**__, starting from
5225 the second element:
5226
5227 .. Let {var-v} be the value of the member named{nbsp}__**FLE**__
5228 within{nbsp}{var-v}.
5229 +
5230 If no member is named{nbsp}__**FLE**__ within{nbsp}{var-v}, then
5231 report an error and abort the data stream decoding process.
5232 +
5233 If the member named{nbsp}__**FLE**__ within{nbsp}{var-v} is not already
5234 decoded nor currently being decoded, then report an error and abort
5235 the data stream decoding process.
5236
5237 .. Depending on the <<dec-val-type,type>> of {var-v}:
5238 +
5239 --
5240 Boolean::
5241 Signed integer::
5242 Unsigned integer::
5243 If{nbsp}__**FLE**__ is not the last element of{nbsp}__**FL**__,
5244 then report an error and abort the data stream decoding process.
5245
5246 Structure::
5247 Continue.
5248
5249 Array::
5250 While {var-v} is an array:
5251 +
5252 * If {var-v} is not currently being decoded, then report an error and
5253 abort the data stream decoding process.
5254 +
5255 Set {var-v} to the element of {var-v} currently being decoded.
5256
5257 Other::
5258 Report an error and abort the data stream decoding process.
5259 --
5260
5261 {var-v} is the located field.
5262
5263 .<<dl-array,{c-dl-array}>> field and its length field in the same root field.
5264 ====
5265 Assume the following JSON object is an event record payload {struct-fc}.
5266
5267 [source,json]
5268 ----
5269 {
5270 "type": "structure",
5271 "member-classes": [
5272 {
5273 "name": "corn", <3>
5274 "field-class": {
5275 "type": "fixed-length-unsigned-integer",
5276 "length": 32,
5277 "byte-order": "little-endian"
5278 }
5279 },
5280 {
5281 "name": "inside",
5282 "field-class": {
5283 "type": "fixed-length-unsigned-integer",
5284 "length": 16,
5285 "byte-order": "little-endian"
5286 }
5287 },
5288 {
5289 "name": "carbon",
5290 "field-class": {
5291 "type": "dynamic-length-array", <1>
5292 "length-field-location": ["event-record-payload", "corn"], <2>
5293 "element-field-class": {
5294 "type": "null-terminated-string"
5295 }
5296 }
5297 }
5298 ]
5299 }
5300 ----
5301 <1> {c-dl-array-fc}.
5302 <2> Length field location of the {dl-array-fc}.
5303 <3> Length member class.
5304 ====
5305
5306 .{c-dl-array} field and its length field in the same root field, within the same array field element.
5307 ====
5308 Assume the following JSON object is an event record payload {struct-fc}.
5309
5310 Both the {dl-array} field and its length field exist within the same
5311 element of the <<sl-array-fc,{sl-array}>> field named `nature`.
5312
5313 [source,json]
5314 ----
5315 {
5316 "type": "structure",
5317 "member-classes": [
5318 {
5319 "name": "norm",
5320 "field-class": {
5321 "type": "null-terminated-string"
5322 }
5323 },
5324 {
5325 "name": "nature",
5326 "field-class": {
5327 "type": "static-length-array",
5328 "length": 43,
5329 "element-field-class": {
5330 "type": "structure",
5331 "member-classes": [
5332 {
5333 "name": "laser", <3>
5334 "field-class": {
5335 "type": "variable-length-unsigned-integer"
5336 }
5337 },
5338 {
5339 "name": "joystick",
5340 "field-class": {
5341 "type": "dynamic-length-array", <1>
5342 "length-field-location": [ <2>
5343 "event-record-payload",
5344 "nature",
5345 "laser"
5346 ],
5347 "element-field-class": {
5348 "type": "null-terminated-string"
5349 }
5350 }
5351 }
5352 ]
5353 }
5354 }
5355 }
5356 ]
5357 }
5358 ----
5359 <1> {c-dl-array-fc}.
5360 <2> Length field location of the {dl-array-fc}.
5361 <3> Length member class.
5362 ====
5363
5364 .{c-dl-array} and its length field in the same root field, within the same <<var-fc,variant>> field.
5365 ====
5366 Assume the following JSON object is an event record payload {struct-fc}.
5367
5368 Both the {dl-array} field and its length field exist within the same
5369 option of the <<var-fc,variant>> field named `clinic`.
5370
5371 Moreover, the selector field of the `clinic` variant field is the
5372 `lawyer` field.
5373
5374 [source,json]
5375 ----
5376 {
5377 "type": "structure",
5378 "member-classes": [
5379 {
5380 "name": "lawyer", <5>
5381 "field-class": {
5382 "type": "fixed-length-signed-integer",
5383 "length": 16,
5384 "byte-order": "little-endian"
5385 }
5386 },
5387 {
5388 "name": "clinic",
5389 "field-class": {
5390 "type": "variant",
5391 "selector-field-location": ["event-record-payload", "lawyer"], <4>
5392 "options": [
5393 {
5394 "selector-field-ranges": [[0, 0]],
5395 "field-class": {
5396 "type": "null-terminated-string"
5397 }
5398 },
5399 {
5400 "selector-field-ranges": [[1, 4]],
5401 "field-class": {
5402 "type": "structure",
5403 "member-classes": [
5404 {
5405 "name": "lemon", <3>
5406 "field-class": {
5407 "type": "fixed-length-unsigned-integer",
5408 "length": 8,
5409 "byte-order": "big-endian"
5410 }
5411 },
5412 {
5413 "name": "joystick",
5414 "field-class": {
5415 "type": "dynamic-length-array", <1>
5416 "length-field-location": [ <2>
5417 "event-record-payload",
5418 "clinic",
5419 "lemon"
5420 ],
5421 "element-field-class": {
5422 "type": "null-terminated-string"
5423 }
5424 }
5425 }
5426 ]
5427 }
5428 },
5429 {
5430 "selector-field-ranges": [[5, 5], [7, 7]],
5431 "field-class": {
5432 "type": "fixed-length-boolean",
5433 "length": 8,
5434 "byte-order": "little-endian"
5435 }
5436 }
5437 ]
5438 }
5439 }
5440 ]
5441 }
5442 ----
5443 <1> {c-dl-array-fc}.
5444 <2> Length field location of the {dl-array-fc}.
5445 <3> Length member class.
5446 <4> Selector field location of the variant field class.
5447 <5> Selector member class.
5448 ====
5449
5450 .{c-dl-array} and its length field in the same root field; length field is a variant field.
5451 ====
5452 Assume the following JSON object is an event record payload {struct-fc}.
5453
5454 The length field of the {dl-array} field is a variant field: it can be
5455 an 8-bit, a 16-bit, or a 32-bit <<fl-int-fc,{fl-int}>> field, depending
5456 on the selection of the variant field.
5457
5458 Moreover, the selector field of the variant field is located in another
5459 root field (event record specific context).
5460
5461 [source,json]
5462 ----
5463 {
5464 "type": "structure",
5465 "member-classes": [
5466 {
5467 "name": "glass", <3>
5468 "field-class": {
5469 "type": "variant",
5470 "selector-field-location": ["event-record-specific-context", "sel"],
5471 "options": [
5472 {
5473 "selector-field-ranges": [[0, 0]],
5474 "field-class": {
5475 "type": "fixed-length-unsigned-integer", <4>
5476 "length": 8,
5477 "byte-order": "little-endian"
5478 }
5479 },
5480 {
5481 "selector-field-ranges": [[1, 1]],
5482 "field-class": {
5483 "type": "fixed-length-unsigned-integer", <4>
5484 "length": 16,
5485 "byte-order": "little-endian"
5486 }
5487 },
5488 {
5489 "selector-field-ranges": [[2, 2]],
5490 "field-class": {
5491 "type": "fixed-length-unsigned-integer", <4>
5492 "length": 32,
5493 "byte-order": "little-endian"
5494 }
5495 }
5496 ]
5497 }
5498 },
5499 {
5500 "name": "margin",
5501 "field-class": {
5502 "type": "dynamic-length-array", <1>
5503 "length-field-location": ["event-record-payload", "glass"], <2>
5504 "element-field-class": {
5505 "type": "null-terminated-string"
5506 }
5507 }
5508 }
5509 ]
5510 }
5511 ----
5512 <1> {c-dl-array-fc}.
5513 <2> Length field location of the {dl-array-fc}.
5514 <3> Length member class.
5515 <4> Possible length field class.
5516 ====
5517
5518 .{c-dl-array} and its length field in the same root field; structure field containing length field is a variant field.
5519 ====
5520 Assume the following JSON object is an event record payload {struct-fc}.
5521
5522 The length field of the {dl-array} field is within a structure field
5523 which is a variant field.
5524
5525 Moreover:
5526
5527 * The selector field of the variant field is located in another root
5528 field (event record common context).
5529
5530 * The field class of the third option of the `glass` variant field class
5531 contains a {dl-blob-fc} (`lock` member); the
5532 length field of its instance is the previous member (`eagle`) within
5533 the same structure field.
5534
5535 [source,json]
5536 ----
5537 {
5538 "type": "structure",
5539 "member-classes": [
5540 {
5541 "name": "glass",
5542 "field-class": {
5543 "type": "variant",
5544 "selector-field-location": ["event-record-common-context", "sel"],
5545 "options": [
5546 {
5547 "selector-field-ranges": [[0, 0]],
5548 "field-class": {
5549 "type": "structure",
5550 "member-classes": [
5551 {
5552 "name": "eagle",
5553 "field-class": {
5554 "type": "fixed-length-unsigned-integer", <3>
5555 "length": 16,
5556 "byte-order": "little-endian"
5557 }
5558 },
5559 {
5560 "name": "road",
5561 "field-class": {
5562 "type": "null-terminated-string"
5563 }
5564 }
5565 ]
5566 }
5567 },
5568 {
5569 "selector-field-ranges": [[32, 172]],
5570 "field-class": {
5571 "type": "structure",
5572 "member-classes": [
5573 {
5574 "name": "nuance",
5575 "field-class": {
5576 "type": "null-terminated-string"
5577 }
5578 },
5579 {
5580 "name": "eagle",
5581 "field-class": {
5582 "type": "fixed-length-unsigned-integer", <3>
5583 "length": 24,
5584 "byte-order": "big-endian"
5585 }
5586 }
5587 ]
5588 }
5589 },
5590 {
5591 "selector-field-ranges": [[5, 5]],
5592 "field-class": {
5593 "type": "structure",
5594 "member-classes": [
5595 {
5596 "name": "eagle", <5>
5597 "field-class": {
5598 "type": "variable-length-unsigned-integer" <3>
5599 }
5600 },
5601 {
5602 "name": "lock",
5603 "field-class": {
5604 "type": "dynamic-length-blob",
5605 "length-field-location": [ <4>
5606 "event-record-payload",
5607 "glass",
5608 "eagle"
5609 ]
5610 }
5611 }
5612 ]
5613 }
5614 }
5615 ]
5616 }
5617 },
5618 {
5619 "name": "margin",
5620 "field-class": {
5621 "type": "dynamic-length-array", <1>
5622 "length-field-location": [ <2>
5623 "event-record-payload",
5624 "glass",
5625 "eagle"
5626 ],
5627 "element-field-class": {
5628 "type": "null-terminated-string"
5629 }
5630 }
5631 }
5632 ]
5633 }
5634 ----
5635 <1> {c-dl-array-fc}.
5636 <2> Length field location of the {dl-array-fc}.
5637 <3> Possible length field class.
5638 <4> Length field location of the {dl-blob-fc}.
5639 <5> Length field class for the {dl-blob-fc}.
5640
5641 Note that both the {dl-array} and {dl-blob} field classes have the same
5642 length field location.
5643 ====
5644
5645 .{c-dl-array} and its length field in another root field.
5646 ====
5647 Assume the following JSON objects are the event record specific context
5648 and payload <<struct-fc,structure field classes>> of the same
5649 <<erc-frag,event record class>>.
5650
5651 The length field of the {dl-array} field of the event record payload is
5652 within the event record specific context.
5653
5654 .Event record specific context field class.
5655 [source,json]
5656 ----
5657 {
5658 "type": "structure",
5659 "member-classes": [
5660 {
5661 "name": "cook",
5662 "field-class": {
5663 "type": "fixed-length-floating-point-number",
5664 "length": 64,
5665 "byte-order": "little-endian"
5666 }
5667 },
5668 {
5669 "name": "vegetable", <1>
5670 "field-class": {
5671 "type": "variable-length-unsigned-integer"
5672 }
5673 }
5674 ]
5675 }
5676 ----
5677 <1> Length member class.
5678
5679 .Event record payload field class.
5680 [source,json]
5681 ----
5682 {
5683 "type": "structure",
5684 "member-classes": [
5685 {
5686 "name": "avenue",
5687 "field-class": {
5688 "type": "dynamic-length-array", <1>
5689 "length-field-location": [ <2>
5690 "event-record-specific-context",
5691 "vegetable"
5692 ],
5693 "element-field-class": {
5694 "type": "null-terminated-string"
5695 }
5696 }
5697 },
5698 {
5699 "name": "railroad",
5700 "field-class": {
5701 "type": "null-terminated-string"
5702 }
5703 }
5704 ]
5705 }
5706 ----
5707 <1> {c-dl-array-fc}.
5708 <2> Length field location of the {dl-array-fc}.
5709 ====
5710
5711 [[fl-ba-field-dec]]
5712 ==== {c-fl-ba} field decoding procedure
5713
5714 For this whole section about decoding an instance of a
5715 {fl-ba-fc}{nbsp}{var-f}, let _**BO**_ be the value of the `byte-order`
5716 property of{nbsp}{var-f}.
5717
5718 [[fl-ba-field-dec-bit]] To read a single data stream bit from an
5719 instance of{nbsp}{var-f}:
5720
5721 . Let:
5722
5723 ** _**BYTE_I**_ be ({var-dec-o-minus-po}){nbsp}/{nbsp}8 (integral
5724 division; remainder discarded).
5725
5726 ** _**BIT_I**_ be:
5727 +
5728 --
5729 [horizontal]
5730 _**BO**_ is `"big-endian"`::
5731 7{nbsp}{minus}{nbsp}(({var-dec-o-minus-po}){nbsp}mod{nbsp}8)
5732
5733 _**BO**_ is `"little-endian"`::
5734 ({var-dec-o-minus-po}){nbsp}mod{nbsp}8
5735 --
5736
5737 . Depending on the value of the bit at the index{nbsp}__**BIT_I**__,
5738 where{nbsp}0 is the index of the
5739 https://en.wikipedia.org/wiki/Bit_numbering#Least_significant_bit[least significant bit],
5740 within the byte at the index{nbsp}__**BYTE_I**__ from the beginning
5741 of{nbsp}__**P**__ (the current packet being decoded):
5742 +
5743 --
5744 [horizontal]
5745 0::
5746 The bit value is _false_.
5747
5748 1::
5749 The bit value is _true_.
5750 --
5751
5752 To decode an instance of{nbsp}{var-f}:
5753
5754 . Let:
5755
5756 .. _**L**_ be the value of the `length` property of{nbsp}{var-f}.
5757 .. {var-v} be an array of booleans of length{nbsp}__**L**__.
5758 .. _**I**_ be an unsigned integer initialized to{nbsp}0.
5759
5760 . <<align-dec,Align {var-dec-o-minus-po}>> according
5761 to{nbsp}{var-f}.
5762
5763 . [[fl-ba-field-dec-step-3]] If
5764 (({var-dec-o-minus-po}){nbsp}mod{nbsp}8{nbsp}{noteq}{nbsp}0) and
5765 __**LAST_BO**__{nbsp}{noteq}{nbsp}__**BO**__, then report an error
5766 and abort the data stream decoding process.
5767
5768 . While __**I**__{nbsp}<{nbsp}__**L**__:
5769
5770 .. Let _**VI**_ be an unsigned integer initialized to:
5771 +
5772 [horizontal]
5773 _**BO**_ is `"big-endian"`::
5774 0
5775
5776 _**BO**_ is `"little-endian"`::
5777 __**L**__{nbsp}{minus}{nbsp}__**I**__{nbsp}{minus}{nbsp}1
5778
5779 .. Set the element at the index{nbsp}__**VI**__ of{nbsp}{var-v}
5780 to the current <<fl-ba-field-dec-bit,single bit value>>.
5781
5782 .. Set __**I**__ to __**I**__{nbsp}+{nbsp}1.
5783
5784 .. Set {var-dec-o} to {var-dec-o}{nbsp}+{nbsp}1.
5785
5786 . Set _**LAST_BO**_ to{nbsp}__**BO**__.
5787
5788 {var-v} is the decoded bit array value.
5789
5790 To add to the decoding procedure above, note that the "`reading
5791 direction`" within a byte depends on{nbsp}__**BO**__. Assuming
5792 {var-dec-o-minus-po}{nbsp}={nbsp}0, the following diagrams show which
5793 bit is selected by {var-dec-o-minus-po} within a 16-bit {fl-ba} field
5794 depending on{nbsp}__**BO**__:
5795
5796 `"big-endian"`:: {empty}
5797 +
5798 image::{doc-id}-images/bit-array-decoding-be.svg[]
5799
5800 `"little-endian"`:: {empty}
5801 +
5802 image::{doc-id}-images/bit-array-decoding-le.svg[]
5803
5804 .Contiguous {fl-ba} fields: big-endian versus little-endian.
5805 ====
5806 This example shows the binary layout of contiguous big-endian and
5807 little-endian {fl-ba} fields.
5808
5809 Assume that {var-dec-o-minus-po}{nbsp}={nbsp}16. All the {fl-ba}
5810 fields of this example have an implicit 1-bit <<align-dec,aligment
5811 requirement>>.
5812
5813 Considering the following <<struct-member-cls,member classes>> of some
5814 {struct-fc}:
5815
5816 [source,json]
5817 ----
5818 [
5819 {
5820 "name": "green",
5821 "field-class": {
5822 "type": "fixed-length-bit-array",
5823 "length": 3,
5824 "byte-order": "big-endian"
5825 }
5826 },
5827 {
5828 "name": "blue",
5829 "field-class": {
5830 "type": "fixed-length-bit-array",
5831 "length": 9,
5832 "byte-order": "big-endian"
5833 }
5834 },
5835 {
5836 "name": "yellow",
5837 "field-class": {
5838 "type": "fixed-length-bit-array",
5839 "length": 14,
5840 "byte-order": "big-endian"
5841 }
5842 },
5843 {
5844 "name": "red",
5845 "field-class": {
5846 "type": "fixed-length-bit-array",
5847 "length": 4,
5848 "byte-order": "big-endian"
5849 }
5850 }
5851 ]
5852 ----
5853
5854 The binary layout is as such:
5855
5856 image::{doc-id}-images/bit-array-fields-be.svg[]
5857
5858 Considering the following member classes of some structure field class,
5859 the only difference with the previous sample being the values of the
5860 `byte-order` property:
5861
5862 [source,json]
5863 ----
5864 [
5865 {
5866 "name": "green",
5867 "field-class": {
5868 "type": "fixed-length-bit-array",
5869 "length": 3,
5870 "byte-order": "little-endian"
5871 }
5872 },
5873 {
5874 "name": "blue",
5875 "field-class": {
5876 "type": "fixed-length-bit-array",
5877 "length": 9,
5878 "byte-order": "little-endian"
5879 }
5880 },
5881 {
5882 "name": "yellow",
5883 "field-class": {
5884 "type": "fixed-length-bit-array",
5885 "length": 14,
5886 "byte-order": "little-endian"
5887 }
5888 },
5889 {
5890 "name": "red",
5891 "field-class": {
5892 "type": "fixed-length-bit-array",
5893 "length": 4,
5894 "byte-order": "little-endian"
5895 }
5896 }
5897 ]
5898 ----
5899
5900 The binary layout is as such:
5901
5902 image::{doc-id}-images/bit-array-fields-le.svg[]
5903 ====
5904
5905 .Padding between {fl-ba} fields.
5906 ====
5907 This example shows how the <<align-dec,alignment requirement>> of a
5908 {fl-ba} field can translate into padding bits to skip during the
5909 decoding process.
5910
5911 Assume that {var-dec-o-minus-po}{nbsp}={nbsp}32.
5912
5913 Considering the following <<struct-member-cls,member classes>> of some
5914 {struct-fc}:
5915
5916 [source,json]
5917 ----
5918 [
5919 {
5920 "name": "green",
5921 "field-class": {
5922 "type": "fixed-length-bit-array",
5923 "length": 5,
5924 "byte-order": "big-endian"
5925 }
5926 },
5927 {
5928 "name": "blue",
5929 "field-class": {
5930 "type": "fixed-length-bit-array",
5931 "length": 3,
5932 "byte-order": "big-endian",
5933 "alignment": 8
5934 }
5935 },
5936 {
5937 "name": "yellow",
5938 "field-class": {
5939 "type": "fixed-length-bit-array",
5940 "length": 4,
5941 "byte-order": "big-endian",
5942 "alignment": 4
5943 }
5944 }
5945 ]
5946 ----
5947
5948 The binary layout is as such:
5949
5950 image::{doc-id}-images/bit-array-fields-padding-be.svg[]
5951
5952 Considering the following member classes of some structure field class,
5953 the only difference with the previous sample being the values of the
5954 `byte-order` property:
5955
5956 [source,json]
5957 ----
5958 [
5959 {
5960 "name": "green",
5961 "field-class": {
5962 "type": "fixed-length-bit-array",
5963 "length": 5,
5964 "byte-order": "little-endian"
5965 }
5966 },
5967 {
5968 "name": "blue",
5969 "field-class": {
5970 "type": "fixed-length-bit-array",
5971 "length": 3,
5972 "byte-order": "little-endian",
5973 "alignment": 8
5974 }
5975 },
5976 {
5977 "name": "yellow",
5978 "field-class": {
5979 "type": "fixed-length-bit-array",
5980 "length": 4,
5981 "byte-order": "little-endian",
5982 "alignment": 4
5983 }
5984 }
5985 ]
5986 ----
5987
5988 The binary layout is as such:
5989
5990 image::{doc-id}-images/bit-array-fields-padding-le.svg[]
5991 ====
5992
5993 .Contiguous {fl-ba} fields with different byte orders.
5994 ====
5995 <<fl-ba-field-dec-step-3,Step{nbsp}3>> of the decoding procedure above
5996 requires that a <<consumer-def,consumer>> stops the data stream decoding
5997 process if the byte order between two contiguous {fl-ba} fields changes
5998 when{nbsp}{var-dec-o-minus-po} is not a mutliple of{nbsp}8.
5999
6000 In other words, a given data stream <<byte-def,byte>> {must-not} contain
6001 bits of two {fl-ba} fields having different byte orders.
6002
6003 This example shows how contiguous {fl-ba} fields may have different byte
6004 orders with correct <<align-dec,alignment>>.
6005
6006 Assume that {var-dec-o-minus-po}{nbsp}={nbsp}16.
6007
6008 Considering the following <<struct-member-cls,member classes>> of some
6009 {struct-fc}:
6010
6011 [source,json]
6012 ----
6013 [
6014 {
6015 "name": "green",
6016 "field-class": {
6017 "type": "fixed-length-bit-array",
6018 "length": 3,
6019 "byte-order": "big-endian"
6020 }
6021 },
6022 {
6023 "name": "blue",
6024 "field-class": {
6025 "type": "fixed-length-bit-array",
6026 "length": 5,
6027 "byte-order": "big-endian"
6028 }
6029 },
6030 {
6031 "name": "yellow",
6032 "field-class": {
6033 "type": "fixed-length-bit-array",
6034 "length": 5,
6035 "byte-order": "little-endian"
6036 }
6037 },
6038 {
6039 "name": "orange",
6040 "field-class": {
6041 "type": "fixed-length-bit-array",
6042 "length": 8,
6043 "byte-order": "little-endian"
6044 }
6045 },
6046 {
6047 "name": "red",
6048 "field-class": {
6049 "type": "fixed-length-bit-array",
6050 "length": 6,
6051 "byte-order": "big-endian",
6052 "alignment": 8
6053 }
6054 }
6055 ]
6056 ----
6057
6058 The binary layout is as such:
6059
6060 image::{doc-id}-images/bit-array-fields-be-le.svg[]
6061 ====
6062
6063 [[fl-bool-field-dec]]
6064 ==== {c-fl-bool} field decoding procedure
6065
6066 To decode an instance of a {fl-bool-fc}:
6067
6068 . Let __**VB**__ be a boolean.
6069 . <<fl-ba-field-dec,Decode the instance as a {fl-ba} field>>.
6070 . If all the elements of{nbsp}{var-v} are _false_, then set{nbsp}__**VB**__
6071 to _false_.
6072 +
6073 Else, set __**VB**__ to _true_.
6074
6075 _**VB**_ is the decoded boolean value.
6076
6077 [[fl-uint-field-dec]]
6078 ==== {c-fl-uint} field decoding procedure
6079
6080 To decode an instance of a {fl-uint-fc}:
6081
6082 . Let __**VI**__ be an unsigned integer.
6083 . <<fl-ba-field-dec,Decode the instance as a {fl-ba} field>>.
6084 . Set __**VI**__ as the unsigned integer interpretation
6085 of{nbsp}{var-v}, where the first element of{nbsp}{var-v} is the most
6086 significant bit.
6087
6088 _**VI**_ is the decoded unsigned integer value.
6089
6090 [[fl-sint-field-dec]]
6091 ==== {c-fl-sint} field decoding procedure
6092
6093 To decode an instance of a {fl-sint-fc}:
6094
6095 . Let __**VI**__ be a signed integer.
6096 . <<fl-ba-field-dec,Decode the instance as a {fl-ba} field>>.
6097 . Set __**VI**__ as the signed integer interpretation, following the
6098 two's complement format, of{nbsp}{var-v}, where the first element
6099 of{nbsp}{var-v} is the most significant bit.
6100
6101 _**VI**_ is the decoded signed integer value.
6102
6103 [[fl-fp-field-dec]]
6104 ==== {c-fl-fp} field decoding procedure
6105
6106 To decode an instance of a {fl-fp-fc}:
6107
6108 . Let __**VR**__ be a real value.
6109 . <<fl-ba-field-dec,Decode the instance as a {fl-ba} field>>.
6110 . Set __**VR**__ to the real number interpretation, following the
6111 {ieee754}, of{nbsp}{var-v}, where the first element of{nbsp}{var-v} is
6112 the most significant bit.
6113
6114 _**VR**_ is the decoded real value.
6115
6116 [[vl-ba-field-dec]]
6117 ==== {c-vl-ba} field decoding procedure
6118
6119 To decode an instance of a {vl-ba-fc}{nbsp}{var-f}:
6120
6121 . Let {var-v} be an empty array of booleans.
6122
6123 . <<align-dec,Align {var-dec-o-minus-po}>> according
6124 to{nbsp}{var-f}.
6125
6126 . Read __**N**__{nbsp}bytes of data from{nbsp}{var-s} at the
6127 offset{nbsp}{var-dec-o}, as many as needed following the unsigned
6128 https://en.wikipedia.org/wiki/LEB128[LEB128] format, appending the
6129 decoded bits to{nbsp}{var-v} as booleans from the most
6130 significant to the least significant.
6131
6132 . Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}__**N**__{nbsp}{times}{nbsp}8.
6133
6134 {var-v} is the decoded value.
6135
6136 .3-byte {vl-ba} field decoding.
6137 ====
6138 Consider the following {vl-ba-fc}{nbsp}{var-f}:
6139
6140 [source,json]
6141 ----
6142 {
6143 "type": "variable-length-bit-array"
6144 }
6145 ----
6146
6147 The following diagram shows the three bytes of an instance
6148 of{nbsp}{var-f} and the resulting bit array value.
6149
6150 image::{doc-id}-images/vl-ba.svg[]
6151
6152 Note that the data bits of the last byte (in red) become the first
6153 elements of the resulting bit array value because LEB128 is a
6154 little-endian encoding.
6155 ====
6156
6157 [[vl-uint-field-dec]]
6158 ==== {c-vl-uint} field decoding procedure
6159
6160 To decode an instance of a {vl-uint-fc}:
6161
6162 . Let __**VI**__ be an unsigned integer.
6163 . <<vl-ba-field-dec,Decode the instance as a {vl-ba} field>>.
6164 . Set __**VI**__ as the unsigned integer interpretation of{nbsp}{var-v},
6165 where the first element of{nbsp}{var-v} is the most significant bit.
6166
6167 _**VI**_ is the decoded unsigned integer value.
6168
6169 [[vl-sint-field-dec]]
6170 ==== {c-vl-sint} field decoding procedure
6171
6172 To decode an instance of a {vl-sint-fc}:
6173
6174 . Let __**VI**__ be a signed integer.
6175 . <<vl-ba-field-dec,Decode the instance as a {vl-ba} field>>.
6176 . Set __**VI**__ as the signed integer interpretation, following the
6177 two's complement format, of{nbsp}{var-v}, where the first element
6178 of{nbsp}{var-v} is the most significant bit.
6179
6180 _**VI**_ is the decoded signed integer value.
6181
6182 [[str-field-dec]]
6183 ==== {c-str} field decoding procedure
6184
6185 To decode an instance of a {str-fc}{nbsp}{var-f}:
6186
6187 . Let:
6188 ** _**B**_ be a byte.
6189 ** _**A**_ be an empty sequence of bytes.
6190 ** {var-v} be a string.
6191
6192 . <<align-dec,Align {var-dec-o-minus-po}>> according
6193 to{nbsp}{var-f}.
6194
6195 . Read one byte of data from{nbsp}{var-s} at the offset{nbsp}{var-dec-o}
6196 as{nbsp}__**B**__.
6197
6198 . Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}8.
6199
6200 . While __**B**__{nbsp}{noteq}{nbsp}0:
6201 .. Append __**B**__ to{nbsp}__**A**__.
6202 .. Read one byte of data from{nbsp}{var-s} at the
6203 offset{nbsp}{var-dec-o} as{nbsp}__**B**__.
6204 .. Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}8.
6205
6206 . Decode _**A**_, following UTF-8, as {var-v}.
6207
6208 {var-v} is the decoded string value.
6209
6210 .22-byte {str} field decoding.
6211 ====
6212 Consider the following {str-fc}{nbsp}{var-f}:
6213
6214 [source,json]
6215 ----
6216 {
6217 "type": "null-terminated-string"
6218 }
6219 ----
6220
6221 The following diagram shows <<pkt,packet>> bytes including a 22-byte
6222 instance of{nbsp}{var-f} (in blue) and its resulting string value.
6223
6224 The offset of the {str} field, from the beginning of the packet,
6225 is 0xfc23{nbsp}bytes, which means
6226 {var-dec-o-minus-po}{nbsp}={nbsp}516,376.
6227
6228 image::{doc-id}-images/str.svg[]
6229
6230 The field contains 21{nbsp}UTF-8 bytes and a null terminating byte.
6231
6232 The resulting string value contains 19{nbsp}Unicode characters.
6233
6234 After the field is decoded, {var-dec-o-minus-po}{nbsp}={nbsp}516,552.
6235 ====
6236
6237 [[sl-str-field-dec]]
6238 ==== {c-sl-str} field decoding procedure
6239
6240 To decode an instance of a {sl-str-fc}{nbsp}{var-f}:
6241
6242 . Let:
6243 ** _**L**_ be the `length` property of{nbsp}{var-f}.
6244 ** _**I**_ be an unsigned integer initialized to 0.
6245 ** _**B**_ be a byte.
6246 ** _**R**_ be a boolean initialized to _true_.
6247 ** _**A**_ be an empty sequence of bytes.
6248 ** {var-v} be a string.
6249
6250 . <<align-dec,Align {var-dec-o-minus-po}>> according
6251 to{nbsp}{var-f}.
6252
6253 . While __**I**__{nbsp}<{nbsp}__**L**__:
6254
6255 .. Read one byte of data from{nbsp}{var-s} at the
6256 offset{nbsp}{var-dec-o} as{nbsp}__**B**__.
6257 .. If __**B**__{nbsp}={nbsp}0, then set _**R**_{nbsp}to _false_.
6258 +
6259 Else, if _**R**_ is _true_, then append{nbsp}__**B**__
6260 to{nbsp}__**A**__.
6261
6262 .. Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}8.
6263 .. Set _**I**_ to __**I**__{nbsp}pass:[+]{nbsp}1.
6264
6265 . Decode _**A**_, following UTF-8, as {var-v}.
6266
6267 {var-v} is the decoded string value.
6268
6269 .18-byte {sl-str} field decoding.
6270 ====
6271 Consider the following {str-fc}{nbsp}{var-f}:
6272
6273 [source,json]
6274 ----
6275 {
6276 "type": "static-length-string",
6277 "length": 18
6278 }
6279 ----
6280
6281 The following diagram shows <<pkt,packet>> bytes including a 18-byte
6282 instance of{nbsp}{var-f} (in green) and its resulting string value.
6283
6284 The offset of the {sl-str} field, from the beginning of the packet, is
6285 0x8c46{nbsp}bytes, which means {var-dec-o-minus-po}{nbsp}={nbsp}287,280.
6286
6287 image::{doc-id}-images/sl-str.svg[]
6288
6289 The field contains 14{nbsp}UTF-8 bytes, a null terminating byte,
6290 and three garbage data bytes to ignore.
6291
6292 The resulting string value contains seven Unicode characters.
6293
6294 After the field is decoded, {var-dec-o-minus-po}{nbsp}={nbsp}287,424.
6295 ====
6296
6297 [[sl-blob-field-dec]]
6298 ==== {c-sl-blob} field decoding procedure
6299
6300 To decode an instance of a {sl-blob-fc}{nbsp}{var-f}:
6301
6302 . Let:
6303 .. _**L**_ be the `length` property of{nbsp}{var-f}.
6304 .. {var-v} be an array of bytes of length{nbsp}__**L**__.
6305
6306 . <<align-dec,Align {var-dec-o-minus-po}>> according
6307 to{nbsp}{var-f}.
6308
6309 . Read _**L**_ bytes of data from{nbsp}{var-s} at the
6310 offset{nbsp}{var-dec-o} as{nbsp}{var-v}.
6311
6312 . Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}__**L**__{nbsp}{times}{nbsp}8.
6313
6314 {var-v} is the decoded BLOB value.
6315
6316 [[dl-str-field-dec]]
6317 ==== {c-dl-str} field decoding procedure
6318
6319 To decode an instance of a {dl-str-fc}{nbsp}{var-f}:
6320
6321 . Let:
6322 ** _**L**_ be the value of the previously decoded unsigned integer
6323 field of which the `length-field-location` property of{nbsp}{var-f}
6324 indicates the <<field-loc-dec,location>>.
6325 ** _**I**_ be an unsigned integer initialized to 0.
6326 ** _**B**_ be a byte.
6327 ** _**R**_ be a boolean initialized to _true_.
6328 ** _**A**_ be an empty sequence of bytes.
6329 ** {var-v} be a string.
6330
6331 . <<align-dec,Align {var-dec-o-minus-po}>> according
6332 to{nbsp}{var-f}.
6333
6334 . While __**I**__{nbsp}<{nbsp}__**L**__:
6335
6336 .. Read one byte of data from{nbsp}{var-s} at the
6337 offset{nbsp}{var-dec-o} as{nbsp}__**B**__.
6338 .. If __**B**__{nbsp}={nbsp}0, then set _**R**_{nbsp}to _false_.
6339 +
6340 Else, if _**R**_ is _true_, then append{nbsp}__**B**__
6341 to{nbsp}__**A**__.
6342
6343 .. Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}8.
6344 .. Set _**I**_ to __**I**__{nbsp}pass:[+]{nbsp}1.
6345
6346 . Decode _**A**_, following UTF-8, as {var-v}.
6347
6348 {var-v} is the decoded string value.
6349
6350 [[dl-blob-field-dec]]
6351 ==== {c-dl-blob} field decoding procedure
6352
6353 To decode an instance of a {dl-blob-fc}{nbsp}{var-f}:
6354
6355 . Let:
6356 .. _**L**_ be the value of the previously decoded unsigned integer
6357 field of which the `length-field-location` property of{nbsp}{var-f}
6358 indicates the <<field-loc-dec,location>>.
6359 .. {var-v} be an array of bytes of length{nbsp}__**L**__.
6360
6361 . <<align-dec,Align {var-dec-o-minus-po}>> according
6362 to{nbsp}{var-f}.
6363
6364 . Read _**L**_ bytes of data from{nbsp}{var-s} at the
6365 offset{nbsp}{var-dec-o} as{nbsp}{var-v}.
6366
6367 . Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}__**L**__{nbsp}{times}{nbsp}8.
6368
6369 {var-v} is the decoded BLOB value.
6370
6371 [[struct-field-dec]]
6372 ==== Structure field decoding procedure
6373
6374 To decode an instance of a {struct-fc}{nbsp}{var-f}:
6375
6376 . Let:
6377 ** _**M**_ be the `member-classes` property of{nbsp}{var-f}.
6378 ** {var-v} be an empty structure.
6379
6380 . <<align-dec,Align {var-dec-o-minus-po}>> according
6381 to{nbsp}{var-f}.
6382
6383 . For each member class{nbsp}__**MC**__ of{nbsp}__**M**__:
6384 .. Let:
6385 *** _**MF**_ be the `field-class` property of{nbsp}__**MC**__.
6386 *** _**MN**_ be the `name` property of{nbsp}__**MC**__.
6387 .. <<field-dec,Decode>> one instance of{nbsp}__**MF**__, appending the
6388 resulting value as a member of{nbsp}{var-v} named{nbsp}__**MN**__.
6389
6390 {var-v} is the decoded value.
6391
6392 [[sl-array-field-dec]]
6393 ==== {c-sl-array} field decoding procedure
6394
6395 To decode an instance of a {sl-array-fc}{nbsp}{var-f}:
6396
6397 . Let:
6398 .. _**L**_ be the `length` property of{nbsp}{var-f}.
6399 .. _**EF**_ be the `element-field-class` property of{nbsp}{var-f}.
6400 .. _**I**_ be an unsigned integer initialized to 0.
6401 .. {var-v} be an array of values of length{nbsp}__**L**__.
6402
6403 . <<align-dec,Align {var-dec-o-minus-po}>> according
6404 to{nbsp}{var-f}.
6405
6406 . While __**I**__{nbsp}<{nbsp}__**L**__:
6407 .. <<field-dec,Decode>> one instance of{nbsp}__**EF**__
6408 as element{nbsp}__**I**__ of{nbsp}{var-v}.
6409 .. Set _**I**_ to __**I**__{nbsp}pass:[+]{nbsp}1.
6410
6411 {var-v} is the decoded value.
6412
6413 [[dl-array-field-dec]]
6414 ==== {c-dl-array} field decoding procedure
6415
6416 To decode an instance of a {dl-array-fc}{nbsp}{var-f}:
6417
6418 . Let:
6419 .. _**L**_ be the value of the previously decoded unsigned integer field
6420 of which the `length-field-location` property of{nbsp}{var-f}
6421 indicates the <<field-loc-dec,location>>.
6422 .. _**EF**_ be the `element-field-class` property of{nbsp}{var-f}.
6423 .. _**I**_ be an unsigned integer initialized to 0.
6424 .. {var-v} be an array of values of length{nbsp}__**L**__
6425
6426 . <<align-dec,Align {var-dec-o-minus-po}>> according
6427 to{nbsp}{var-f}.
6428
6429 . While __**I**__{nbsp}<{nbsp}__**L**__:
6430 .. <<field-dec,Decode>> one instance of{nbsp}__**EF**__
6431 as element{nbsp}__**I**__ of{nbsp}{var-v}.
6432 .. Set _**I**_ to __**I**__{nbsp}pass:[+]{nbsp}1.
6433
6434 {var-v} is the decoded value.
6435
6436 .5-element {dl-array} field decoding.
6437 ====
6438 Consider the following <<er-payload,event record payload>>
6439 {struct-fc}{nbsp}{var-f}:
6440
6441 [source,json]
6442 ----
6443 {
6444 "type": "structure",
6445 "member-classes": [
6446 {
6447 "name": "len",
6448 "field-class": {
6449 "type": "fixed-length-unsigned-integer",
6450 "length": 16,
6451 "byte-order": "big-endian"
6452 }
6453 },
6454 {
6455 "name": "id",
6456 "field-class": {
6457 "type": "null-terminated-string"
6458 }
6459 },
6460 {
6461 "name": "vals",
6462 "field-class": {
6463 "type":
6464 "type": "dynamic-length-array",
6465 "length-field-location": ["event-record-payload", "len"],
6466 "element-field-class": {
6467 "type": "fixed-length-unsigned-integer",
6468 "length": 32,
6469 "byte-order": "little-endian",
6470 "alignment": 32
6471 }
6472 }
6473 }
6474 ]
6475 }
6476 ----
6477
6478 The following diagram shows <<pkt,packet>> bytes including an instance
6479 of{nbsp}{var-f} (starting in green and ending in blue) and the resulting
6480 signed integer values of its `vals` member.
6481
6482 The offset of the `len` {fl-uint} field, from the beginning of the packet, is
6483 0x42c1{nbsp}bytes, which means {var-dec-o-minus-po}{nbsp}={nbsp}136,712.
6484
6485 The offset of the `vals` {dl-array} field, from the beginning of the
6486 packet, is 0x42c8{nbsp}bytes, which means
6487 {var-dec-o-minus-po}{nbsp}={nbsp}136,768.
6488
6489 image::{doc-id}-images/dl-array.svg[]
6490
6491 The unsigned integer value of the `len` field is{nbsp}5, which means the
6492 `vals` field contains five {fl-sint} fields.
6493
6494 After the structure field is decoded,
6495 {var-dec-o-minus-po}{nbsp}={nbsp}136,928.
6496 ====
6497
6498 [[opt-field-dec]]
6499 ==== Optional field decoding procedure
6500
6501 To decode an instance of an {opt-fc}{nbsp}{var-f}:
6502
6503 . Let:
6504 ** _**SEL**_ be the value of the previously decoded <<bool-fc,boolean>>
6505 or <<int-fc,integer>> field of which the `selector-field-location`
6506 property of{nbsp}{var-f} indicates the <<field-loc-dec,location>>.
6507 ** _**OF**_ be the `field-class` property of {var-f}.
6508 ** {var-v} be a nil value.
6509
6510 . If the class of{nbsp}__**SEL**__ is a {fl-bool-fc}
6511 and _**SEL**_ is _true_, then:
6512 ** <<field-dec,Decode>> one instance of{nbsp}__**OF**__
6513 as{nbsp}{var-v}.
6514
6515 +
6516 Else, if _**SEL**_ is an element of any <<int-range-set,integer range>>
6517 of the `selector-field-ranges` property of{nbsp}{var-f}, then:
6518 ** <<field-dec,Decode>> one instance of{nbsp}__**OF**__
6519 as{nbsp}{var-v}.
6520
6521 {var-v} is the decoded value.
6522
6523 [[var-field-dec]]
6524 ==== Variant field decoding procedure
6525
6526 To decode an instance of an {var-fc}{nbsp}{var-f}:
6527
6528 . Let:
6529 .. _**SEL**_ be the value of the previously decoded <<int-fc,integer>>
6530 field of which the `selector-field-location` property of{nbsp}{var-f}
6531 indicates the <<field-loc-dec,location>>.
6532 .. _**OPTS**_ be the `options` property of{nbsp}{var-f}.
6533 .. _**OF**_ be the `field-class` property of the <<var-fc-opt,variant
6534 field class option>>{nbsp}__**OPT**__ of{nbsp}__**OPTS**__ of
6535 which{nbsp}__**SEL**__ is an element of any <<int-range-set,integer
6536 range>> of the `selector-field-ranges` property of{nbsp}__**OPT**__.
6537 .. {var-v} be a value.
6538
6539 . <<field-dec,Decode>> one instance of{nbsp}__**OF**__
6540 as{nbsp}{var-v}.
6541
6542 {var-v} is the decoded value.
This page took 0.161501 seconds and 4 git commands to generate.