|
libe3 0.6.1
C++ library for E3AP RAN vendor integration
|
This chapter describes how an implementation turns every E2SM-DAPP information element into bytes. It gives worked examples that an implementer can check against the reference test vectors, the size limits and the type map.
The index is README.md. The field lists are in 02-ie-mapping.md. The validation rules are in 05-semantics-and-constraints.md. Code references, product names and build switches are in integrator-guide.md.
An implementation shall encode each E2SM-DAPP information element as one ASN.1 value with APER (ASN.1 Packed Encoding Rules, aligned variant, X.691). It shall carry the value as the content of an OCTET STRING in the E2AP message. E2AP does the framing. E2SM-DAPP adds no header, no length prefix, no checksum and no version byte of its own.
Table: ASN.1 type that each E2AP field carries
| E2AP field that carries it | ASN.1 type that is encoded into it |
|---|---|
| RAN Function Definition (E2 Setup Request, RIC Service Update) | E2SM-DAPP-RANFunctionDefinition |
| RIC Event Trigger Definition (RIC Subscription Request) | E2SM-DAPP-EventTrigger |
| RIC Action Definition (RIC Subscription Request) | E2SM-DAPP-ActionDefinition |
| RIC Indication Header (RIC Indication) | E2SM-DAPP-IndicationHeader |
| RIC Indication Message (RIC Indication) | E2SM-DAPP-IndicationMessage |
| RIC Control Header (RIC Control Request) | E2SM-DAPP-ControlHeader |
| RIC Control Message (RIC Control Request) | E2SM-DAPP-ControlMessage |
| RIC Control Outcome (RIC Control Acknowledge) | E2SM-DAPP-ControlOutcome |
The grammar is in the last clause of this chapter. Its module identifier is E2SM-DAPP-IEs {... oran(53148) e2(1) version1(1) e2sm(255) e2sm-DAPP-IEs (3)}, so the OID is 1.3.6.1.4.1.53148.1.1.255.3.
Plain and FlatBuffers encodings do not exist. A conforming stack encodes APER. Some implementations ship unused stubs for the other encodings.
Table: APER bits for each ASN.1 construct
| Construct in the grammar | APER bits | Where it appears |
|---|---|---|
| SEQUENCE { ... } with ... | 1 extension bit (0), then one presence bit per OPTIONAL field, then the fields | every SEQUENCE |
| CHOICE { a, ... } with one alternative | 1 extension bit, no index bits | event trigger, action definition, control header, control message, control outcome |
| CHOICE { a, b, ... } with two alternatives | 1 extension bit, then 1 index bit (0 = first, 1 = second) | indication header, indication message |
| INTEGER (0..4294967295, ...) | 1 extension bit, then a 2-bit field holding (number of octets - 1), then pad to the octet boundary, then the value in 1 to 4 octets, big-endian, no leading zero octets | ran-function-id, dapp-id, node-nb-id, node-cu-du-id, SubscribedE3RANFunction-ID |
| INTEGER (0..255, ...) | 1 extension bit, pad, 1 octet | node-type |
| INTEGER (0..32768) (no ...) | pad, 2 octets big-endian | data-size |
| INTEGER with no bounds | pad, 1 length octet, then the value as the fewest two's-complement octets, big-endian | Timestamp, SequenceId, RIC-Style-Type, RIC-Format-Type, ranFunction-Instance |
| OCTET STRING (SIZE(3)) | pad, 3 octets, no length | node-plmn-id |
| OCTET STRING (SIZE(1..32768)) | pad, 2-octet length holding (length - 1), then the octets | data in indication message format 1 and control message format 1 |
| OCTET STRING with no bounds | pad, length determinant, then the octets. Length 0..127: 1 octet. Length 128..16383: 2 octets with the top two bits 10. Longer: fragmentation in 16 KiB blocks | e3-control-outcome |
| PrintableString (SIZE(1..150, ...)) | 1 extension bit, an 8-bit field holding (length - 1), pad, one octet per character | short name, description, style names |
| PrintableString (SIZE(1..1000, ...)) | 1 extension bit, pad, a 2-octet field holding (length - 1), one octet per character | ranFunction-E2SM-OID |
| SEQUENCE (SIZE(1..64)) OF | a 6-bit count holding (count - 1), then the elements | subscribed-e3-ran-functions |
| SEQUENCE (SIZE(0..256)) OF | pad, a 2-octet count, then the elements | DAppE3Subscription-List |
| SEQUENCE (SIZE(1..2)) OF | a 1-bit count holding (count - 1) | report style list |
| SEQUENCE (SIZE(1..1)) OF | no bits for the count | control style list |
Notes on the table.
Table: Byte order, padding and length prefixes
| Topic | Rule |
|---|---|
| Byte order | APER is a bit stream, written most significant bit first. Multi-octet integers and lengths are big-endian. There is nothing host-endian on the wire. |
| Padding | Encoders write zero pad bits. The last octet is padded with zero bits to a whole octet. |
| Struct packing | None on the wire. Native structures in memory are the implementation's own business. |
| Length prefixes | Only where the table above says so. E2SM-DAPP never prefixes a whole element with its length. |
| Extension markers | Written as 0. The next subsection says what a receiver does with 1. |
| Trailing data | APER has no end marker. A decoder checks that the decode succeeded. It does not need to check that it consumed every octet, and several implementations ignore trailing octets. A receiver should not rely on a sender to append nothing. |
The grammar has no extension additions yet, so every extension bit that a conforming sender writes is 0. A future version could add fields after the ... marker. A decoder that meets extension bit 1 has three options, and implementations pick differently.
Table: Handling of extension bit 1 on a SEQUENCE
| Implementation | Extension bit 1 on a SEQUENCE |
|---|---|
| A (generated codec) | The decoder reads the extension bitmap and skips additions that it does not know. The value decodes with the added fields ignored. |
| B (hand-written codec) | The decoder reads the additions as opaque open types (X.691 19.7 to 19.9) and drops them. The encoder refuses a structure with the extension flag set. |
A CHOICE alternative beyond the defined ones (a future format 3) is not skipped by any implementation. The decode fails.
An extension bit of 1 on a constrained INTEGER (0..4294967295, ...) means that the value is outside the root range and uses a different encoding. Implementations reject it. See 05-semantics-and-constraints.md.
Table: Size constants of the grammar
| Grammar constant | Value | What it bounds |
|---|---|---|
| maxE2SMDAPPIndMsgSize | 32768 | data in indication message format 1, and data-size |
| maxE2SMDAPPCtrlMsgSize | 32768 | data in control message format 1, and data-size |
| maxnoofDApps | 256 | items in a DAppE3Subscription-List |
| maxnoofSubscribedE3RANFunctions | 64 | functions in one DAppE3Subscription-Item |
| maxnoofDAPPReportStyles | 2 | items in ric-ReportStyle-List |
| maxnoofDAPPControlStyles | 1 | items in ric-ControlStyle-List |
The next table gives the smallest and the largest encodings. The smallest values are reference test vectors. The largest values assume 64-bit signed timestamps and sequence ids (what every implementation holds) and ids of 4294967295. They follow from the encoding rules. The names in the Notes column are reference test vectors.
Table: Smallest and largest encodings
| Element | Smallest | Largest | Notes |
|---|---|---|---|
| Event trigger | 1 octet | 1 octet | vector et_f1 |
| Action definition | 4 octets | 8 octets | vectors ad_style1, ad_style_max |
| Indication header format 1 | 12 octets | 44 octets | ih1_min is a vector. The 44 differs from the 41 of ih1_bounds only because that vector uses ran-function-id 0 (2 octets) where the maximum uses 4294967295 (5 octets). |
| Indication header format 2 | 7 octets | 33 octets | ih2_min |
| Indication message format 1 | 6 octets | 32773 octets | overhead is 5 octets; im1_one, im1_max |
| Indication message format 2 | 3 octets (empty list) | 83459 octets | 256 items of 64 functions, every id 4294967295. A list of 256 items with one such function each is 2819 octets. Vector im2_256 (first item 64 functions, the rest one, small ids) is 1473. |
| Control header format 1 | 4 octets | 28 octets | ch1_min; ch1_bounds (25 octets) has dapp-id 0 |
| Control message format 1 | 6 octets | 32773 octets | overhead is 5 octets |
| Control outcome format 1 | 1 octet | 19 octets without a payload; the payload adds its own length and its 1 or 2 length octets | co1_min, co1_tsseq |
| RAN function definition | 78 octets | large: the dApp map is listed once per style that carries it | fd_min; the OID and name strings dominate the minimum |
Format 2 is the one element that can be larger than 32768 octets, because the grammar bounds only the number of items, not the encoded size of the list.
Implementation limits are tighter than the grammar. An implementation can encode into fixed buffers and fail when an element does not fit. The buffers range from 1 KiB for an action definition to 512 KiB for an event trigger, and one implementation limits a control message to about 16 KiB, although the grammar allows 32768 octets. For this reason the reference test vector cm1_large stops at 16000 octets. A sender that wants to work with every implementation should keep a control message below 16 KiB. The details are in integrator-guide.md.
All the bytes below are reference test vectors. They were produced by the encoder of a reference implementation. Every example here was re-derived by hand from the grammar and the encoding rules. All 31 vectors (27 inline and 4 by length and hash) were also reproduced by an independent bit-level encoder, which agreed byte for byte.
Reading the tables: a row is a run of bits in stream order. pad is alignment padding. Bit groups are written MSB first.
One octet. The event trigger has one format and no fields.
Table: Bits of the event trigger et_f1
| Bits | Meaning |
|---|---|
| 0 | E2SM-DAPP-EventTrigger extension bit |
| 0 | ric-eventTrigger-formats CHOICE extension bit (one alternative, so no index bits) |
| 0 | E2SM-DAPP-EventTrigger-Format1 extension bit (the SEQUENCE has no fields and no OPTIONAL) |
| 00000 | pad to the octet boundary |
Table: Octets of the action definition ad_style1
| Octet | Bits | Meaning |
|---|---|---|
| 0 | 0 + 0000000 | E2SM-DAPP-ActionDefinition extension bit, then pad (the next item is an unbounded integer, whose length is octet-aligned) |
| 1 | 00000001 | length determinant: 1 octet follows |
| 2 | 00000001 | ric-Style-Type = 1 |
| 3 | 0 0 000000 | actionDefinition-formats CHOICE extension bit, Format1 SEQUENCE extension bit, pad |
ad_style2 is the same with 02 in octet 2. ad_style_max = 00 05 00 ff ff ff ff 00 has length 5 and the value 00 ff ff ff ff (4294967295 needs a leading zero octet in two's complement), then the same closing octet.
Input: ran-function-id 255, dapp-id 1, node-type 0, node-plmn-id 13 00 14, node-nb-id 0, no node-cu-du-id, no timestamp, no sequence-id.
Table: Octets of the indication header ih1_min
| Octet(s) | Bits | Meaning |
|---|---|---|
| 0 | 0 | E2SM-DAPP-IndicationHeader extension bit |
| 0 | ric-indicationHeader-formats extension bit | |
| 0 | alternative index, 2 alternatives so 1 bit: 0 = indicationHeader-Format1 | |
| 0 | Format1 SEQUENCE extension bit | |
| 0 0 0 | presence bits: node-cu-du-id, timestamp, sequence-id all absent | |
| 0 | ran-function-id INTEGER extension bit (value is in the root range) | |
| 1 | 00 + 000000 | ran-function-id: number of octets minus 1 = 0, then pad |
| 2 | ff | ran-function-id = 255 |
| 3 | 0 00 + 00000 | dapp-id: extension bit, number of octets minus 1 = 0, pad |
| 4 | 01 | dapp-id = 1 |
| 5 | 0 + 0000000 | node-type: extension bit, pad (range is exactly 256, so one aligned octet) |
| 6 | 00 | node-type = 0 |
| 7-9 | 13 00 14 | node-plmn-id, three raw octets, no length |
| 10 | 0 00 + 00000 | node-nb-id: extension bit, number of octets minus 1 = 0, pad |
| 11 | 00 | node-nb-id = 0 |
Total 12 octets. The first octet is entirely header bits: the whole presence map and the first extension bit of the first integer fit in it.
Same shape, with all three optional fields present. Differences from ih1_min:
Table: Octets of the indication header ih1_full
| Octet(s) | Bits or bytes | Meaning |
|---|---|---|
| 0 | 0000 111 + 0 | extensions 0, 0, index 0, SEQUENCE extension 0, then presence bits 1 1 1, then the ran-function-id extension bit 0. The octet is 0x0e. |
| 1-2 | 00 ff | ran-function-id = 255 |
| 3-4 | 00 07 | dapp-id = 7 |
| 5-6 | 00 02 | node-type = 2 |
| 7-9 | 00 f1 10 | node-plmn-id |
| 10-12 | 20 04 d2 | node-nb-id = 1234: extension bit 0, number of octets minus 1 = 01 (two octets), so bits 0 01 + pad = 0x20, then 04 d2 |
| 13-14 | 00 05 | node-cu-du-id = 5 (present) |
| 15-23 | 08 17 97 9c fe 3d 85 cd 15 | timestamp: length 8, value 0x17979cfe3d85cd15 = 1700000000123456789 ns, which is 2023-11-14 22:13:20.123456789 UTC |
| 24-25 | 01 2a | sequence-id = 42 |
Input: ran-function-id 1, dapp-id 2.
Table: Octets of the control header ch1_min
| Octet | Bits | Meaning |
|---|---|---|
| 0 | 0 | E2SM-DAPP-ControlHeader extension bit |
| 0 | ric-controlHeader-formats extension bit (one alternative, no index) | |
| 0 | Format1 SEQUENCE extension bit | |
| 0 0 | presence bits: timestamp, sequence-id absent | |
| 0 | ran-function-id extension bit | |
| 00 | number of octets minus 1 = 0 (the length field closes the octet, so there is no pad here) | |
| 1 | 01 | ran-function-id = 1 |
| 2 | 0 00 + 00000 | dapp-id: extension bit, length field, pad |
| 3 | 02 | dapp-id = 2 |
Compare with ih1_min: the control header has one choice alternative and two OPTIONAL fields, so the preamble is 5 bits instead of 7 and the first octet is completely full.
This is the outcome that carries the Service-Model payload.
Table: Octets of the control outcome co1_full
| Octet(s) | Bits or bytes | Meaning |
|---|---|---|
| 0 | 0 0 0 | E2SM-DAPP-ControlOutcome extension bit; ric-controlOutcome-formats extension bit (one alternative); Format1 extension bit |
| 1 1 1 | presence bits: timestamp, sequence-id, e3-control-outcome all present | |
| 00 | pad before the first octet-aligned item. The octet is 000 111 00 = 0x1c. | |
| 1 | 08 | timestamp length: 8 octets |
| 2-9 | 17 97 9c fe 3d 85 cd 15 | timestamp = 1700000000123456789 |
| 10 | 01 | sequence-id length: 1 octet |
| 11 | 2a | sequence-id = 42 |
| 12 | 0a | e3-control-outcome length: 10 octets |
| 13-22 | 10 20 30 40 50 60 70 80 90 a0 | the opaque Service-Model payload, copied unchanged |
23 octets. The three smaller outcomes show how the presence bits move:
Table: Smaller control outcome vectors
| Vector | Hex | Presence bits | Why |
|---|---|---|---|
| co1_min | 00 | 000 | acknowledge only: three zero extension bits, three zero presence bits, two pad bits |
| co1_tsseq | 18 08 17979cfe3d85cd15 01 2a | 110 | octet 0 = 000 110 00 |
| co1_payload | 04 0a 10 20 30 40 50 60 70 80 90 a0 | 001 | octet 0 = 000 001 00 |
e3-control-outcome is an OCTET STRING, and the Spectrum Service Model fills it with its own APER encoding of Spectrum-ApplyOutcomeData (02-ie-mapping.md). So a received outcome has two independent APER values, one inside the other:
The inner value starts on an octet boundary and its bit alignment is its own: it is decoded from its first octet as if it were a standalone message. The same tunnel is used by ControlMessage-Format1.data (xApp to RAN) and IndicationMessage-Format1.data (RAN to xApp).
Table: Octets of the indication message im1_small
| Octet(s) | Bits or bytes | Meaning |
|---|---|---|
| 0 | 0 0 0 0 + 0000 | E2SM-DAPP-IndicationMessage extension bit; ric-indicationMessage-formats extension bit; index bit 0 = Format1; Format1 extension bit; pad |
| 1-2 | 00 04 | data-size = 4. The integer (0..32768) has a range above 256, so it takes two aligned octets. |
| 3-4 | 00 03 | data length minus 1 = 3, two aligned octets (the size range 1..32768 is above 256 too) |
| 5-8 | de ad be ef | data |
data-size and the octet-string length both carry the payload size.
Table: Octets of the indication message im2_one
| Octet(s) | Bits or bytes | Meaning |
|---|---|---|
| 0 | 0 0 1 0 + 0000 | extension bit, extension bit, index bit 1 = Format2, Format2 extension bit, pad before the 2-octet list count. The octet is 0x20. |
| 1-2 | 00 01 | DAppE3Subscription-List count = 1 |
| 3 | 0 0 00 + 0000 | DAppE3Subscription-Item extension bit; dapp-id extension bit; dapp-id length field (octets minus 1 = 0); pad |
| 4 | 01 | dapp-id = 1 |
| 5-6 | 000000 0 0 / 0 + 0000000 | 6-bit function count minus 1 = 0; the function id's extension bit; the first bit of its 2-bit length field (octet 5 ends here); then the second bit of the length field and pad (octet 6). Both octets are 00. |
| 7 | 01 | function id = 1 |
Octets 5 and 6 show a bit field spanning the octet boundary: the first length bit is the last bit of octet 5 and the second is the first bit of octet 6.
00 10 45 32 53 4d 2d 44 41 50 50 00 00 1a 31 2e 33 2e 36 2e 31 2e 34 2e 31 2e 35 33 31 34 38 2e 31 2e 31 2e 32 35 35 2e 33 11 00 44 41 50 50 20 53 65 72 76 69 63 65 20 4d 6f 64 65 6c 20 66 6f 72 20 45 32 2f 45 33 20 62 72 69 64 67 65
Table: Octets of the RAN function definition fd_min
| Octet(s) | Meaning |
|---|---|
| 0 | bit 0: E2SM-DAPP-RANFunctionDefinition extension bit. Bits 1-3: presence bits for event trigger, report, control, all 0. Bit 4: RANfunction-Name extension bit. Bit 5: its ranFunction-Instance presence bit. Bit 6: short-name extension bit. Bit 7: first bit of the 8-bit short-name length field. All 0, so the octet is 00. |
| 1 | the other 7 bits of the length field, then 1 pad bit. Length minus 1 = 8 = 00001000, so the first bit is 0 (in octet 0) and the rest are 0001000, then pad 0: 0001 0000 = 10. |
| 2-10 | E2SM-DAPP (45 32 53 4d 2d 44 41 50 50), nine characters |
| 11 | 00: the OID string's extension bit, then pad |
| 12-13 | 00 1a: OID length minus 1 = 26 (the OID 1.3.6.1.4.1.53148.1.1.255.3 has 27 characters) |
| 14-40 | the OID as characters |
| 41-42 | 11 00: description extension bit 0, then the 8-bit length minus 1 = 34 (00100010), then pad. As bits: 0 00100010 0000000, which is 11 00 |
| 43-77 | DAPP Service Model for E2/E3 bridge, 35 characters |
The other three definition vectors add the optional sections:
Table: Other RAN function definition vectors
| Vector | Octets | Content |
|---|---|---|
| fd_min | 78 | name only |
| fd_report | 143 | name, report section with two styles (style 2 carries a subscription map of dApps 7 and 9) |
| fd_ctrl | 101 | name, event trigger section (empty), control section with one style, no map |
| fd_full | 175 | name, empty event trigger section, two report styles (style 2 with a map), one control style with a map |
The reference test vectors are encoded values with the inputs that produce them. An implementer uses them to check a codec. Vectors too large to inline carry a length and an FNV-1a 64-bit hash instead. The offset basis is 14695981039346656037, and the prime is 1099511628211.
Table: Reference test vectors
| Vector | Element | Input | Octets |
|---|---|---|---|
| et_f1 | event trigger | format 1 | 1 |
| ad_style1 | action definition | style 1 | 4 |
| ad_style2 | action definition | style 2 | 4 |
| ad_style_max | action definition | style 4294967295 | 8 |
| ih1_full | indication header 1 | all optional fields | 26 |
| ih1_min | indication header 1 | no optional fields | 12 |
| ih1_bounds | indication header 1 | id fields at 0 and 4294967295, node-type 255, timestamp and sequence-id INT64_MAX | 41 |
| ih2_full | indication header 2 | all optional fields | 21 |
| ih2_min | indication header 2 | no optional fields | 7 |
| im1_small | indication message 1 | 4 octets of payload | 9 |
| im1_one | indication message 1 | 1 octet of payload | 6 |
| im1_max | indication message 1 | 32768 octets (pattern i*7+3) | 32773, hash 0xf1a4af710fb93cc5 |
| im2_empty | indication message 2 | empty list | 3 |
| im2_one | indication message 2 | one dApp, one function | 8 |
| im2_multi | indication message 2 | two dApps, three and two functions, ids at 0 and 4294967295 | 25 |
| im2_255 | indication message 2 | 255 dApps, first one with 63 functions | 1464, hash 0x19011514fbcfc2de |
| im2_256 | indication message 2 | 256 dApps, first one with 64 functions | 1473, hash 0x74d95212a317dbb8 |
| ch1_full | control header | all optional fields | 15 |
| ch1_min | control header | no optional fields | 4 |
| ch1_bounds | control header | ran-function-id 4294967295, dapp-id 0, timestamp and sequence-id INT64_MAX | 25 |
| cm1_small | control message | 3 octets of payload | 8 |
| cm1_one | control message | 1 octet of payload | 6 |
| cm1_large | control message | 16000 octets (pattern i*13+5) | 16005, hash 0x5250310ee619ccfe |
| co1_full | control outcome | timestamp, sequence-id, 10-octet payload | 23 |
| co1_min | control outcome | nothing | 1 |
| co1_tsseq | control outcome | timestamp and sequence-id | 12 |
| co1_payload | control outcome | payload only | 12 |
| fd_min | RAN function definition | name only | 78 |
| fd_report | RAN function definition | report section | 143 |
| fd_full | RAN function definition | all sections | 175 |
| fd_ctrl | RAN function definition | control section | 101 |
Properties that these vectors pin down:
The vectors do not cover: extension bit 1, a ranFunction-Instance, an e3-control-outcome longer than 127 octets (two-octet length form), a PLMN that is not three bytes, a timestamp with the top bit set, and any invalid input.
Implementations hold the grammar types in different native types. This clause lists the typical choices and the traps. Field names in the C++ and the C structures of a codec can follow the grammar names exactly, so that the same names work across implementations.
Table: Typical native types for the fields
| ASN.1 field | Typical native type | Note |
|---|---|---|
| ran-function-id, dapp-id, node-nb-id (0..4294967295) | unsigned 32-bit or 64-bit integer | Use 64 bits when 4294967295 shall stay positive in a signed language. |
| node-type (0..255) | unsigned 8-bit integer | |
| node-plmn-id (SIZE(3)) | array of 3 octets | |
| node-cu-du-id OPTIONAL | presence flag and an unsigned integer | |
| timestamp OPTIONAL | presence flag and a signed 64-bit integer | One implementation treats 0 as absent. |
| sequence-id OPTIONAL | presence flag and a signed 64-bit integer | One implementation treats 0 as absent. |
| data-size (0..32768) | unsigned 16-bit integer | Some implementations drop the field and use the length of data. |
| data | octet string, size 1..32768 | |
| e3-control-outcome OPTIONAL | presence flag and an octet string with no bounds | One implementation treats a null pointer and a size of 0 as absent. |
| ric-style-type, format and style types | signed 64-bit integer | The grammar has no bounds for these types. |
| ranFunction-Instance OPTIONAL | presence flag and a signed 64-bit integer | One encoder rejects a present instance. |
| the format choice | enumeration | The wire format numbers start at 1. |
Two traps:
To check a stack, an implementer encodes every input of the reference test vectors and compares the output with the expected bytes. Then the implementer decodes every expected value and compares the result with the input. The checklist and the way to regenerate the vectors are in integrator-guide.md.
The ASN.1 definition of E2SM-DAPP conforms to ITU-T Rec. X.680 and ITU-T Rec. X.681. If the ASN.1 definition contradicts a table in this specification, the ASN.1 definition takes precedence.