asn1c vs. X.691: where V2X stacks disagree on the bits
Most V2X stacks encode with asn1c, others with asn1tools or commercial compilers. In some ASN.1 constructs used by ETSI messages they disagree, and the same message comes out with different bits. What X.691 says in each case.
A large part of the European V2X world encodes its messages with code generated by asn1c: Vanetza is the best-known example, and many on-board and roadside stacks are built the same way. Commercial compilers and asn1tools are the other usual references. For most ETSI messages they all give exactly the same bits, the ones ITU-T X.691 (PER) specifies.
Not always. While building asn1click we found constructs, used in current ETSI messages, where the tools disagree. Sometimes asn1c is the one that departs from X.691; sometimes it is the one that follows it. Either way the result is the worst kind of interoperability bug: a message that one side encodes without complaint and the other side decodes wrongly or rejects.
1. Extension additions merged into the root
Some types have a root range plus values added later as extension additions, written after the ellipsis:
PathPredicted ::= SEQUENCE (SIZE(1..16, ..., 17..40)) OF PathPointPredicted -- ETSI CDD 4.x
X.691 encodes the extension bit and then, for a list of 1 to 16 points, the count in the root range: 4 bits. Only 17 to 40 points use the extension (bit set, then a general length). asn1c instead treats the type as if it were SIZE(1..40, ...): same extension bit, but the count takes 6 bits.
3 path points, X.691 : 0 0010 (extension bit + 4 bits) 3 path points, asn1c : 0 000010 (extension bit + 6 bits)
OSS Nokalva's compiler gives the 4-bit count too. Every list of this type comes out 2 bits longer, and everything after it is shifted. In the ETSI Common Data Dictionary (CDD 4.x) we found it in PathPredicted, DeltaPositions and DeltaReferencePositions, and the same rule applies to integers with an extension addition.
2. A second constraint removes the extension bit, and asn1c is right
The CPM wraps its containers in a list with an extensible size, and then constrains that list again with an inner subtype constraint (WITH COMPONENT), so that the originating vehicle and RSU containers do not appear together:
WrappedCpmContainers ::= SEQUENCE SIZE(1..8,...) OF WrappedCpmContainer
ConstraintWrappedCpmContainers ::= WrappedCpmContainers
((WITH COMPONENT (WITH COMPONENTS {..., containerId (ALL EXCEPT 1)})) |
(WITH COMPONENT (WITH COMPONENTS {..., containerId (ALL EXCEPT 2)}))) -- ETSI TS 103 324An inner subtype constraint on a list is not PER-visible (X.691 10.3.18), so it is tempting to ignore it and keep the extensible size with its extension bit. That is what asn1tools does. But X.691 10.3.20 says more: a constraint that is not PER-visible, applied after an extensible one, removes the extensibility of the earlier constraint (as X.680 50.11 specifies), and its note spells it out: such a type "is encoded without an extension bit". The size stays 1..8; the extension bit goes.
2 containers, X.691 and asn1c : 001 (count, 3 bits) 2 containers, asn1tools : 0 001 (extension bit + count)
So here asn1c (and with it Vanetza) follows the standard, and a stack built on asn1tools sends one bit more, which shifts everything after it. OSS Nokalva's ASN-1Step, which we also tried, rejected every value of this type, valid ones included, so it gives no verdict. The same rule applies to a list constrained in place, such aspathPredicted in PathPredicted2 (the path prediction of DENM 2.3.1 and of the CAM 2.3.1 path prediction container).
Who is right?
- Case 1 (extension additions): X.691 and OSS agree; asn1c departs from the standard.
- Case 2 (a second constraint on an extensible size): X.691 and asn1c agree; asn1tools departs from it.
In the field what matters is the peer you talk to. If the vehicle or roadside unit on the other side runs Vanetza or another asn1c-based stack, its bits are the asn1c ones, including in case 1. The practical rule:
- Testing conformance: use the standard encoding.
- Talking to Vanetza or another asn1c-based stack: use asn1c's encoding, or case 1 will not match.
- If a message decodes on one side and not on the other, check these constructs first.
A grey zone: the id of an open type
The CAM 2.3.1 extension containers carry an id, ExtensionContainerId ::= INTEGER (1..16,...), restricted by a table of the allowed containers. asn1c and OSS encode it without an extension bit; asn1tools with one. The table is a general constraint (X.682), and X.680 50.11 notes that general constraints do not affect the extensibility of the type, which favours the extension bit; read on its own, the note in X.691 10.3.20 points the other way. We keep the extension bit, and the asn1c mode encodes it as asn1c does.
Both encodings in asn1click
asn1click encodes by the standard by default and has an asn1c mode for the cases above. We check the asn1c mode against stock Vanetza, and the standard mode against asn1tools except where asn1tools departs from X.691 (case 2). Until 2 December 2026 our standard mode followed asn1tools in case 2; since then it follows X.691.
- Web tools: the encoding rules selector (X.691 standard or asn1c/Vanetza).
- API: the header
X-Compat: asn1c. - MCP, from Claude or any AI assistant: the
compatparameter, or just ask for "the Vanetza encoding".