1 // Please render with Asciidoctor
2 :doc-id: CTF2-SPECRC-3.0
4 = **{doc-id}**: Common Trace Format version{nbsp}2 release candidate
5 Philippe Proulx <pproulx@efficios.com>
7 :attribute-missing: warn
18 :ieee754: https://standards.ieee.org/standard/754-2008.html[IEEE 754-2008] binary interchange format
20 :ctf1: https://diamon.org/ctf/v1.8.3/[{ctf1-nl}]
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 7464]
123 :must: pass:q[__MUST__]
124 :must-not: pass:q[__MUST NOT__]
125 :required: pass:q[__REQUIRED__]
126 :should: pass:q[__SHOULD__]
127 :should-not: pass:q[__SHOULD 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**__ âˆ’ __**PO**__]
139 This document is a release candidate of the Common Trace Format (CTF)
140 version{nbsp}2 specification (_**CTF2-SPEC-2.0**_).
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].
151 [%header%autowidth, cols="d,d,a"]
153 |Document |Publication date |Changes
158 Add the optional `minimum-alignment` property to the
159 <<array-fc,abstract array field class>>.
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>>:
170 "type": "static-length-array",
172 "minimum-alignment": 32,
173 "element-field-class": {
174 "type": "fixed-length-boolean",
176 "byte-order": "little-endian"
181 While the producer writes a single integer value, consumers decode said
182 datum as an array of 32{nbsp}individual flags (booleans).
184 Update the <<align-dec>> section accordingly.
186 |_**CTF2‑SPECRC‑2.0**_
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
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>>.
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.
201 Correspondingly, make a <<var-fc,variant field>> require that _all_ its
202 possible selector fields be either unsigned integer fields or signed
205 This constraint exists to accomodate some consumer implementations, in
206 particular the ones with limited integer types.
208 * Add the "`nil`" <<dec-val-type,decoding value type>> so that
209 <<opt-field-dec,decoding an optional field>> always generates a value.
211 * Specify that an "`array`" decoding value contains a sequence of values,
212 whatever their types.
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.
218 |_**CTF2‑SPECRC‑1.0**_
220 |Initial {ctf2} specification release candidate.
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.
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.
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.
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.
246 {ctf2} is a major revision of {ctf1}, bringing many improvements, such
249 * Using JSON text sequences for the metadata stream.
251 * Adding <<aux-stream,auxiliary streams>> (also JSON text sequences).
253 * Simplifying the metadata stream.
255 * Adding new <<fc,field classes>>.
257 * Using <<roles,roles>> instead of reserved structure member names to
258 identify "`special`" fields.
260 and more, while remaining backward compatible at the data stream level.
262 == Common definitions
264 Common {ctf2} definitions:
266 [[byte-def]] <<byte-def,Byte>>::
267 A group of eight https://en.wikipedia.org/wiki/Bit[bits] operated on
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
277 [[class-def]] <<class-def,Class>>::
278 A set of values (instances) which share common properties.
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).
284 This specification often states that some class _describes_ instances.
285 For example, an <<erc-frag,event record class>> describes <<er,event
288 [[consumer-def]] <<consumer-def,Consumer>>::
289 A software or hardware system which consumes (reads) the streams of
292 A trace consumer is often a _trace viewer_ or a _trace analyzer_.
294 [[ns-def]] <<ns-def,Namespace>>::
295 A string of which the purpose is to avoid naming conflicts.
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.
301 IMPORTANT: The `std` namespace is reserved for the {ctf2} specification.
303 [[producer-def]] <<producer-def,Producer>>::
304 A software or hardware system which produces (writes) the streams of
307 A trace producer is often a _tracer_.
309 [[seq-def]] <<seq-def,Sequence>>::
310 A set of related items which follow each other in a particular
313 [[stream-def]] <<stream-def,Stream>>::
314 A <<seq-def,sequence>> of <<byte-def,bytes>>.
321 * One <<metadata-stream-overview,metadata stream>>.
322 * One or more <<data-stream,data streams>>.
323 * Zero or more <<aux-stream,auxiliary streams>>.
325 As a reminder, this specification defines a <<stream-def,stream>> as a
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.
333 [[metadata-stream-overview]]
334 === Metadata stream (overview)
336 A metadata stream describes trace <<ds,data streams>> with JSON objects.
338 A metadata stream describes things such as:
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.
344 Multiple traces {may} share the same metadata stream: a given trace
345 {may} contain specific information in its own <<aux-stream,auxiliary
348 See <<metadata-stream>> for the full metadata stream specification.
353 A _data stream_ is a <<seq-def,sequence>> of one or more data
356 image::{doc-id}-images/ctf-trace-all.svg[]
358 In the <<metadata-stream,metadata stream>>, a
359 <<dsc-frag,data stream class>> describes data streams.
361 A packet {must} contain one or more bytes of data.
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.
368 A data stream {may} have, conceptually:
370 [[def-clk]] One default, monotonic clock::
371 Described by a <<cc-frag,clock class>> in the metadata stream.
373 <<pkt,Packets>> and <<er,event records>> {may} contain snapshots, named
374 _timestamps_, of the default clock of their data stream.
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.
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.
383 A packet {may} contain a snapshot of this counter.
385 See <<ds-dec>> to learn how to decode a {ctf2} data stream.
390 A _packet_ is a segment of a <<ds,data stream>>.
392 A packet contains a <<seq-def,sequence>> of data _fields_ or padding
393 (garbage data). In the metadata stream, <<fc,field classes>> describe
396 A packet {var-p}, contained in a data stream{nbsp}{var-s}, contains,
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).
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
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},
417 ** {optional}: A field which contains the beginning timestamp
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.
427 . Zero or more <<er,event records>>.
429 A packet {must} contain one or more bytes of data.
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
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
440 * Packets {may} contain _snapshots_ of the <<disc-er-counter,discarded
441 event record counter>> of their data stream.
443 * Packets and event records {may} contain _timestamps_ which are
444 snapshots of the <<def-clk,default clock>> of their data stream.
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.
450 See <<pkt-dec>> to learn how to decode a {ctf2} packet.
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
459 A <<pkt,packet>> contains zero or more event records.
461 An <<erc-frag,event record class>> describes the specific parts of event
464 An event record _**E**_, contained in a <<ds,data stream>>{nbsp}{var-s},
465 contains, in this order:
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
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.
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.
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.
488 An event record {must} contain one or more bits of data.
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.
496 See <<er-dec>> to learn how to decode a {ctf2} event record.
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.
505 Each element of an auxiliary stream is a JSON object which has a single
510 <<ns-def,Namespace>> of the auxiliary stream.
515 .Auxiliary stream element with the `my.tracer` namespace.
521 "version": [1, 3, 2],
522 "session-name": "amqui"
528 .Auxiliary stream element of which the value is just `42`.
533 "328c7a2d-a959-4f60-bd22-cca74359326f": 42
539 ==== Trace environment
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.
545 The trace environment variables are a single JSON object where each
550 Trace environment variable name.
553 Trace environment variable value (any JSON value).
555 This document doesn't specify trace environment variable names.
557 .`std` auxiliary stream element with trace environment variables.
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",
572 "tracer_patchlevel": 0
582 A metadata stream is a JSON text sequence, as specified by {rfc-7464},
585 Together, the fragments of a metadata stream contain all the information
586 about the <<ds,data streams>> of one or more <<trace,traces>>.
588 [[frag]] A _fragment_ is a JSON object; its allowed properties depend on
591 .Common properties of a fragment {var-f}.
592 [%header%autowidth,cols="d,d,a,d,d"]
594 |Name |Type |Description |Required? |Default
598 |Type of{nbsp}{var-f}.
600 The value of this property {must} be one of:
603 {var-f} is a <<preamble-frag,preamble fragment>>.
606 {var-f} is a <<tc-frag,trace class fragment>>.
609 {var-f} is a <<cc-frag,clock class fragment>>.
611 `"data-stream-class"`::
612 {var-f} is a <<dsc-frag,data stream class fragment>>.
614 `"event-record-class"`::
615 {var-f} is a <<erc-frag,event record class fragment>>.
620 |<<user-attrs,User attributes>>
621 |User attributes of{nbsp}{var-f}.
627 |Extensions of{nbsp}{var-f}.
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.
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.
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.
656 .Partial metadata stream.
658 In the sample below, the string `<RS>` represents a single record
659 separator character (U+001E) and the string `[pass:[...]]` represents
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.
676 See <<ds-dec>> to learn how to decode a data stream.
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_]
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
691 .`e53e0ab8-50a1-4f0a-b710-b5f0bba9c4ac` UUID.
695 [229, 62, 10, 184, 80, 161, 79, 10, 183, 16, 181, 240, 187, 169, 196, 172]
702 A <<producer-def,producer>> {may} add _extensions_ to many metadata
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.
709 This document doesn't specify what an extension exactly is.
711 The <<preamble-frag,preamble fragment>> of the metadata stream contains
712 _extension declarations_:
714 * Any extension in metadata stream objects {must} be declared, by
715 namespace and name, in the preamble fragment.
717 Declaring an extension is said to _enable_ it.
719 * If a <<consumer-def,consumer>> doesn't support _any_ declared
720 extension, it {must-not} consume the <<ds,data streams>> of the
723 The consumer {should} report unsupported extensions as an error.
725 Extensions are a single JSON object, where each property is:
729 A <<ns-def,namespace>>
732 A <<ns-exts-obj,namespaced extensions object>>
734 [[ns-exts-obj]] A _namespaced extensions object_ is a JSON object, where
744 The metadata stream JSON objects which {may} contain extensions as their
745 `extensions` property are:
747 * Any <<frag,fragment>>.
749 An extension in the <<preamble-frag,preamble fragment>> also makes it
750 _declared_/_enabled_.
752 * Any <<fc,field class>>.
754 * A <<struct-member-cls,structure field member class>>.
756 * A <<var-fc-opt,variant field class option>>.
758 .Three extensions under two namespaces.
766 "temperament": "equal"
782 A <<producer-def,producer>> {may} add custom _user attributes_ to many
783 metadata stream JSON objects.
785 This document doesn't specify what a user attribute exactly is.
787 Unlike <<ext,extensions>>, a <<consumer-def,consumer>> {must-not}
788 consider user attributes to decode <<ds,data streams>>.
790 User attributes are a single JSON object, where each property is:
794 A <<ns-def,namespace>>
799 The metadata stream JSON objects which {may} contain user attributes
800 as their `user-attributes` property are:
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>>.
807 .User attributes under two namespaces.
824 A _field class_ describes fields, that is, <<seq-def,sequences>> of bits
825 as found in a <<ds,data stream>>.
827 A field class contains all the properties a <<consumer-def,consumer>>
828 needs to <<ds-dec,decode>> a given field.
830 A _field_ is a field class instance.
832 This document specifies the following types of field classes:
834 Abstract field classes::
835 One cannot use the following field classes directly: they are bases
836 for other, concrete field classes:
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>>
843 Fixed/static-length field classes::
853 Variable/dynamic-length field classes::
862 Compound field classes::
863 The following field classes contain one or more field classes.
871 A field class is a JSON object; its properties depend on its `type`
874 .Common properties of a field class {var-f}.
875 [%header%autowidth, cols="d,d,a,d,d"]
877 |Name |Type |Description |Required? |Default
881 |Type of{nbsp}{var-f}.
883 The value of this property {must} be one of:
885 `"fixed-length-bit-array"`::
886 {var-f} is a {fl-ba-fc}.
888 `"fixed-length-boolean"`::
889 {var-f} is a {fl-bool-fc}.
891 `"fixed-length-unsigned-integer"`::
892 `"fixed-length-signed-integer"`::
893 {var-f} is a {fl-int-fc}.
895 `"fixed-length-unsigned-enumeration"`::
896 `"fixed-length-signed-enumeration"`::
897 {var-f} is a {fl-enum-fc}.
899 `"fixed-length-floating-point-number"`::
900 {var-f} is a {fl-fp-fc}.
902 `"variable-length-bit-array"`::
903 {var-f} is a {vl-ba-fc}.
905 `"variable-length-unsigned-integer"`::
906 `"variable-length-signed-integer"`::
907 {var-f} is a {vl-int-fc}.
909 `"variable-length-unsigned-enumeration"`::
910 `"variable-length-signed-enumeration"`::
911 {var-f} is a {vl-enum-fc}.
913 `"null-terminated-string"`::
914 {var-f} is a {str-fc}.
916 `"static-length-string"`::
917 {var-f} is a {sl-str-fc}.
919 `"static-length-blob"`::
920 {var-f} is a {sl-blob-fc}.
922 `"dynamic-length-string"`::
923 {var-f} is a {dl-str-fc}.
925 `"dynamic-length-blob"`::
926 {var-f} is a {dl-blob-fc}.
929 {var-f} is a {struct-fc}.
931 `"static-length-array"`::
932 {var-f} is a {sl-array-fc}.
934 `"dynamic-length-array"`::
935 {var-f} is a {dl-array-fc}.
938 {var-f} is a {opt-fc}.
941 {var-f} is a {var-fc}.
947 |Roles of an instance of{nbsp}{var-f}.
949 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
955 |<<user-attrs,User attributes>>
956 |User attributes of{nbsp}{var-f}.
962 |Extensions of{nbsp}{var-f}.
964 Any extension which exists under this property {must} also be declared
965 in the <<preamble-frag,preamble fragment>> of the metadata stream.
970 The following <<frag,fragment>> properties {must} have a {struct-fc} as
973 <<tc-frag,Trace class fragment>>::
974 `packet-header-field-class`
976 <<dsc-frag,Data stream class fragment>>::
978 * `packet-context-field-class`
979 * `event-record-header-field-class`
980 * `event-record-common-context-field-class`
982 <<erc-frag,Event record class fragment>>::
984 * `specific-context-field-class`
985 * `payload-field-class`
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.
993 A consumer needs to locate another field to decode instances of the
994 following <<fc,classes>>:
999 Needs a <<fl-int-fc,{fl-uint}>> or
1000 <<vl-int-fc,{vl-uint}>> length field.
1003 Needs a <<fl-bool-fc,{fl-bool}>>, <<fl-int-fc,{fl-int}>>, or
1004 <<vl-int-fc,{vl-int}>> selector field.
1007 Needs a <<fl-int-fc,{fl-int}>> or <<vl-int-fc,{vl-int}>> selector
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:
1014 . The first element is the name (JSON string) of a root field from
1015 where to start the lookup of{nbsp}__**T**__, amongst:
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}.
1033 In other words, __**T**__ {must} be in the same packet or event record
1036 . The following elements are <<struct-fc,structure>> field member names
1037 (JSON strings) to follow to locate the target field.
1039 The length of a field location {must} be greater than or equal to two.
1041 See <<field-loc-dec>> to learn how to locate a field with a field
1045 ==== Integer range set
1047 An _integer range set_ is a JSON array of integer ranges.
1049 An integer range set {must} contain one or more integer ranges.
1051 An _integer range_ is a JSON array of two elements:
1053 . The lower bound of the range (JSON integer, included).
1054 . The upper bound of the range (JSON integer, included).
1056 An integer range represents all the integer values from the lower bound
1057 of the range to its upper bound.
1059 The upper bound of an integer range {must} be greater than or equal to
1062 If both the lower and upper bounds of an integer range are equal, then
1063 the integer range represents a single integer value.
1077 .Single integer value.
1084 .Integer range set containing three integer ranges.
1088 [[3, 67], [-45, 1], [42, 42]]
1095 Some <<fc,field class>> instances can have _roles_.
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).
1102 Roles are a JSON array of role names (JSON strings).
1104 See <<tc-frag>> and <<dsc-frag>> which indicate accepted roles within
1105 their root field classes.
1108 ==== {c-fl-ba} field class
1110 A _{fl-ba}_ field class describes _{fl-ba}_ fields.
1112 A {fl-ba} field is a simple array of contiguous bits, without any
1113 attached integer type semantics.
1115 The length, or number of bits, of a {fl-ba} field is a property
1116 (`length`) of its class.
1118 A {fl-ba} field class acts as a base of a {fl-bool-fc}, a {fl-int-fc},
1121 .Common properties of a {fl-ba} field class {var-f}.
1122 [%header%autowidth, cols="d,d,a,d,d"]
1124 |Name |Type |Description |Required? |Default
1128 |Type of{nbsp}{var-f}.
1130 The value of this property {must} be `"fixed-length-bit-array"`.
1136 |Number of bits of an instance of{nbsp}{var-f}.
1138 The value of this property {must} be greater than zero.
1144 |{c-bo} of an instance of{nbsp}{var-f}.
1146 The value of this property {must} be one of:
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.
1162 The value of this property {must} be a positive power of two.
1168 |Roles of an instance of{nbsp}{var-f}.
1170 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
1176 |<<user-attrs,User attributes>>
1177 |User attributes of{nbsp}{var-f}.
1183 |Extensions of{nbsp}{var-f}.
1185 Any extension which exists under this property {must} also be declared
1186 in the <<preamble-frag,preamble fragment>> of the metadata stream.
1191 .Minimal {fl-ba} field class.
1196 "type": "fixed-length-bit-array",
1198 "byte-order": "little-endian"
1203 .{c-fl-ba} field class with instances aligned to 32{nbsp}bits.
1208 "type": "fixed-length-bit-array",
1210 "byte-order": "big-endian",
1216 .{c-fl-ba} field class with <<user-attrs,user attributes>>.
1221 "type": "fixed-length-bit-array",
1223 "byte-order": "little-endian",
1224 "user-attributes": {
1234 ==== {c-fl-bool} field class
1236 A _{fl-bool}_ field class is a {fl-ba-fc} which describes _{fl-bool}_
1239 A {fl-bool} field is a {fl-ba} field which has the following semantics:
1241 If all the bits of the bit array field are cleared (zero)::
1242 The value of the {fl-bool} field is _false_.
1245 The value of the {fl-bool} field is _true_.
1247 .Properties of a {fl-bool} field class {var-f}.
1248 [%header%autowidth, cols="d,d,a,d,d"]
1250 |Name |Type |Description |Required? |Default
1254 |Type of{nbsp}{var-f}.
1256 The value of this property {must} be `"fixed-length-boolean"`.
1262 |Number of bits of an instance of{nbsp}{var-f}.
1264 The value of this property {must} be greater than zero.
1266 Property inherited from the {fl-ba-fc}.
1272 |{c-bo} of an instance
1275 The value of this property {must} be one of:
1283 Property inherited from the {fl-ba-fc}.
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.
1293 The value of this property {must} be a positive power of two.
1295 Property inherited from the {fl-ba-fc}.
1301 |Roles of an instance of{nbsp}{var-f}.
1303 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
1309 |<<user-attrs,User attributes>>
1310 |User attributes of{nbsp}{var-f}.
1316 |Extensions of{nbsp}{var-f}.
1318 Any extension which exists under this property {must} also be declared
1319 in the <<preamble-frag,preamble fragment>> of the metadata stream.
1324 .Minimal {fl-bool} field class.
1329 "type": "fixed-length-boolean",
1331 "byte-order": "little-endian"
1336 .{c-fl-bool} field class with instances aligned to 32{nbsp}bits.
1341 "type": "fixed-length-boolean",
1343 "byte-order": "big-endian",
1349 .{c-fl-bool} field class with <<user-attrs,user attributes>>.
1354 "type": "fixed-length-boolean",
1356 "byte-order": "little-endian",
1357 "user-attributes": {
1367 ==== Abstract integer field class
1369 An _abstract integer_ field class is a base of a {fl-int-fc} and a
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.
1376 .Common property of an integer field class {var-f}.
1377 [%header%autowidth, cols="d,d,a,d,d"]
1379 |Name |Type |Description |Required? |Default
1381 |`preferred-display-base`
1383 |Preferred base to display the value of an instance of{nbsp}{var-f}.
1385 The value of this property {must} be one of:
1400 This property exists to remain backward compatible with {ctf1}:
1401 it's not strictly needed to decode an instance of{nbsp}{var-f}.
1407 ==== {c-fl-int} field class
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.
1412 A {fl-int} field is a {fl-ba} field which has integer semantics.
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
1418 A {fl-int} field class acts as a base of a {fl-enum-fc}.
1420 .Common properties of a {fl-int} field class {var-f}.
1421 [%header%autowidth, cols="d,d,a,d,d"]
1423 |Name |Type |Description |Required? |Default
1427 |Type of{nbsp}{var-f}.
1429 The value of this property {must} be one of:
1431 `"fixed-length-unsigned-integer"`::
1432 The instances of{nbsp}{var-f} are {fl-uint} fields.
1434 `"fixed-length-signed-integer"`::
1435 The instances of{nbsp}{var-f} are {fl-sint} fields.
1441 |Number of bits of an instance of{nbsp}{var-f}.
1443 The value of this property {must} be greater than zero.
1445 Property inherited from the {fl-ba-fc}.
1451 |{c-bo} of an instance
1454 The value of this property {must} be one of:
1462 Property inherited from the {fl-ba-fc}.
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.
1472 The value of this property {must} be a positive power of two.
1474 Property inherited from the {fl-ba-fc}.
1478 |`preferred-display-base`
1480 |Preferred base to display the value of an instance of{nbsp}{var-f}.
1482 The value of this property {must} be one of:
1497 This property exists to remain backward compatible with {ctf1}:
1498 it's not strictly needed to decode an instance of{nbsp}{var-f}.
1500 Property inherited from the <<int-fc,abstract integer field class>>.
1506 |Roles of an instance of{nbsp}{var-f}.
1508 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
1514 |<<user-attrs,User attributes>>
1515 |User attributes of{nbsp}{var-f}.
1521 |Extensions of{nbsp}{var-f}.
1523 Any extension which exists under this property {must} also be declared
1524 in the <<preamble-frag,preamble fragment>> of the metadata stream.
1529 .Minimal {fl-uint} field class.
1534 "type": "fixed-length-unsigned-integer",
1536 "byte-order": "little-endian"
1541 .{c-fl-sint} field class with instances aligned to 32{nbsp}bits.
1546 "type": "fixed-length-signed-integer",
1548 "byte-order": "big-endian",
1554 .{c-fl-uint} field class with instances to be preferably displayed with a hexadecimal base.
1559 "type": "fixed-length-unsigned-integer",
1561 "byte-order": "big-endian",
1562 "preferred-display-base": 16
1567 .{c-fl-sint} field class with <<user-attrs,user attributes>>.
1572 "type": "fixed-length-signed-integer",
1574 "byte-order": "little-endian",
1575 "user-attributes": {
1585 ==== Abstract enumeration field class
1587 An _abstract enumeration_ field class is a base of a {fl-enum-fc} and a
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.
1594 An abstract enumeration field class is an <<int-fc,abstract integer
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.
1600 .Common property of an enumeration field class {var-f}.
1601 [%header%autowidth, cols="d,d,a,d,d"]
1603 |Name |Type |Description |Required? |Default
1605 |`preferred-display-base`
1607 |Preferred base to display the value of an instance of{nbsp}{var-f}.
1609 The value of this property {must} be one of:
1624 This property exists to remain backward compatible with {ctf1}:
1625 it's not strictly needed to decode an instance of{nbsp}{var-f}.
1627 Property inherited from the <<int-fc,abstract integer field class>>.
1632 |<<enum-fc-mappings,Enumeration field class mappings>>
1633 |Mappings of{nbsp}{var-f}.
1635 The value of this property {must} contain one or more properties.
1640 [[enum-fc-mappings]]
1641 ===== Enumeration field class mappings
1643 _Enumeration field class mappings_ map names to
1644 <<int-range-set,integer range sets>>.
1646 Enumeration field class mappings are a JSON object, where each property
1654 Mapped ranges of integers (<<int-range-set,integer range set>>).
1656 The integer ranges of two given mappings {may} overlap.
1658 Enumeration field class mappings {must} contain one or more properties.
1660 .Enumeration field class mappings with three mappings.
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
1669 "fortune": [[3, 67], [-45, 1], [84, 84]],
1670 "building": [[4, 5], [75, 82]],
1671 "journal": [[100, 2305], [80, 80]]
1677 ==== {c-fl-enum} field class
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.
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.
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
1689 .Properties of a {fl-enum} field class {var-f}.
1690 [%header%autowidth, cols="d,d,a,d,d"]
1692 |Name |Type |Description |Required? |Default
1696 |Type of{nbsp}{var-f}.
1698 The value of this property {must} be one of:
1700 `"fixed-length-unsigned-enumeration"`::
1701 The instances of{nbsp}{var-f} are {fl-uenum} fields.
1703 `"fixed-length-signed-enumeration"`::
1704 The instances of{nbsp}{var-f} are {fl-senum} fields.
1710 |Number of bits of an instance of{nbsp}{var-f}.
1712 The value of this property {must} be greater than zero.
1714 Property inherited from the {fl-ba-fc}.
1720 |{c-bo} of an instance
1723 The value of this property {must} be one of:
1731 Property inherited from the {fl-ba-fc}.
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.
1741 The value of this property {must} be a positive power of two.
1743 Property inherited from the {fl-ba-fc}.
1747 |`preferred-display-base`
1749 |Preferred base to display the value of an instance of{nbsp}{var-f}.
1751 The value of this property {must} be one of:
1766 This property exists to remain backward compatible with {ctf1}:
1767 it's not strictly needed to decode an instance of{nbsp}{var-f}.
1769 Property inherited from the <<int-fc,abstract integer field class>>.
1774 |<<enum-fc-mappings,Enumeration field class mappings>>
1775 |Mappings of{nbsp}{var-f}.
1777 The value of this property {must} contain one or more properties.
1779 Property inherited from the <<enum-fc,abstract enumeration field class>>.
1785 |Roles of an instance of{nbsp}{var-f}.
1787 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
1793 |<<user-attrs,User attributes>>
1794 |User attributes of{nbsp}{var-f}.
1800 |Extensions of{nbsp}{var-f}.
1802 Any extension which exists under this property {must} also be declared
1803 in the <<preamble-frag,preamble fragment>> of the metadata stream.
1808 .Minimal {fl-uenum} field class.
1813 "type": "fixed-length-unsigned-enumeration",
1815 "byte-order": "little-endian",
1823 .{c-fl-senum} field class with instances aligned to 32{nbsp}bits.
1828 "type": "fixed-length-signed-enumeration",
1830 "byte-order": "big-endian",
1833 "banana": [[-27399, -1882], [8, 199], [101, 101]],
1834 "orange": [[67, 67], [43, 1534]]
1840 .{c-fl-uenum} field class with instances to be preferably displayed with a hexadecimal base.
1845 "type": "fixed-length-unsigned-enumeration",
1847 "byte-order": "big-endian",
1848 "preferred-display-base": 16,
1852 "blueberry": [[11, 11]]
1858 .{c-fl-senum} field class with <<user-attrs,user attributes>>.
1863 "type": "fixed-length-signed-enumeration",
1865 "byte-order": "little-endian",
1869 "user-attributes": {
1879 ==== {c-fl-fp} field class
1881 A _{fl-fp}_ field class is a {fl-ba-fc} which describes _{fl-fp}_
1884 A {fl-fp} field is a {fl-ba} field which has floating point number
1887 .Properties of a {fl-fp} field class {var-f}.
1888 [%header%autowidth, cols="d,d,a,d,d"]
1890 |Name |Type |Description |Required? |Default
1894 |Type of{nbsp}{var-f}.
1896 The value of this property {must} be
1897 `"fixed-length-floating-point-number"`.
1903 |Number of bits of an instance of{nbsp}{var-f}.
1905 The value of this property {must} be one of:
1908 The instances of{nbsp}{var-f} are binary16 floating point numbers,
1909 as per the {ieee754}.
1912 The instances of{nbsp}{var-f} are binary32 floating point numbers.
1915 The instances of{nbsp}{var-f} are binary64 floating point numbers.
1918 The instances of{nbsp}{var-f} are binary128 floating point
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
1925 Property inherited from the {fl-ba-fc}.
1931 |{c-bo} of an instance
1934 The value of this property {must} be one of:
1942 Property inherited from the {fl-ba-fc}.
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.
1952 The value of this property {must} be a positive power of two.
1954 Property inherited from the {fl-ba-fc}.
1960 |Roles of an instance of{nbsp}{var-f}.
1962 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
1968 |<<user-attrs,User attributes>>
1969 |User attributes of{nbsp}{var-f}.
1975 |Extensions of{nbsp}{var-f}.
1977 Any extension which exists under this property {must} also be declared
1978 in the <<preamble-frag,preamble fragment>> of the metadata stream.
1983 .Minimal binary32 {fl-fp} field class.
1988 "type": "fixed-length-floating-point-number",
1990 "byte-order": "little-endian"
1995 .binary64 {fl-fp} field class with instances aligned to 32{nbsp}bits.
2000 "type": "fixed-length-floating-point-number",
2002 "byte-order": "big-endian",
2008 .binary192 {fl-fp} field class with <<user-attrs,user attributes>>.
2013 "type": "fixed-length-floating-point-number",
2015 "byte-order": "little-endian",
2016 "user-attributes": {
2026 ==== {c-vl-ba} field class
2028 A _{vl-ba}_ field class describes _{vl-ba}_ fields.
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].
2035 A {vl-ba} field class acts as a base of a {vl-int-fc}.
2037 .Common properties of a {vl-ba} field class {var-f}.
2038 [%header%autowidth, cols="d,d,a,d,d"]
2040 |Name |Type |Description |Required? |Default
2044 |Type of{nbsp}{var-f}.
2046 The value of this property {must} be `"variable-length-bit-array"`.
2052 |Roles of an instance of{nbsp}{var-f}.
2054 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2060 |<<user-attrs,User attributes>>
2061 |User attributes of{nbsp}{var-f}.
2067 |Extensions of{nbsp}{var-f}.
2069 Any extension which exists under this property {must} also be declared
2070 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2075 .Minimal {vl-ba} field class.
2080 "type": "variable-length-bit-array"
2085 .{c-vl-ba} field class with <<user-attrs,user attributes>>.
2090 "type": "variable-length-bit-array",
2091 "user-attributes": {
2101 ==== {c-vl-int} field class
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.
2106 A {vl-int} field is a {vl-ba} field which has integer semantics.
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
2112 A {vl-int} field class acts as a base of a {vl-enum-fc}.
2114 .Common properties of a {vl-int} field class {var-f}.
2115 [%header%autowidth, cols="d,d,a,d,d"]
2117 |Name |Type |Description |Required? |Default
2121 |Type of{nbsp}{var-f}.
2123 The value of this property {must} be one of:
2125 `"variable-length-unsigned-integer"`::
2126 The instances of{nbsp}{var-f} are {vl-uint} fields.
2128 `"variable-length-signed-integer"`::
2129 The instances of{nbsp}{var-f} are {vl-sint} fields.
2133 |`preferred-display-base`
2135 |Preferred base to display the value of an instance of{nbsp}{var-f}.
2137 The value of this property {must} be one of:
2152 This property exists to remain backward compatible with {ctf1}:
2153 it's not strictly needed to decode an instance of{nbsp}{var-f}.
2155 Property inherited from the <<int-fc,abstract integer field class>>.
2161 |Roles of an instance of{nbsp}{var-f}.
2163 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2169 |<<user-attrs,User attributes>>
2170 |User attributes of{nbsp}{var-f}.
2176 |Extensions of{nbsp}{var-f}.
2178 Any extension which exists under this property {must} also be declared
2179 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2184 .Minimal {vl-uint} field class.
2189 "type": "variable-length-unsigned-integer"
2194 .{c-vl-sint} field class with instances to be preferably displayed with a hexadecimal base.
2199 "type": "variable-length-signed-integer",
2200 "preferred-display-base": 16
2205 .{c-vl-uint} field class with <<user-attrs,user attributes>>.
2210 "type": "variable-length-unsigned-integer",
2211 "user-attributes": {
2221 ==== {c-vl-enum} field class
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.
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.
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.
2233 .Properties of a {vl-enum} field class {var-f}.
2234 [%header%autowidth, cols="d,d,a,d,d"]
2236 |Name |Type |Description |Required? |Default
2240 |Type of{nbsp}{var-f}.
2242 The value of this property {must} be one of:
2244 `"variable-length-unsigned-enumeration"`::
2245 The instances of{nbsp}{var-f} are {vl-uenum} fields.
2247 `"variable-length-signed-enumeration"`::
2248 The instances of{nbsp}{var-f} are {vl-senum} fields.
2252 |`preferred-display-base`
2254 |Preferred base to display the value of an instance of{nbsp}{var-f}.
2256 The value of this property {must} be one of:
2271 This property exists to remain backward compatible with {ctf1}:
2272 it's not strictly needed to decode an instance of{nbsp}{var-f}.
2274 Property inherited from the <<int-fc,abstract integer field class>>.
2279 |<<enum-fc-mappings,Enumeration field class mappings>>
2280 |Mappings of{nbsp}{var-f}.
2282 The value of this property {must} contain one or more properties.
2284 Property inherited from the <<enum-fc,abstract enumeration field class>>.
2290 |Roles of an instance of{nbsp}{var-f}.
2292 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2298 |<<user-attrs,User attributes>>
2299 |User attributes of{nbsp}{var-f}.
2305 |Extensions of{nbsp}{var-f}.
2307 Any extension which exists under this property {must} also be declared
2308 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2313 .Minimal {vl-uenum} field class.
2318 "type": "variable-length-unsigned-enumeration",
2326 .{c-vl-uenum} field class with instances to be preferably displayed with a hexadecimal base.
2331 "type": "variable-length-unsigned-enumeration",
2332 "preferred-display-base": 16,
2336 "blueberry": [[11, 11]]
2342 .{c-vl-senum} field class with <<user-attrs,user attributes>>.
2347 "type": "variable-length-signed-enumeration",
2349 "banana": [[-27399, -1882], [8, 199], [101, 101]],
2350 "orange": [[67, 67], [43, 1534]]
2352 "user-attributes": {
2362 ==== {c-str} field class
2364 A _{str}_ field class describes _{str}_ fields.
2366 A {str} field is, in this order:
2368 . Zero or more contiguous non-null (non-zero) bytes which form a
2369 UTF-8-encoded string.
2371 . One null (zero) byte.
2373 .Properties of a {str} field class {var-f}.
2374 [%header%autowidth, cols="d,d,a,d,d"]
2376 |Name |Type |Description |Required? |Default
2380 |Type of{nbsp}{var-f}.
2382 The value of this property {must} be `"null-terminated-string"`.
2388 |Roles of an instance of{nbsp}{var-f}.
2390 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2396 |<<user-attrs,User attributes>>
2397 |User attributes of{nbsp}{var-f}.
2403 |Extensions of{nbsp}{var-f}.
2405 Any extension which exists under this property {must} also be declared
2406 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2411 .Minimal {str} field class.
2416 "type": "null-terminated-string"
2421 .{c-str} field class with <<user-attrs,user attributes>>.
2426 "type": "null-terminated-string",
2427 "user-attributes": {
2437 ==== {c-sl-str} field class
2439 A _{sl-str}_ field class describes _{sl-str}_ fields.
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).
2446 The length, or number of bytes, of a {sl-str} field is a property
2447 (`length`) of its class.
2449 .Properties of a {sl-str} field class {var-f}.
2450 [%header%autowidth, cols="d,d,a,d,d"]
2452 |Name |Type |Description |Required? |Default
2456 |Type of{nbsp}{var-f}.
2458 The value of this property {must} be `"static-length-string"`.
2464 |Number of bytes contained in an instance of{nbsp}{var-f}.
2466 The value of this property {must} be greater than or equal to zero.
2472 |Roles of an instance of{nbsp}{var-f}.
2474 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2480 |<<user-attrs,User attributes>>
2481 |User attributes of{nbsp}{var-f}.
2487 |Extensions of{nbsp}{var-f}.
2489 Any extension which exists under this property {must} also be declared
2490 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2495 .Empty {sl-str} field class.
2500 "type": "static-length-string",
2506 .{c-sl-str} field class with instances having 100{nbsp}bytes.
2511 "type": "static-length-string",
2517 .{c-sl-str} field class with <<user-attrs,user attributes>>.
2522 "type": "static-length-string",
2524 "user-attributes": {
2532 ==== {c-dl-str} field class
2534 A _{dl-str}_ field class describes _{dl-str}_ fields.
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).
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.
2546 .Properties of a {dl-str} field class {var-f}.
2547 [%header%autowidth, cols="d,d,a,d,d"]
2549 |Name |Type |Description |Required? |Default
2553 |Type of{nbsp}{var-f}.
2555 The value of this property {must} be `"static-length-string"`.
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}.
2564 The class of the length field {must} be one of:
2573 |Roles of an instance of{nbsp}{var-f}.
2575 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2581 |<<user-attrs,User attributes>>
2582 |User attributes of{nbsp}{var-f}.
2588 |Extensions of{nbsp}{var-f}.
2590 Any extension which exists under this property {must} also be declared
2591 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2596 .{c-dl-str} field class.
2601 "type": "dynamic-length-string",
2602 "length-field-location": ["event-record-payload", "length"]
2607 .{c-dl-str} field class with <<user-attrs,user attributes>>.
2612 "type": "dynamic-length-string",
2613 "length-field-location": ["event-record-common-context", "name-length"],
2614 "user-attributes": {
2622 ==== Abstract BLOB field class
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}.
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.
2631 .Common properties of a BLOB field class {var-f}.
2632 [%header%autowidth, cols="d,d,a,d,d"]
2634 |Name |Type |Description |Required? |Default
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}.
2642 |`"application/octet-stream"`
2646 ==== {c-sl-blob} field class
2648 A _{sl-blob}_ field class is an <<blob-fc,abstract BLOB field class>>
2649 which describes _{sl-blob}_ fields.
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).
2655 The length, or number of bytes, of a {sl-blob} field is a property
2656 (`length`) of its class.
2658 .Properties of a {sl-blob} field class {var-f}.
2659 [%header%autowidth, cols="d,d,a,d,d"]
2661 |Name |Type |Description |Required? |Default
2665 |Type of{nbsp}{var-f}.
2667 The value of this property {must} be `"static-length-blob"`.
2673 |Number of bytes contained in an instance of{nbsp}{var-f}.
2675 The value of this property {must} be greater than or equal to zero.
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}.
2685 Property inherited from the <<blob-fc,abstract BLOB field class>>.
2687 |`"application/octet-stream"`
2691 |Roles of an instance of{nbsp}{var-f}.
2693 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2699 |<<user-attrs,User attributes>>
2700 |User attributes of{nbsp}{var-f}.
2706 |Extensions of{nbsp}{var-f}.
2708 Any extension which exists under this property {must} also be declared
2709 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2714 .Empty {sl-blob} field class with instances having a default IANA media type.
2719 "type": "static-length-blob",
2725 .Static-length TIFF BLOB field class with instances having 511,267{nbsp}bytes.
2730 "type": "static-length-blob",
2732 "media-type": "image/tif"
2737 .Static-length CSV BLOB field class with <<user-attrs,user attributes>>.
2742 "type": "static-length-blob",
2744 "media-type": "text/csv",
2745 "user-attributes": {
2755 ==== {c-dl-blob} field class
2757 A _{dl-blob}_ field class is an <<blob-fc,abstract BLOB field class>>
2758 which describes _{dl-blob}_ fields.
2760 A {dl-blob} field is a <<seq-def,sequence>> of zero or more contiguous
2761 bytes with an associated IANA media type.
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.
2768 .Properties of a {dl-blob} field class {var-f}.
2769 [%header%autowidth, cols="d,d,a,d,d"]
2771 |Name |Type |Description |Required? |Default
2775 |Type of{nbsp}{var-f}.
2777 The value of this property {must} be `"dynamic-length-blob"`.
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}.
2786 The class of the length field {must} be one of:
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}.
2798 Property inherited from the <<blob-fc,abstract BLOB field class>>.
2800 |`"application/octet-stream"`
2804 |Roles of an instance of{nbsp}{var-f}.
2806 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2812 |<<user-attrs,User attributes>>
2813 |User attributes of{nbsp}{var-f}.
2819 |Extensions of{nbsp}{var-f}.
2821 Any extension which exists under this property {must} also be declared
2822 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2827 .{c-dl-blob} field class with instances having a default IANA media type.
2832 "type": "dynamic-length-blob",
2833 "length-field-location": ["event-record-payload", "length"]
2838 .Dynamic-length JPEG BLOB field class with <<user-attrs,user attributes>>.
2843 "type": "dynamic-length-blob",
2844 "length-field-location": ["event-record-common-context", "length"],
2845 "media-type": "image/jpeg",
2846 "user-attributes": {
2856 ==== Structure field class
2858 A _structure field class_ describes _structure fields_.
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.
2863 .Properties of a structure field class {var-f}.
2864 [%header%autowidth, cols="d,d,a,d,d"]
2866 |Name |Type |Description |Required? |Default
2870 |Type of{nbsp}{var-f}.
2872 The value of this property {must} be `"structure"`.
2877 |JSON array of <<struct-member-cls,structure field member classes>>
2878 |Classes of the members of an instance of{nbsp}{var-f}.
2880 The `name` property of each member class {must} be unique within the
2881 member class names of{nbsp}{var-f}.
2885 |`minimum-alignment`
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
2891 The value of this property {must} be a positive power of two.
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.
2900 |Roles of an instance of{nbsp}{var-f}.
2902 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
2908 |<<user-attrs,User attributes>>
2909 |User attributes of{nbsp}{var-f}.
2915 |Extensions of{nbsp}{var-f}.
2917 Any extension which exists under this property {must} also be declared
2918 in the <<preamble-frag,preamble fragment>> of the metadata stream.
2923 .Empty structure field class: instances have no members.
2933 .Structure field class with three member classes.
2938 "type": "structure",
2943 "type": "null-terminated-string"
2949 "type": "fixed-length-unsigned-integer",
2951 "byte-order": "little-endian",
2952 "preferred-display-base": 2
2954 "user-attributes": {
2963 "type": "fixed-length-boolean",
2965 "byte-order": "little-endian"
2973 .Structure field class with instances minimally aligned to 64{nbsp}bits.
2978 "type": "structure",
2983 "type": "null-terminated-string"
2987 "name": "Lajeunesse",
2989 "type": "fixed-length-unsigned-integer",
2991 "byte-order": "big-endian",
2996 "minimum-alignment": 64
3001 .Structure field class with <<user-attrs,user attributes>>.
3006 "type": "structure",
3009 "name": "Henri-Julien",
3011 "type": "fixed-length-signed-integer",
3013 "byte-order": "little-endian"
3019 "type": "static-length-string",
3024 "user-attributes": {
3033 [[struct-member-cls]]
3034 ===== Structure field member class
3036 A _structure field member class_ describes _structure field members_.
3038 A structure field member class is a JSON object.
3040 .Properties of a structure field member class _**M**_.
3041 [%header%autowidth, cols="d,d,a,d,d"]
3043 |Name |Type |Description |Required? |Default
3047 |Name of{nbsp}__**M**__.
3053 |Field class of{nbsp}__**M**__.
3058 |<<user-attrs,User attributes>>
3059 |User attributes of{nbsp}__**M**__.
3065 |Extensions of{nbsp}__**M**__.
3067 Any extension which exists under this property {must} also be declared
3068 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3073 .<<str-fc,{c-str} field class>> member class named `cat`.
3080 "type": "null-terminated-string"
3086 .{c-vl-sint-fc} member class named `dog` with <<user-attrs,user attributes>>.
3093 "type": "variable-length-signed-integer",
3094 "preferred-display-base": 8
3096 "user-attributes": {
3099 243, 97, 0, 184, 236, 54, 72, 97,
3100 141, 107, 169, 214, 171, 137, 115, 201
3110 ==== Abstract array field class
3112 An _abstract array_ field class is a base of a {sl-array-fc} and a
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.
3119 .Common properties of an array field class {var-f}.
3120 [%header%autowidth, cols="d,d,a,d,d"]
3122 |Name |Type |Description |Required? |Default
3124 |`element-field-class`
3126 |Class of the element fields contained in an instance of{nbsp}{var-f}.
3130 |`minimum-alignment`
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
3136 The value of this property {must} be a positive power of two.
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.
3145 ==== {c-sl-array} field class
3147 A _{sl-array}_ field class is an <<array-fc,abstract array field class>>
3148 which describes _{sl-array}_ fields.
3150 A {sl-array} field is a sequence of zero or more element fields.
3152 The length, or number of element fields, of a {sl-array} field is a
3153 property (`length`) of its class.
3155 .Properties of a {sl-array} field class {var-f}.
3156 [%header%autowidth, cols="d,d,a,d,d"]
3158 |Name |Type |Description |Required? |Default
3162 |Type of{nbsp}{var-f}.
3164 The value of this property {must} be `"static-length-array"`.
3168 |`element-field-class`
3170 |Class of the element fields contained in an instance of{nbsp}{var-f}.
3172 Property inherited from the <<array-fc,abstract array field class>>.
3176 |`minimum-alignment`
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
3182 The value of this property {must} be a positive power of two.
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.
3187 Property inherited from the <<array-fc,abstract array field class>>.
3193 |Number of element fields contained in an instance of{nbsp}{var-f}.
3195 The value of this property {must} be greater than or equal to zero.
3201 |Roles of an instance of{nbsp}{var-f}.
3203 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
3209 |<<user-attrs,User attributes>>
3210 |User attributes of{nbsp}{var-f}.
3216 |Extensions of{nbsp}{var-f}.
3218 Any extension which exists under this property {must} also be declared
3219 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3224 .Empty {sl-array} field class.
3229 "type": "static-length-array",
3230 "element-field-class": {
3231 "type": "fixed-length-signed-integer",
3233 "byte-order": "little-endian",
3241 .{c-sl-array} field class with instances having 100{nbsp}<<str-fc,{str}>> fields.
3246 "type": "static-length-array",
3247 "element-field-class": {
3248 "type": "null-terminated-string"
3255 .{c-sl-array} field class with <<user-attrs,user attributes>>.
3260 "type": "static-length-array",
3261 "element-field-class": {
3262 "type": "variable-length-unsigned-integer"
3265 "user-attributes": {
3272 .{c-sl-array} field class with instances minimally aligned to 32{nbsp}bits.
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).
3282 "type": "static-length-array",
3284 "minimum-alignment": 32,
3285 "element-field-class": {
3286 "type": "fixed-length-boolean",
3288 "byte-order": "little-endian"
3295 ==== {c-dl-array} field class
3297 A _{dl-array}_ field class is an <<array-fc,abstract array field class>>
3298 which describes _{dl-array}_ fields.
3300 A {dl-array} field is a sequence of zero or more element fields.
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.
3307 .Properties of a {dl-array} field class {var-f}.
3308 [%header%autowidth, cols="d,d,a,d,d"]
3310 |Name |Type |Description |Required? |Default
3314 |Type of{nbsp}{var-f}.
3316 The value of this property {must} be `"dynamic-length-array"`.
3320 |`element-field-class`
3322 |Class of the element fields contained in an instance of{nbsp}{var-f}.
3324 Property inherited from the <<array-fc,abstract array field class>>.
3328 |`minimum-alignment`
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
3334 The value of this property {must} be a positive power of two.
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.
3339 Property inherited from the <<array-fc,abstract array field class>>.
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}.
3348 The class of the length field {must} be one of:
3357 |Roles of an instance of{nbsp}{var-f}.
3359 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
3365 |<<user-attrs,User attributes>>
3366 |User attributes of{nbsp}{var-f}.
3372 |Extensions of{nbsp}{var-f}.
3374 Any extension which exists under this property {must} also be declared
3375 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3380 .{c-dl-array} field class.
3385 "type": "dynamic-length-array",
3386 "element-field-class": {
3387 "type": "fixed-length-unsigned-integer",
3389 "byte-order": "big-endian",
3392 "length-field-location": ["event-record-payload", "length"]
3397 .{c-dl-array} field class with <<user-attrs,user attributes>>.
3402 "type": "dynamic-length-array",
3403 "element-field-class": {
3404 "type": "variable-length-unsigned-integer"
3406 "length-field-location": ["packet-context", "common-length"],
3407 "user-attributes": {
3415 ==== Optional field class
3417 An _optional_ field class describes _optional_ fields.
3419 An optional field is, depending on the value of another, anterior
3420 (already encoded/decoded) _selector_ field, one of:
3422 * An instance of a given field class (`field-class` property of the
3423 optional field class).
3425 In this case, the optional field is said to be _enabled_.
3427 * A zero-bit field (no field).
3429 In this case, the optional field is said to be _disabled_.
3431 A <<consumer-def,consumer>> can locate the selector field thanks to the
3432 `selector-field-location` property of the optional field class.
3434 .Properties of an optional field class {var-f}.
3435 [%header%autowidth, cols="d,d,a,d,d"]
3437 |Name |Type |Description |Required? |Default
3441 |Type of{nbsp}{var-f}.
3443 The value of this property {must} be `"optional"`.
3449 |Class of an instance of{nbsp}{var-f} when it's enabled.
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.
3458 A selector field{nbsp}__**S**__ {must} be an instance of one of:
3461 An instance of{nbsp}{var-f} is enabled when{nbsp}__**S**__ is
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}.
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
3474 * <<fl-bool-fc,``"fixed-length-boolean"``>>
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"``>>
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"``>>
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}
3495 |None if the selector field is an instance of a {fl-bool-fc}.
3499 |Roles of{nbsp}{var-f}.
3501 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
3507 |<<user-attrs,User attributes>>
3508 |User attributes of{nbsp}{var-f}.
3514 |Extensions of{nbsp}{var-f}.
3516 Any extension which exists under this property {must} also be declared
3517 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3522 .Optional {sl-array-fc} with a <<bool-fc,boolean>> selector field class.
3528 "selector-field-location": ["event-record-payload", "has-ip"],
3530 "type": "static-length-array",
3531 "element-field-class": {
3532 "type": "fixed-length-unsigned-integer",
3534 "byte-order": "little-endian",
3543 .Optional {str} with a <<fl-int-fc,fixed-length signed integer>> selector field class.
3549 "selector-field-location": ["event-record-payload", "has-ip"],
3550 "selector-field-ranges": [[-12, -12], [-5, 0], [15, 35]],
3552 "type": "null-terminated-string"
3559 ==== Variant field class
3561 A _variant_ field class describes _variant_ fields.
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_.
3567 A <<consumer-def,consumer>> can locate the selector field thanks to the
3568 `selector-field-location` property of the variant field class.
3570 .Properties of a variant field class {var-f}.
3571 [%header%autowidth, cols="d,d,a,d,d"]
3573 |Name |Type |Description |Required? |Default
3577 |Type of{nbsp}{var-f}.
3579 The value of this property {must} be `"variant"`.
3584 |JSON array of <<var-fc-opt,variant field class options>>
3585 |Options containing the possible effective classes of an instance
3588 This array {must} contain one or more elements.
3590 The `name` property of each option, if it's set, {must} be unique within
3591 the option names of{nbsp}{var-f}.
3593 The integer ranges (`selector-field-ranges` property) of two given
3594 options {must-not} intersect.
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
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
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"``>>
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"``>>
3624 |Roles of{nbsp}{var-f}.
3626 See <<tc-frag>> and <<dsc-frag>> which indicate accepted within their
3632 |<<user-attrs,User attributes>>
3633 |User attributes of{nbsp}{var-f}.
3639 |Extensions of{nbsp}{var-f}.
3641 Any extension which exists under this property {must} also be declared
3642 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3647 .Variant field class with two options.
3653 "selector-field-location": ["event-record-payload", "sel"],
3656 "selector-field-ranges": [[5, 5]],
3658 "type": "null-terminated-string"
3662 "selector-field-ranges": [[8, 8]],
3664 "type": "fixed-length-signed-integer",
3666 "byte-order": "little-endian",
3667 "preferred-display-base": 8
3675 .Variant field class within an {opt-fc} which share the same selector field location.
3677 This example shows that an optional field class and a contained variant
3678 field class {may} share the same selector field location.
3680 In this example, depending on the value of the selector field:
3684 The optional field is _not_ enabled.
3687 The optional field is enabled and is a variant field.
3689 The variant field is an instance of a {str-fc} (effective class).
3692 The optional field is enabled and is a variant field.
3694 The variant field is an instance of a {vl-sint-fc} (effective class).
3700 "selector-field-location": ["event-record-payload", "sel"],
3701 "selector-field-ranges": [[1, 255]],
3704 "selector-field-location": ["event-record-payload", "sel"],
3707 "selector-field-ranges": [[1, 1]],
3709 "type": "null-terminated-string"
3713 "selector-field-ranges": [[2, 2]],
3715 "type": "variable-length-signed-integer",
3716 "preferred-display-base": 16
3725 .Variant field class with <<user-attrs,user attributes>>.
3731 "selector-field-location": ["event-record-specific-context", "sel"],
3734 "selector-field-ranges": [[5, 5], [10, 10], [15, 15]],
3736 "type": "static-length-string",
3741 "selector-field-ranges": [[0, 4], [6, 9], [11, 14], [16, 127]],
3743 "type": "fixed-length-floating-point-number",
3745 "byte-order": "big-endian"
3749 "user-attributes": {
3760 ===== Variant field class option
3762 A _variant field class option_ contains a possible effective class of a
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}.
3770 A variant field class option is a JSON object.
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"]
3775 |Name |Type |Description |Required? |Default
3779 |Field class of{nbsp}{var-o}.
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}.
3793 |Name of{nbsp}{var-o}.
3795 This property exists to remain backward compatible with {ctf1}:
3796 it's not strictly needed to decode an instance of{nbsp}{var-f}.
3801 |<<user-attrs,User attributes>>
3802 |User attributes of{nbsp}{var-o}.
3808 |Extensions of{nbsp}{var-o}.
3810 Any extension which exists under this property {must} also be declared
3811 in the <<preamble-frag,preamble fragment>> of the metadata stream.
3816 .Unnamed {str-fc} option.
3822 "type": "null-terminated-string"
3824 "selector-field-ranges": [[3, 9]]
3829 .{c-vl-sint-fc} option named `juice` with <<user-attrs,user attributes>>.
3836 "type": "variable-length-signed-integer",
3837 "preferred-display-base": 16
3839 "selector-field-ranges": [[-4, 4], [9, 9], [100, 200]],
3840 "user-attributes": {
3843 243, 97, 0, 184, 236, 54, 72, 97,
3844 141, 107, 169, 214, 171, 137, 115, 201
3854 === Preamble fragment
3856 A _preamble fragment_ indicates:
3858 * The {ctf2} major version (2).
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
3865 * <<ext,Extension>> declarations.
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
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.
3877 The first fragment of a metadata stream {must} be a preamble fragment.
3879 .Properties of a preamble fragment {var-f}.
3882 |Name |Type |Description |Required? |Default
3886 |Type of{nbsp}{var-f}.
3888 The value of this property {must} be `"preamble"`.
3894 |{ctf2} major version.
3896 The value of this property {must} be `2`.
3901 |<<user-attrs,User attributes>>
3902 |User attributes of{nbsp}{var-f}.
3908 |Extension declarations of{nbsp}{var-f}.
3910 The name of each property is a <<ns-def,namespace>> and its value is a
3911 <<ns-exts-obj,namespaced extensions object>>.
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.
3920 .Minimal preamble fragment.
3931 .Preamble fragment with <<ext,extension>> declarations.
3933 The following preamble fragment declares the `piano` and `ramen`
3934 extensions under the `my.tracer` namespace.
3945 "temperament": "equal"
3955 === Trace class fragment
3957 A _trace class_ describes <<trace,_traces_>>.
3959 Within a metadata stream, a trace class fragment {must} occur, if any,
3960 before any <<dsc-frag,data stream class fragment>>.
3962 .Properties of a trace class fragment {var-f}.
3963 [%header%autowidth,cols="d,d,a,d,d"]
3965 |Name |Type |Description |Required? |Default
3969 |Type of{nbsp}{var-f}.
3971 The value of this property {must} be `"trace-class"`.
3977 |UUID of{nbsp}{var-f}.
3979 |{var-f}{nbsp}has no UUID
3981 |`packet-header-field-class`
3983 |Class of all the <<pkt-header,packet header fields>> of an instance
3986 Any field class as the value of this property {must} satisfy _at least
3989 * Have at least one valid <<pkt-header-roles,role>>.
3993 * Be the class of a field which is the selector field of an optional
3996 |{var-f}{nbsp}has no packet header field class
3999 |<<user-attrs,User attributes>>
4000 |User attributes of{nbsp}{var-f}.
4006 |Extensions of{nbsp}{var-f}.
4008 Any extension which exists under this property {must} also be declared
4009 in the <<preamble-frag,preamble fragment>> of the metadata stream.
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
4021 .Roles of field classes of the member classes of a packet header field class.
4022 [%header%autowidth,cols="d,d,a,a"]
4024 |Name |Description |Field class ({var-f}) constraints |Other constraints
4026 |`packet-magic-number`
4027 |<<pkt,Packet>> magic number.
4029 The purpose of a packet magic number field is to confirm the beginning
4031 |{c-fl-uint-fc} with the following property value:
4036 |An instance of{nbsp}{var-f} {must} be the _first_ member of the packet
4037 header structure field.
4039 The value of an instance of{nbsp}{var-f} value {must} be 0xc1fc1fc1
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
4048 |{c-sl-blob-fc} with the following property value:
4053 |The `uuid` property of the trace class {must} exist.
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.
4058 |`data-stream-class-id`
4059 |Data stream class ID.
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}.
4069 The purpose of a data stream ID field is to set the current ID of
4070 the data stream of the current packet.
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}.
4078 .Trace class fragment.
4083 "type": "trace-class",
4085 30, 201, 100, 148, 228, 2, 69, 70,
4086 147, 219, 233, 34, 43, 238, 108, 199
4088 "packet-header-field-class": {
4089 "type": "structure",
4092 "name": "the magic!",
4094 "type": "fixed-length-unsigned-integer",
4096 "byte-order": "little-endian",
4097 "preferred-display-base": 16,
4098 "roles": ["packet-magic-number"]
4104 "type": "static-length-blob",
4106 "roles": ["trace-class-uuid"]
4110 "name": "my data stream class ID",
4112 "type": "fixed-length-unsigned-integer",
4114 "byte-order": "little-endian",
4115 "roles": ["data-stream-class-id"]
4119 "name": "my data stream ID",
4121 "type": "variable-length-unsigned-integer",
4122 "roles": ["data-stream-id"]
4132 === Clock class fragment
4134 A _clock class_ describes _clocks_.
4136 A <<ds,data stream>> {may} have a <<def-clk,default clock>>.
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.
4142 .Properties of a clock class fragment {var-f}.
4143 [%header%autowidth,cols="d,d,a,d,d"]
4145 |Name |Type |Description |Required? |Default
4149 |Type of{nbsp}{var-f}.
4151 The value of this property {must} be `"clock-class"`.
4157 |Frequency of an instance of{nbsp}{var-f} (Hz).
4159 The value of this property {must} be greater than zero.
4165 |Name of{nbsp}{var-f}.
4171 |Textual description of{nbsp}{var-f}.
4173 This property exists to remain backward compatible with {ctf1}:
4174 it's not strictly needed to decode <<ds,data streams>>.
4176 |{var-f}{nbsp}has no textual description
4180 |UUID of{nbsp}{var-f}.
4182 This property exists to remain backward compatible with {ctf1}:
4183 it's not strictly needed to decode <<ds,data streams>>.
4185 |{var-f}{nbsp}has no UUID
4187 |`origin-is-unix-epoch`
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].
4192 If the value of this property is `false`, then the origin of
4193 an instance of{nbsp}{var-f} is unknown.
4198 |<<clock-offset,Clock offset>>
4199 |Offset of an instance of{nbsp}{var-f} relative to its origin.
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}.
4208 Then the effective offset of an instance of{nbsp}{var-f}, in clock
4210 is{nbsp}{var-s}{nbsp}{times}{nbsp}__**H**__{nbsp}pass:[+]{nbsp}__**C**__.
4212 |`{"seconds":{nbsp}0, "cycles":{nbsp}0}`
4216 |Precision of an instance of{nbsp}{var-f} (clock cycles).
4218 The value of this property {must} be greater than or equal to zero.
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}].
4228 |<<user-attrs,User attributes>>
4229 |User attributes of{nbsp}{var-f}.
4235 |Extensions of{nbsp}{var-f}.
4237 Any extension which exists under this property {must} also be declared
4238 in the <<preamble-frag,preamble fragment>> of the metadata stream.
4243 Within a metadata stream, two given clock class fragments {must-not}:
4245 * Share the same `name` property value.
4246 * Share the same `uuid` property value.
4248 .Minimal clock class fragment with 1-GHz instances.
4253 "type": "clock-class",
4254 "name": "my clock class",
4255 "frequency": 1000000000
4260 .Clock class fragment with a UUID property.
4265 "type": "clock-class",
4266 "name": "my clock class",
4267 "frequency": 1000000000,
4269 116, 210, 0, 140, 239, 255, 77, 3,
4270 129, 99, 233, 226, 134, 106, 207, 32
4276 .Clock class fragment with instances having a specific offset.
4281 "type": "clock-class",
4282 "name": "my clock class",
4283 "frequency": 1000000000,
4285 "seconds": 1605112699,
4292 .Clock class fragment with instances having a specific precision.
4297 "type": "clock-class",
4298 "name": "my clock class",
4299 "frequency": 8000000,
4305 .Clock class fragment with instances having an origin which isn't the Unix epoch.
4310 "type": "clock-class",
4311 "name": "my clock class",
4312 "frequency": 1000000000,
4313 "origin-is-unix-epoch": false
4318 .Clock class fragment with <<user-attrs,user attributes>>.
4323 "type": "clock-class",
4324 "name": "my clock class",
4325 "frequency": 16000000,
4326 "user-attributes": {
4328 "sys-name": "SOC23",
4333 "propagation-delay-ps": 177
4343 A _clock offset_ contains the offset of the instances of a
4344 <<cc-frag,clock class>> relative to their origin.
4346 A clock offset is a JSON object.
4348 .Properties of a clock offset contained in a clock class fragment {var-f}.
4351 |Name |Type |Description |Required? |Default
4355 |Offset, in seconds, of an instance of{nbsp}{var-f} relative to its
4362 |Offset, in cycles, of an instance of{nbsp}{var-f} relative to its
4365 The value of this property {must} be greater than or equal to zero.
4367 The value of this property {must} be less than the value of the
4368 `frequency` property of{nbsp}{var-f}.
4373 .Minimal clock offset.
4381 .Clock offset with seconds and cycles.
4386 "seconds": 1605112699,
4392 .Clock offset with seconds only.
4397 "seconds": 1605111293
4402 .Negative clock offset.
4404 This example shows that a clock offset {may} be negative, that is,
4405 _before_ the origin of the clock.
4417 === Data stream class fragment
4419 A _data stream class_ describes <<ds,_data streams_>>.
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.
4425 .Properties of a data stream class fragment {var-f}.
4426 [%header%autowidth,cols="d,d,a,d,d"]
4428 |Name |Type |Description |Required? |Default
4432 |Type of{nbsp}{var-f}.
4434 The value of this property {must} be `"data-stream-class"`.
4440 |Numeric ID of{nbsp}{var-f}.
4442 The value of this property {must} be greater than or equal to zero.
4448 |Name of{nbsp}{var-f}.
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>>.
4454 |{var-f}{nbsp}is unnamed
4458 |<<ns-def,Namespace>> of{nbsp}{var-f}.
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>>.
4464 |{var-f}{nbsp}has no namespace
4466 |`default-clock-class-name`
4468 |Name of the <<cc-frag,class>> of the <<def-clk,default clock>> of an
4469 instance of{nbsp}{var-f}.
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}.
4475 |An instance of{nbsp}{var-f} has no default clock
4477 |`packet-context-field-class`
4479 |Class of all the <<pkt-ctx,packet context fields>> of an instance
4482 |{var-f}{nbsp}has no packet context field class
4484 |`event-record-header-field-class`
4486 |Class of all the <<er-header,event record header fields>> of an
4487 instance of{nbsp}{var-f}.
4489 Any field class as the value of this property {must} satisfy _at least
4492 * Have at least one valid <<er-header-roles,role>>.
4496 * Be the class of a field which is the selector field of an optional or
4499 |{var-f}{nbsp}has no event record header field class
4501 |`event-record-common-context-field-class`
4503 |Class of all the <<er-common-ctx,event record common context fields>>
4504 of an instance of{nbsp}{var-f}.
4506 |{var-f}{nbsp}has no event record common context field class
4509 |<<user-attrs,User attributes>>
4510 |User attributes of{nbsp}{var-f}.
4516 |Extensions of{nbsp}{var-f}.
4518 Any extension which exists under this property {must} also be declared
4519 in the <<preamble-frag,preamble fragment>> of the metadata stream.
4524 Within a metadata stream, two given data stream class fragments
4525 {must-not} share the same `id` property value.
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
4534 .Roles of field classes of the member classes of a packet context field class.
4535 [%header%autowidth,cols="d,d,a,a"]
4537 |Name |Description |Field class ({var-f}) constraints |Other constraints
4539 |`packet-total-size`
4540 |Total size (bits) of the <<pkt,packet>>.
4542 This size includes any padding after the packet contents.
4543 |{c-fl-uint-fc} or {vl-uint-fc}.
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
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
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}.
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.
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}.
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.
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}.
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}.
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
4598 .Roles of field classes of the member classes of an event record header field class.
4599 [%header%autowidth,cols="d,d,a"]
4601 |Name |Description |Field class ({var-f}) constraints
4603 |`event-record-class-id`
4604 |Event record class ID.
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
4609 |{c-fl-uint-fc} or {vl-uint-fc}.
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}.
4618 === Event record class fragment
4620 An _event record class_ describes <<er,_event records_>>.
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}.
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"]
4630 |Name |Type |Description |Required? |Default
4634 |Type of{nbsp}{var-f}.
4636 The value of this property {must} be `"event-record-class"`.
4642 |Numeric ID of{nbsp}{var-f} within{nbsp}{var-p}.
4644 The value of this property {must} be greater than or equal to zero.
4648 |`data-stream-class-id`
4650 |Numeric ID of{nbsp}{var-p}.
4652 The value of this property {must} be greater than or equal to zero.
4654 Within the metadata stream,{nbsp}{var-p} {must} occur
4655 before{nbsp}{var-f}.
4661 |Name of{nbsp}{var-f}.
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>>.
4667 |{var-f}{nbsp}is unnamed
4671 |<<ns-def,Namespace>> of{nbsp}{var-f}.
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>>.
4677 |{var-f}{nbsp}has no namespace
4679 |`specific-context-field-class`
4681 |Class of the <<er-spec-ctx,event record specific context field>>
4682 of an instance of{nbsp}{var-f}.
4684 |{var-f}{nbsp}has no event record specific context field class
4686 |`payload-field-class`
4688 |Class of the <<er-payload,event record payload field>> of an
4689 instance of{nbsp}{var-f}.
4691 |{var-f}{nbsp}has no event record payload field class
4694 |<<user-attrs,User attributes>>
4695 |User attributes of{nbsp}{var-f}.
4701 |Extensions of{nbsp}{var-f}.
4703 Any extension which exists under this property {must} also be declared
4704 in the <<preamble-frag,preamble fragment>> of the metadata stream.
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.
4714 == Data stream decoding procedure
4716 This section shows how to, procedurally, _decode_ a {ctf2} <<ds,data
4719 Decoding a data stream is the responsibility of a
4720 <<consumer-def,consumer>>.
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.
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
4730 .Variable needed to decode a data stream{nbsp}{var-s}.
4733 |Name |Type |Description |Initial value
4737 |Current decoding offset/position (bits) from the beginning
4742 To decode a data stream {var-s}:
4744 * While there's remaining data in {var-s}:
4745 ** <<pkt-dec,Decode one packet>>.
4748 === Packet decoding procedure
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_:
4754 .Variables needed to decode a packet{nbsp}{var-p} within a data stream{nbsp}{var-s}.
4757 |Name |Type |Description |Initial value
4761 |Current value (clock cycles) of the <<def-clk,default
4762 clock>> of{nbsp}{var-s}, if any.
4767 |Current ID of the <<dsc-frag,class>> of{nbsp}{var-s}.
4771 |Optional <<dsc-frag,data stream class>>
4772 |Current class of{nbsp}{var-s}.
4776 |Optional unsigned integer
4777 |Current ID of{nbsp}{var-s}.
4782 |Current total size (bits) of{nbsp}{var-p}.
4785 |_**PKT_CONTENT_SZ**_
4787 |Current content size (bits) of{nbsp}{var-p}.
4792 |Byte order of the last <<fl-ba-field-dec,decoded {fl-ba} field>>.
4796 To decode a packet {var-p} within a data stream {var-s}:
4798 . Let {var-dec-po} be the current value of {var-dec-o}.
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}.
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.
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`
4812 ** If _**C**_ has the role `packet-magic-number`, then validate that the
4813 unsigned integer value of{nbsp}{var-f} is 0xc1fc1fc1 (3254525889).
4815 A <<consumer-def,consumer>> {should} report an invalid packet magic
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
4822 A consumer {should} report a trace type UUID mismatch as an error.
4824 ** If _**C**_ has the role `data-stream-class-id`, then
4825 set{nbsp}__**DSC_ID**__ to the unsigned integer value
4828 ** If _**C**_ has the role `data-stream-id`, then
4829 set{nbsp}__**DS_ID**__ to the unsigned integer value
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.
4838 . Set _**DSC**_ to the <<dsc-frag,data stream class>>
4839 having{nbsp}__**DSC_ID**__ as the value of its `id` property.
4841 If no data stream class has the ID{nbsp}__**DSC_ID**__, then report an
4842 error and abort the data stream decoding process.
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.
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`
4852 ** If _**C**_ has the role `packet-total-size`, then
4853 set{nbsp}__**PKT_TOTAL_SZ**__ to the unsigned integer value
4856 ** If _**C**_ has the role `packet-content-size`, then
4857 set{nbsp}__**PKT_CONTENT_SZ**__ to the unsigned integer value
4860 ** If _**C**_ has the role `packet-beginning-default-clock-timestamp`,
4861 then set{nbsp}__**DEF_CLK_VAL**__ to the unsigned integer value
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}.
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}.
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}.
4878 A <<consumer-def,consumer>> {should} report a beginning default clock
4879 timestamp greater than an end default clock timestamp as an error.
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**__.
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**__.
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}:
4892 ** <<er-dec,Decode an event record>>.
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.
4900 === Event record decoding procedure
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_:
4906 .Variables needed to decode an event record{nbsp}__**E**__ within a data stream{nbsp}{var-s}.
4909 |Name |Type |Description |Initial value
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}.
4918 |Optional <<erc-frag,event record class>>
4919 |Current class of{nbsp}__**E**__.
4923 To decode an event record _**E**_ within a data stream {var-s}:
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.
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
4933 ** If _**C**_ has the role `event-record-class-id`, then
4934 set{nbsp}__**ERC_ID**__ to the unsigned integer value
4937 ** If _**C**_ has the role `default-clock-timestamp`, then
4938 <<clk-val-update,update{nbsp}__**DEF_CLK_VAL**__>> from{nbsp}{var-f}.
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.
4946 . Set _**ERC**_ to the <<erc-frag,event record class>> having:
4948 ** __**DSC_ID**__ as the value of its `data-stream-class-id` property.
4949 ** __**ERC_ID**__ as the value of its `id` property.
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.
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
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.
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.
4971 ==== Clock value update procedure
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**__:
4977 . Let __**L**__ be an unsigned integer initialized to,
4978 depending on the `type` property of{nbsp}__**C**__:
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**__.
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>>.
4992 . Let _**MASK**_ be an unsigned integer initialized to
4993 2^__**L**__^{nbsp}{minus}{nbsp}1.
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.
5000 . Let _**CUR**_ be an unsigned integer initialized to
5001 __**DEF_CLK_VAL**__{nbsp}&{nbsp}__**MASK**__, where "`&`" is the
5002 bitwise _AND_ operator.
5004 . Set __**DEF_CLK_VAL**__ to:
5007 If __**V**__{nbsp}≥{nbsp}__**CUR**__::
5008 __**H**__{nbsp}pass:[+]{nbsp}__**V**__
5011 __**H**__{nbsp}pass:[+]{nbsp}__**MASK**__{nbsp}pass:[+]{nbsp}1{nbsp}pass:[+]{nbsp}__**V**__
5015 === Field decoding procedure
5017 The <<fc,class>> of a field contains what's needed to decode it as a
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
5024 [[dec-val-type]] The types of values are:
5026 [%header%autowidth,cols="a,a"]
5028 |Value type |Possible values
5036 |Unsigned/signed integer
5040 |Continuous quantity.
5043 |<<seq-def,Sequence>> of https://home.unicode.org/[Unicode] characters.
5046 |Sequence of values.
5049 |Sequence of named values (members).
5052 To decode an instance of a field class{nbsp}{var-f}, depending on the
5053 value of its `type` property:
5055 [%header%autowidth,cols="a,a"]
5057 |Value of the `type` property of{nbsp}{var-f} |Decoding procedure of {var-f}
5059 |<<fl-ba-fc,`"fixed-length-bit-array"`>>
5060 |<<fl-ba-field-dec,Decode a {fl-ba} field>>.
5062 |<<fl-bool-fc,`"fixed-length-boolean"`>>
5063 |<<fl-bool-field-dec,Decode a {fl-bool} field>>.
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>>.
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>>.
5075 |<<fl-fp-fc,`"fixed-length-floating-point-number"`>>
5076 |<<fl-fp-field-dec,Decode a {fl-fp} field>>.
5078 |<<vl-ba-fc,`"variable-length-bit-array"`>>
5079 |<<vl-ba-field-dec,Decode a {vl-ba} field>>.
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>>.
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}>>.
5091 |<<str-fc,`"null-terminated-string"`>>
5092 |<<str-field-dec,Decode a {str} field>>.
5094 |<<sl-str-fc,`"static-length-string"`>>
5095 |<<sl-str-field-dec,Decode a {sl-str} field>>.
5097 |<<sl-blob-fc,`"static-length-blob"`>>
5098 |<<sl-blob-field-dec,Decode a {sl-blob} field>>.
5100 |<<dl-str-fc,`"dynamic-length-string"`>>
5101 |<<dl-str-field-dec,Decode a {dl-str} field>>.
5103 |<<dl-blob-fc,`"dynamic-length-blob"`>>
5104 |<<dl-blob-field-dec,Decode a {dl-blob} field>>.
5106 |<<struct-fc,`"structure"`>>
5107 |<<struct-field-dec,Decode a structure field>>.
5109 |<<sl-array-fc,`"static-length-array"`>>
5110 |<<sl-array-field-dec,Decode a {sl-array} field>>.
5112 |<<dl-array-fc,`"dynamic-length-array"`>>
5113 |<<dl-array-field-dec,Decode a {dl-array} field>>.
5115 |<<opt-fc,`"optional"`>>
5116 |<<opt-field-dec,Decode an optional field>>.
5118 |<<var-fc,`"variant"`>>
5119 |<<var-field-dec,Decode a variant field>>.
5123 ==== Alignment procedure
5125 The decoding procedure of many fields require
5126 {var-dec-o-minus-po} to have a specific _alignment_.
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:
5131 [%header,cols="a,a"]
5133 |`type` property of {var-f} |Alignment requirement of {var-f}
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}.
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"`>>
5158 |<<struct-fc,`"structure"`>>
5159 |The _maximum_ value of:
5161 * The value of the `minimum-alignment` property of{nbsp}{var-f}.
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}.
5168 * <<sl-array-fc,`"static-length-array"`>>
5169 * <<dl-array-fc,`"dynamic-length-array"`>>
5170 |The _maximum_ value of:
5172 * The value of the `minimum-alignment` property of{nbsp}{var-f}.
5174 * The alignment requirement of an instance of the
5175 `element-field-class` property of{nbsp}{var-f}.
5178 * <<opt-fc,`"optional"`>>
5179 * <<var-fc,`"variant"`>>
5183 To align {var-dec-o-minus-po} to some alignment
5184 requirement{nbsp}__**A**__ (bits):
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.
5191 ==== Field location procedure
5193 To locate a previously decoded field using a
5194 <<field-loc,field location>>{nbsp}__**FL**__:
5196 . Let {var-v} be, depending on the first element of{nbsp}__**FL**__:
5200 The <<pkt-header,header>> structure of{nbsp}__**P**__
5201 (<<pkt-dec,current packet>>).
5203 `"packet-context"`::
5204 The <<pkt-ctx,context>> structure of{nbsp}__**P**__.
5206 `"event-record-header"`::
5207 The <<er-header,header>> structure of{nbsp}__**E**__
5208 (<<er-dec,current event record>>).
5210 `"event-record-common-context"`::
5211 The <<er-common-ctx,common context>> structure of{nbsp}__**E**__.
5213 `"event-record-specific-context"`::
5214 The <<er-spec-ctx,specific context>> structure of{nbsp}__**E**__.
5216 `"event-record-payload"`::
5217 The <<er-payload,payload>> structure of{nbsp}__**E**__.
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.
5224 . For each element{nbsp}__**FLE**__ of{nbsp}__**FL**__, starting from
5227 .. Let {var-v} be the value of the member named{nbsp}__**FLE**__
5228 within{nbsp}{var-v}.
5230 If no member is named{nbsp}__**FLE**__ within{nbsp}{var-v}, then
5231 report an error and abort the data stream decoding process.
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.
5237 .. Depending on the <<dec-val-type,type>> of {var-v}:
5243 If{nbsp}__**FLE**__ is not the last element of{nbsp}__**FL**__,
5244 then report an error and abort the data stream decoding process.
5250 While {var-v} is an array:
5252 * If {var-v} is not currently being decoded, then report an error and
5253 abort the data stream decoding process.
5255 Set {var-v} to the element of {var-v} currently being decoded.
5258 Report an error and abort the data stream decoding process.
5261 {var-v} is the located field.
5263 .<<dl-array,{c-dl-array}>> field and its length field in the same root field.
5265 Assume the following JSON object is an event record payload {struct-fc}.
5270 "type": "structure",
5275 "type": "fixed-length-unsigned-integer",
5277 "byte-order": "little-endian"
5283 "type": "fixed-length-unsigned-integer",
5285 "byte-order": "little-endian"
5291 "type": "dynamic-length-array", <1>
5292 "length-field-location": ["event-record-payload", "corn"], <2>
5293 "element-field-class": {
5294 "type": "null-terminated-string"
5301 <1> {c-dl-array-fc}.
5302 <2> Length field location of the {dl-array-fc}.
5303 <3> Length member class.
5306 .{c-dl-array} field and its length field in the same root field, within the same array field element.
5308 Assume the following JSON object is an event record payload {struct-fc}.
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`.
5316 "type": "structure",
5321 "type": "null-terminated-string"
5327 "type": "static-length-array",
5329 "element-field-class": {
5330 "type": "structure",
5333 "name": "laser", <3>
5335 "type": "variable-length-unsigned-integer"
5341 "type": "dynamic-length-array", <1>
5342 "length-field-location": [ <2>
5343 "event-record-payload",
5347 "element-field-class": {
5348 "type": "null-terminated-string"
5359 <1> {c-dl-array-fc}.
5360 <2> Length field location of the {dl-array-fc}.
5361 <3> Length member class.
5364 .{c-dl-array} and its length field in the same root field, within the same <<var-fc,variant>> field.
5366 Assume the following JSON object is an event record payload {struct-fc}.
5368 Both the {dl-array} field and its length field exist within the same
5369 option of the <<var-fc,variant>> field named `clinic`.
5371 Moreover, the selector field of the `clinic` variant field is the
5377 "type": "structure",
5380 "name": "lawyer", <5>
5382 "type": "fixed-length-signed-integer",
5384 "byte-order": "little-endian"
5391 "selector-field-location": ["event-record-payload", "lawyer"], <4>
5394 "selector-field-ranges": [[0, 0]],
5396 "type": "null-terminated-string"
5400 "selector-field-ranges": [[1, 4]],
5402 "type": "structure",
5405 "name": "lemon", <3>
5407 "type": "fixed-length-unsigned-integer",
5409 "byte-order": "big-endian"
5415 "type": "dynamic-length-array", <1>
5416 "length-field-location": [ <2>
5417 "event-record-payload",
5421 "element-field-class": {
5422 "type": "null-terminated-string"
5430 "selector-field-ranges": [[5, 5], [7, 7]],
5432 "type": "fixed-length-boolean",
5434 "byte-order": "little-endian"
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.
5450 .{c-dl-array} and its length field in the same root field; length field is a variant field.
5452 Assume the following JSON object is an event record payload {struct-fc}.
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.
5458 Moreover, the selector field of the variant field is located in another
5459 root field (event record specific context).
5464 "type": "structure",
5467 "name": "glass", <3>
5470 "selector-field-location": ["event-record-specific-context", "sel"],
5473 "selector-field-ranges": [[0, 0]],
5475 "type": "fixed-length-unsigned-integer", <4>
5477 "byte-order": "little-endian"
5481 "selector-field-ranges": [[1, 1]],
5483 "type": "fixed-length-unsigned-integer", <4>
5485 "byte-order": "little-endian"
5489 "selector-field-ranges": [[2, 2]],
5491 "type": "fixed-length-unsigned-integer", <4>
5493 "byte-order": "little-endian"
5502 "type": "dynamic-length-array", <1>
5503 "length-field-location": ["event-record-payload", "glass"], <2>
5504 "element-field-class": {
5505 "type": "null-terminated-string"
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.
5518 .{c-dl-array} and its length field in the same root field; structure field containing length field is a variant field.
5520 Assume the following JSON object is an event record payload {struct-fc}.
5522 The length field of the {dl-array} field is within a structure field
5523 which is a variant field.
5527 * The selector field of the variant field is located in another root
5528 field (event record common context).
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.
5538 "type": "structure",
5544 "selector-field-location": ["event-record-common-context", "sel"],
5547 "selector-field-ranges": [[0, 0]],
5549 "type": "structure",
5554 "type": "fixed-length-unsigned-integer", <3>
5556 "byte-order": "little-endian"
5562 "type": "null-terminated-string"
5569 "selector-field-ranges": [[32, 172]],
5571 "type": "structure",
5576 "type": "null-terminated-string"
5582 "type": "fixed-length-unsigned-integer", <3>
5584 "byte-order": "big-endian"
5591 "selector-field-ranges": [[5, 5]],
5593 "type": "structure",
5596 "name": "eagle", <5>
5598 "type": "variable-length-unsigned-integer" <3>
5604 "type": "dynamic-length-blob",
5605 "length-field-location": [ <4>
5606 "event-record-payload",
5621 "type": "dynamic-length-array", <1>
5622 "length-field-location": [ <2>
5623 "event-record-payload",
5627 "element-field-class": {
5628 "type": "null-terminated-string"
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}.
5641 Note that both the {dl-array} and {dl-blob} field classes have the same
5642 length field location.
5645 .{c-dl-array} and its length field in another root field.
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>>.
5651 The length field of the {dl-array} field of the event record payload is
5652 within the event record specific context.
5654 .Event record specific context field class.
5658 "type": "structure",
5663 "type": "fixed-length-floating-point-number",
5665 "byte-order": "little-endian"
5669 "name": "vegetable", <1>
5671 "type": "variable-length-unsigned-integer"
5677 <1> Length member class.
5679 .Event record payload field class.
5683 "type": "structure",
5688 "type": "dynamic-length-array", <1>
5689 "length-field-location": [ <2>
5690 "event-record-specific-context",
5693 "element-field-class": {
5694 "type": "null-terminated-string"
5701 "type": "null-terminated-string"
5707 <1> {c-dl-array-fc}.
5708 <2> Length field location of the {dl-array-fc}.
5712 ==== {c-fl-ba} field decoding procedure
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}.
5718 [[fl-ba-field-dec-bit]] To read a single data stream bit from an
5719 instance of{nbsp}{var-f}:
5723 ** _**BYTE_I**_ be ({var-dec-o-minus-po}){nbsp}/{nbsp}8 (integral
5724 division; remainder discarded).
5730 _**BO**_ is `"big-endian"`::
5731 7{nbsp}{minus}{nbsp}(({var-dec-o-minus-po}){nbsp}mod{nbsp}8)
5733 _**BO**_ is `"little-endian"`::
5734 ({var-dec-o-minus-po}){nbsp}mod{nbsp}8
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):
5746 The bit value is _false_.
5749 The bit value is _true_.
5752 To decode an instance of{nbsp}{var-f}:
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.
5760 . <<align-dec,Align {var-dec-o-minus-po}>> according
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.
5768 . While __**I**__{nbsp}<{nbsp}__**L**__:
5770 .. Let _**VI**_ be an unsigned integer initialized to:
5773 _**BO**_ is `"big-endian"`::
5776 _**BO**_ is `"little-endian"`::
5777 __**L**__{nbsp}{minus}{nbsp}__**I**__{nbsp}{minus}{nbsp}1
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>>.
5782 .. Set __**I**__ to __**I**__{nbsp}+{nbsp}1.
5784 .. Set {var-dec-o} to {var-dec-o}{nbsp}+{nbsp}1.
5786 . Set _**LAST_BO**_ to{nbsp}__**BO**__.
5788 {var-v} is the decoded bit array value.
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**__:
5796 `"big-endian"`:: {empty}
5798 image::{doc-id}-images/bit-array-decoding-be.svg[]
5800 `"little-endian"`:: {empty}
5802 image::{doc-id}-images/bit-array-decoding-le.svg[]
5804 .Contiguous {fl-ba} fields: big-endian versus little-endian.
5806 This example shows the binary layout of contiguous big-endian and
5807 little-endian {fl-ba} fields.
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
5813 Considering the following <<struct-member-cls,member classes>> of some
5822 "type": "fixed-length-bit-array",
5824 "byte-order": "big-endian"
5830 "type": "fixed-length-bit-array",
5832 "byte-order": "big-endian"
5838 "type": "fixed-length-bit-array",
5840 "byte-order": "big-endian"
5846 "type": "fixed-length-bit-array",
5848 "byte-order": "big-endian"
5854 The binary layout is as such:
5856 image::{doc-id}-images/bit-array-fields-be.svg[]
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:
5868 "type": "fixed-length-bit-array",
5870 "byte-order": "little-endian"
5876 "type": "fixed-length-bit-array",
5878 "byte-order": "little-endian"
5884 "type": "fixed-length-bit-array",
5886 "byte-order": "little-endian"
5892 "type": "fixed-length-bit-array",
5894 "byte-order": "little-endian"
5900 The binary layout is as such:
5902 image::{doc-id}-images/bit-array-fields-le.svg[]
5905 .Padding between {fl-ba} fields.
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
5911 Assume that {var-dec-o-minus-po}{nbsp}={nbsp}32.
5913 Considering the following <<struct-member-cls,member classes>> of some
5922 "type": "fixed-length-bit-array",
5924 "byte-order": "big-endian"
5930 "type": "fixed-length-bit-array",
5932 "byte-order": "big-endian",
5939 "type": "fixed-length-bit-array",
5941 "byte-order": "big-endian",
5948 The binary layout is as such:
5950 image::{doc-id}-images/bit-array-fields-padding-be.svg[]
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:
5962 "type": "fixed-length-bit-array",
5964 "byte-order": "little-endian"
5970 "type": "fixed-length-bit-array",
5972 "byte-order": "little-endian",
5979 "type": "fixed-length-bit-array",
5981 "byte-order": "little-endian",
5988 The binary layout is as such:
5990 image::{doc-id}-images/bit-array-fields-padding-le.svg[]
5993 .Contiguous {fl-ba} fields with different byte orders.
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.
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.
6003 This example shows how contiguous {fl-ba} fields may have different byte
6004 orders with correct <<align-dec,alignment>>.
6006 Assume that {var-dec-o-minus-po}{nbsp}={nbsp}16.
6008 Considering the following <<struct-member-cls,member classes>> of some
6017 "type": "fixed-length-bit-array",
6019 "byte-order": "big-endian"
6025 "type": "fixed-length-bit-array",
6027 "byte-order": "big-endian"
6033 "type": "fixed-length-bit-array",
6035 "byte-order": "little-endian"
6041 "type": "fixed-length-bit-array",
6043 "byte-order": "little-endian"
6049 "type": "fixed-length-bit-array",
6051 "byte-order": "big-endian",
6058 The binary layout is as such:
6060 image::{doc-id}-images/bit-array-fields-be-le.svg[]
6063 [[fl-bool-field-dec]]
6064 ==== {c-fl-bool} field decoding procedure
6066 To decode an instance of a {fl-bool-fc}:
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**__
6073 Else, set __**VB**__ to _true_.
6075 _**VB**_ is the decoded boolean value.
6077 [[fl-uint-field-dec]]
6078 ==== {c-fl-uint} field decoding procedure
6080 To decode an instance of a {fl-uint-fc}:
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
6088 _**VI**_ is the decoded unsigned integer value.
6090 [[fl-sint-field-dec]]
6091 ==== {c-fl-sint} field decoding procedure
6093 To decode an instance of a {fl-sint-fc}:
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.
6101 _**VI**_ is the decoded signed integer value.
6104 ==== {c-fl-fp} field decoding procedure
6106 To decode an instance of a {fl-fp-fc}:
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.
6114 _**VR**_ is the decoded real value.
6117 ==== {c-vl-ba} field decoding procedure
6119 To decode an instance of a {vl-ba-fc}{nbsp}{var-f}:
6121 . Let {var-v} be an empty array of booleans.
6123 . <<align-dec,Align {var-dec-o-minus-po}>> according
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.
6132 . Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}__**N**__{nbsp}{times}{nbsp}8.
6134 {var-v} is the decoded value.
6136 .3-byte {vl-ba} field decoding.
6138 Consider the following {vl-ba-fc}{nbsp}{var-f}:
6143 "type": "variable-length-bit-array"
6147 The following diagram shows the three bytes of an instance
6148 of{nbsp}{var-f} and the resulting bit array value.
6150 image::{doc-id}-images/vl-ba.svg[]
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.
6157 [[vl-uint-field-dec]]
6158 ==== {c-vl-uint} field decoding procedure
6160 To decode an instance of a {vl-uint-fc}:
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.
6167 _**VI**_ is the decoded unsigned integer value.
6169 [[vl-sint-field-dec]]
6170 ==== {c-vl-sint} field decoding procedure
6172 To decode an instance of a {vl-sint-fc}:
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.
6180 _**VI**_ is the decoded signed integer value.
6183 ==== {c-str} field decoding procedure
6185 To decode an instance of a {str-fc}{nbsp}{var-f}:
6188 ** _**B**_ be a byte.
6189 ** _**A**_ be an empty sequence of bytes.
6190 ** {var-v} be a string.
6192 . <<align-dec,Align {var-dec-o-minus-po}>> according
6195 . Read one byte of data from{nbsp}{var-s} at the offset{nbsp}{var-dec-o}
6198 . Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}8.
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.
6206 . Decode _**A**_, following UTF-8, as {var-v}.
6208 {var-v} is the decoded string value.
6210 .22-byte {str} field decoding.
6212 Consider the following {str-fc}{nbsp}{var-f}:
6217 "type": "null-terminated-string"
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.
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.
6228 image::{doc-id}-images/str.svg[]
6230 The field contains 21{nbsp}UTF-8 bytes and a null terminating byte.
6232 The resulting string value contains 19{nbsp}Unicode characters.
6234 After the field is decoded, {var-dec-o-minus-po}{nbsp}={nbsp}516,552.
6237 [[sl-str-field-dec]]
6238 ==== {c-sl-str} field decoding procedure
6240 To decode an instance of a {sl-str-fc}{nbsp}{var-f}:
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.
6250 . <<align-dec,Align {var-dec-o-minus-po}>> according
6253 . While __**I**__{nbsp}<{nbsp}__**L**__:
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_.
6259 Else, if _**R**_ is _true_, then append{nbsp}__**B**__
6262 .. Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}8.
6263 .. Set _**I**_ to __**I**__{nbsp}pass:[+]{nbsp}1.
6265 . Decode _**A**_, following UTF-8, as {var-v}.
6267 {var-v} is the decoded string value.
6269 .18-byte {sl-str} field decoding.
6271 Consider the following {str-fc}{nbsp}{var-f}:
6276 "type": "static-length-string",
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.
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.
6287 image::{doc-id}-images/sl-str.svg[]
6289 The field contains 14{nbsp}UTF-8 bytes, a null terminating byte,
6290 and three garbage data bytes to ignore.
6292 The resulting string value contains seven Unicode characters.
6294 After the field is decoded, {var-dec-o-minus-po}{nbsp}={nbsp}287,424.
6297 [[sl-blob-field-dec]]
6298 ==== {c-sl-blob} field decoding procedure
6300 To decode an instance of a {sl-blob-fc}{nbsp}{var-f}:
6303 .. _**L**_ be the `length` property of{nbsp}{var-f}.
6304 .. {var-v} be an array of bytes of length{nbsp}__**L**__.
6306 . <<align-dec,Align {var-dec-o-minus-po}>> according
6309 . Read _**L**_ bytes of data from{nbsp}{var-s} at the
6310 offset{nbsp}{var-dec-o} as{nbsp}{var-v}.
6312 . Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}__**L**__{nbsp}{times}{nbsp}8.
6314 {var-v} is the decoded BLOB value.
6316 [[dl-str-field-dec]]
6317 ==== {c-dl-str} field decoding procedure
6319 To decode an instance of a {dl-str-fc}{nbsp}{var-f}:
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.
6331 . <<align-dec,Align {var-dec-o-minus-po}>> according
6334 . While __**I**__{nbsp}<{nbsp}__**L**__:
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_.
6340 Else, if _**R**_ is _true_, then append{nbsp}__**B**__
6343 .. Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}8.
6344 .. Set _**I**_ to __**I**__{nbsp}pass:[+]{nbsp}1.
6346 . Decode _**A**_, following UTF-8, as {var-v}.
6348 {var-v} is the decoded string value.
6350 [[dl-blob-field-dec]]
6351 ==== {c-dl-blob} field decoding procedure
6353 To decode an instance of a {dl-blob-fc}{nbsp}{var-f}:
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**__.
6361 . <<align-dec,Align {var-dec-o-minus-po}>> according
6364 . Read _**L**_ bytes of data from{nbsp}{var-s} at the
6365 offset{nbsp}{var-dec-o} as{nbsp}{var-v}.
6367 . Set {var-dec-o} to {var-dec-o}{nbsp}pass:[+]{nbsp}__**L**__{nbsp}{times}{nbsp}8.
6369 {var-v} is the decoded BLOB value.
6371 [[struct-field-dec]]
6372 ==== Structure field decoding procedure
6374 To decode an instance of a {struct-fc}{nbsp}{var-f}:
6377 ** _**M**_ be the `member-classes` property of{nbsp}{var-f}.
6378 ** {var-v} be an empty structure.
6380 . <<align-dec,Align {var-dec-o-minus-po}>> according
6383 . For each member class{nbsp}__**MC**__ of{nbsp}__**M**__:
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**__.
6390 {var-v} is the decoded value.
6392 [[sl-array-field-dec]]
6393 ==== {c-sl-array} field decoding procedure
6395 To decode an instance of a {sl-array-fc}{nbsp}{var-f}:
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**__.
6403 . <<align-dec,Align {var-dec-o-minus-po}>> according
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.
6411 {var-v} is the decoded value.
6413 [[dl-array-field-dec]]
6414 ==== {c-dl-array} field decoding procedure
6416 To decode an instance of a {dl-array-fc}{nbsp}{var-f}:
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**__
6426 . <<align-dec,Align {var-dec-o-minus-po}>> according
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.
6434 {var-v} is the decoded value.
6436 .5-element {dl-array} field decoding.
6438 Consider the following <<er-payload,event record payload>>
6439 {struct-fc}{nbsp}{var-f}:
6444 "type": "structure",
6449 "type": "fixed-length-unsigned-integer",
6451 "byte-order": "big-endian"
6457 "type": "null-terminated-string"
6464 "type": "dynamic-length-array",
6465 "length-field-location": ["event-record-payload", "len"],
6466 "element-field-class": {
6467 "type": "fixed-length-unsigned-integer",
6469 "byte-order": "little-endian",
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.
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.
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.
6489 image::{doc-id}-images/dl-array.svg[]
6491 The unsigned integer value of the `len` field is{nbsp}5, which means the
6492 `vals` field contains five {fl-sint} fields.
6494 After the structure field is decoded,
6495 {var-dec-o-minus-po}{nbsp}={nbsp}136,928.
6499 ==== Optional field decoding procedure
6501 To decode an instance of an {opt-fc}{nbsp}{var-f}:
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.
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**__
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**__
6521 {var-v} is the decoded value.
6524 ==== Variant field decoding procedure
6526 To decode an instance of an {var-fc}{nbsp}{var-f}:
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.
6539 . <<field-dec,Decode>> one instance of{nbsp}__**OF**__
6542 {var-v} is the decoded value.