Skip to content

ASN.1 encoder ​

Encodes typed records into an ASN.1 BER file (for example telecom CDR files). Flow types are generated from an ASN.1 module definition, the same way the ASN.1 decoder does it; every record received on Input is encoded and appended to the current file, which is emitted on Output.

Pins ​

PinKindTypesDescription
Inputinputgenerated root type (<flow namespace>.<RootType>)One record per call.
OutputoutputViaducta.Plugins.Files.Types.ViaFileStreamThe encoded file, emitted when its batch ends, per record without a batch, or when the file reaches MaxFileOpenTime (records without a batch). Name is CDR-<yyyyMMdd-HHmmss>-<file sequence, 10 digits><ext> (TS 32.297) or ASN-<yyyyMMdd-HHmmss>-<file number since start, 6 digits><ext> (raw), UTC.

Configuration ​

FieldTypeDefaultDescription
AsnDefinitionASN.1 module (editor)The module text. Triggers reconfigure.
RootTypeNametype (type selector)Full name of the record type. Set automatically by reconfigure; triggers reconfigure.
Encodingdropdown: BERBERBER with definite lengths.
Modedropdown: 1 STRICT, 2 RELAXED21 stops on the first record that can't be encoded; 2 logs it and skips the record.
MaxDepthinteger (1-9999)99Maximum nesting depth of a record, protects against cyclic object graphs.
Framingdropdown: NONE, TS32297NONENONE writes concatenated TLV records; TS32297 writes a 3GPP TS 32.297 CDR file.
MaxFileOpenTimeinteger, ms (0-86400000)0Records without a batch only: 0 = a file per record; otherwise the records go into one file emitted once it has been open (since its first record) this long.
FileExtensiontext.berExtension set on the produced ViaFileStream.
ReleaseIdentifierinteger (0-7)7TS 32.297 release identifier for the file and CDR headers. 7 writes ReleaseIdentifierExtension.
ReleaseIdentifierExtensioninteger (0-255)0TS 32.297 release identifier extension.
VersionIdentifierinteger (0-31)0TS 32.297 version identifier.
TsNumberinteger (0-31)0TS 32.297 TS number in the CDR header (for example 6 = TS 32.250, 7 = TS 32.251).
NodeIpAddresstextTS 32.297 IP address of the generating node (IPv4 or IPv6).
FileSequenceStartinteger0TS 32.297 file sequence number of the first file after start, incremented per file.
BatchScopebatch scope selectoremptyWhich batch goes into one file. Empty = the closest batch producer upstream (e.g. the records of one decoded file). A component id of a batch producer upstream = the batches of that producer. None = ignore batches (see MaxFileOpenTime).

Values ​

The encoder accepts the values the ASN.1 decoder produces, so decoded records can be re-encoded unchanged:

ASN.1Value
INTEGER, INTEGER64, BIGINTany integer type, BigInteger, integral string
ENUMERATEDgenerated enum, integer, or the item name
BOOLEANbool
NULLbool?: true = present, null/false = absent
OCTET STRINGhex string (decoder format) or byte[]
TBCD-STRINGdigit string (0-9 * # a b c, odd length padded with F) or byte[]
BIT STRINGBitArray, bool[], byte[] or a 0/1 string
character stringsstring, character set is validated
GeneralizedTime, UTCTimeDateTime (Unspecified = UTC, as decoded) or DateTimeOffset
REALdouble
CHOICEActiveChoice names the alternative; when empty exactly one alternative must be set
SEQUENCE OF, SET OFlist, SIZE constraints are checked

Behaviour ​

  • Reconfigure (changing AsnDefinition) generates the flow classes and picks the first SEQUENCE/SET/CHOICE no other type refers to as the root, written to RootTypeName and set on Input.
  • Members are written in definition order (SET members too, BER doesn't sort). Missing mandatory members, an unset CHOICE and SIZE violations fail the record with the member path in the message.
  • Tagged members are IMPLICIT unless declared EXPLICIT or of a CHOICE type, which matches how the decoder reads them.
  • Records in a batch (see BatchScope) are encoded into the file of their batch. When the whole batch has been processed the file is emitted with the metadata of the last record; it stays in the batch, so batch consumers behind it (Write file, ...) include it before they commit. When the batch failed the file is discarded (with TS 32.297 its file sequence number is used up). In STRICT mode a record that can't be encoded fails the batch. MaxFileOpenTime doesn't split batches.
  • Records without a batch (or BatchScope None): with MaxFileOpenTime 0 every record is emitted as a file of its own; otherwise they go into one shared file emitted by MaxFileOpenTime.
  • TS 32.297: CDR count, file length and timestamps (local time) are filled in when the file is closed; closure reason is 0 normal or 2 open time limit. Routing filter and private extension are empty.

Notes ​

  • Only BER (definite length). DER/CER/PER/OER are rejected at start.
  • A TS 32.297 CDR is limited to 65535 bytes (16 bit length field).
  • The file sequence number is not persisted, it restarts at FileSequenceStart on every flow start.
  • On flow stop, files of open batches are discarded (the batch is aborted) and records of the shared file are dropped with a warning.

Example ​

json
{ "Encoding": "BER", "Mode": "2", "Framing": "TS32297", "MaxFileOpenTime": 60000, "ReleaseIdentifier": 7, "ReleaseIdentifierExtension": 8, "TsNumber": 6, "NodeIpAddress": "10.1.2.3", "RootTypeName": "MyFlow.CallDataRecord" }

Data mapper → ASN.1 encoder → File writer

Viaducta documentation