Appearance
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
| Pin | Kind | Types | Description |
|---|---|---|---|
| Input | input | generated root type (<flow namespace>.<RootType>) | One record per call. |
| Output | output | Viaducta.Plugins.Files.Types.ViaFileStream | The 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
| Field | Type | Default | Description |
|---|---|---|---|
AsnDefinition | ASN.1 module (editor) | The module text. Triggers reconfigure. | |
RootTypeName | type (type selector) | Full name of the record type. Set automatically by reconfigure; triggers reconfigure. | |
Encoding | dropdown: BER | BER | BER with definite lengths. |
Mode | dropdown: 1 STRICT, 2 RELAXED | 2 | 1 stops on the first record that can't be encoded; 2 logs it and skips the record. |
MaxDepth | integer (1-9999) | 99 | Maximum nesting depth of a record, protects against cyclic object graphs. |
Framing | dropdown: NONE, TS32297 | NONE | NONE writes concatenated TLV records; TS32297 writes a 3GPP TS 32.297 CDR file. |
MaxFileOpenTime | integer, ms (0-86400000) | 0 | Records 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. |
FileExtension | text | .ber | Extension set on the produced ViaFileStream. |
ReleaseIdentifier | integer (0-7) | 7 | TS 32.297 release identifier for the file and CDR headers. 7 writes ReleaseIdentifierExtension. |
ReleaseIdentifierExtension | integer (0-255) | 0 | TS 32.297 release identifier extension. |
VersionIdentifier | integer (0-31) | 0 | TS 32.297 version identifier. |
TsNumber | integer (0-31) | 0 | TS 32.297 TS number in the CDR header (for example 6 = TS 32.250, 7 = TS 32.251). |
NodeIpAddress | text | TS 32.297 IP address of the generating node (IPv4 or IPv6). | |
FileSequenceStart | integer | 0 | TS 32.297 file sequence number of the first file after start, incremented per file. |
BatchScope | batch scope selector | empty | Which 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.1 | Value |
|---|---|
INTEGER, INTEGER64, BIGINT | any integer type, BigInteger, integral string |
ENUMERATED | generated enum, integer, or the item name |
BOOLEAN | bool |
NULL | bool?: true = present, null/false = absent |
OCTET STRING | hex string (decoder format) or byte[] |
TBCD-STRING | digit string (0-9 * # a b c, odd length padded with F) or byte[] |
BIT STRING | BitArray, bool[], byte[] or a 0/1 string |
| character strings | string, character set is validated |
GeneralizedTime, UTCTime | DateTime (Unspecified = UTC, as decoded) or DateTimeOffset |
REAL | double |
CHOICE | ActiveChoice names the alternative; when empty exactly one alternative must be set |
SEQUENCE OF, SET OF | list, SIZE constraints are checked |
Behaviour
- Reconfigure (changing
AsnDefinition) generates the flow classes and picks the firstSEQUENCE/SET/CHOICEno other type refers to as the root, written toRootTypeNameand set onInput. - Members are written in definition order (
SETmembers too, BER doesn't sort). Missing mandatory members, an unsetCHOICEandSIZEviolations fail the record with the member path in the message. - Tagged members are IMPLICIT unless declared
EXPLICITor of aCHOICEtype, 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). InSTRICTmode a record that can't be encoded fails the batch.MaxFileOpenTimedoesn't split batches. - Records without a batch (or
BatchScopeNone): withMaxFileOpenTime0every record is emitted as a file of its own; otherwise they go into one shared file emitted byMaxFileOpenTime. - TS 32.297: CDR count, file length and timestamps (local time) are filled in when the file is closed; closure reason is
0normal or2open 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
FileSequenceStarton 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