| | 1 | == ASN.1 Support == |
| | 2 | Initial Abstract Syntax Notation 1 (ASN.1) support has been added to T3Q in version 2.1.0b4. It relies the compiler from [Eclipse TITAN](https://projects.eclipse.org/projects/tools.titan), which needs to be installed separately. The path to the `compiler` executable needs to be specified in the corresponding configuration entry in the profile (**`titanCompilerPath`**) which is set to `compiler` by default, assuming that the compiler executable is included in the system path and readily executable from any location. If that is not the case, the correct path needs to be specified in the profile. |
| | 3 | |
| | 4 | === Stages === |
| | 5 | |
| | 6 | The use of ASN.1 definitions is a two-stage process: |
| | 7 | |
| | 8 | 1. Collect all ASN.1 files (file extension `.asn`) in the input path and convert them to a JSON Schema with the Eclipse TITAN compiler (option `--convert-asn1-to-schema`). |
| | 9 | 2. Generate corresponding TTCN-3 modules for each ASN.1 file from the JSON Schema produced by the Eclipse TITAN compiler (option `--convert-schemas`). |
| | 10 | |
| | 11 | Each stage can be executed independently with the corresponding option. If both options are provided, they are executed in the order listed above. The Eclipse TITAN compiler is only required for the first stage. |
| | 12 | |
| | 13 | The first stage produces an `asn.json` file in the current working folder where T3Q is executed, which contains the definitions from all the input ASN.1 files. The second stage uses the `asn.json` file and generate one TTCN-3 file in the current working folder for each ASN.1 file with the following convention `asn.json.<MODULE_NAME>.ttcn`, where `MODULE_NAME` is the generated TTCN-3 name corresponding to the ASN.1 file. If both stages are executed together, T3Q takes care of passing on the generated files from one stage to the next. If only the second stage is executed, then the `asn.json` file needs to be provided as part of the input paths for T3Q. The generated files will be overwritten between runs. |
| | 14 | |
| | 15 | If the ASN.1 files do not change or if Eclipse TITAN is not available on the used platform / computer, the generated TTCN-3 files can be used directly by including them into the input path. For example, running T3Q with the first stage on a folder that contains `ModuleA.asn` and `ModuleB.asn` (even deeply nested) produces an `asn.json` file in the current working folder which contains all the definitions from both `ModuleA.asn` and `ModuleB.asn` as a JSON Schema. e.g.: |
| | 16 | |
| | 17 | {{{ |
| | 18 | java -Xmx3g -Xss512m -jar t3q.jar --convert-asn1-to-schema --config config/t3q-tf160-next.xml --profile stf160Profile "iwd-TTCN3-B2024-06_D25wk24/NR5GC_IWD_25wk24" |
| | 19 | }}} |
| | 20 | |
| | 21 | If only the first stage is selected, only the `asn.json` file is generated and the corresponding references cannot be resolved yet. Therefore, it makes sense to run the first stage with only the ASN.1 files as input. It is best to add all the necessary ASN.1 files as input rather than processing individual files one at a time, as unresolved dependencies between ASN.1 files would result in failure to generate the `asn.json` file, e.g: |
| | 22 | |
| | 23 | {{{ |
| | 24 | java -Xmx3g -Xss512m -jar t3q.jar --convert-asn1-to-schema --config config/t3q-tf160-next.xml --profile stf160Profile \ "iwd-TTCN3-B2024-06_D25wk24/NR5GC_IWD_25wk24/Common/POS/LPP_PDU_Definitions.asn" \ |
| | 25 | "iwd-TTCN3-B2024-06_D25wk24/NR5GC_IWD_25wk24/Common/SuppServices/Common_Definitions_Arguments.asn" \ |
| | 26 | "iwd-TTCN3-B2024-06_D25wk24/NR5GC_IWD_25wk24/Common/SuppServices/LCS_Definitions_Arguments.asn" \ |
| | 27 | "iwd-TTCN3-B2024-06_D25wk24/NR5GC_IWD_25wk24/Common/NR_Defs/NR_Sidelink_Preconf.asn" \ |
| | 28 | "iwd-TTCN3-B2024-06_D25wk24/NR5GC_IWD_25wk24/Common/NR_Defs/NR_PC5_RRC_Definitions.asn" \ |
| | 29 | "iwd-TTCN3-B2024-06_D25wk24/NR5GC_IWD_25wk24/Common/NR_Defs/NR_RRC_ASN1_Definitions.asn" |
| | 30 | }}} |
| | 31 | |
| | 32 | Given that `LCS_Definitions_Arguments` depends on `Common_Definitions_Arguments`, leaving `Common_Definitions_Arguments` out will result in a failure to produce an `asn.json` file. |
| | 33 | |
| | 34 | Running T3Q with the second stage, including `asn.json` as input produces `asn.json.ModuleA.ttcn` and `asn.json.ModuleB.ttcn` files in the current working folder, which are then added to the input paths and considered during the evaluation of the other TTCN-3 files, e.g. using the `asn.json` file generated above: |
| | 35 | |
| | 36 | {{{ |
| | 37 | java -Xmx3g -Xss512m -jar t3q.jar --convert-schemas --config config/t3q-tf160-next.xml --profile stf160Profile "asn.json" |
| | 38 | }}} |
| | 39 | |
| | 40 | produces the corresponding TTCN-3 files `asn.json.Common_Definitions_Arguments.ttcn`, `asn.json.NR_Sidelink_Preconf.ttcn`, `asn.json.LCS_Definitions_Arguments.ttcn`, `asn.json.NR_PC5_RRC_Definitions.ttcn`, and `asn.json.NR_RRC_ASN1_Definitions.ttcn`. These can then be used in a subsequent runs by adding them to the input paths without the need to convert the ASN.1 / JSON Schema again. These can also be shared with other users that do not have Eclipse TITAN available. Running T3Q with the `asn.json` file in addition to the TTCN-3 files referencing the ASN.1 definitions as input with integrate the generated files and consider them during the evaluation of the non-generated TTCN-3 files. |
| | 41 | |
| | 42 | The generated files should be excluded from the evaluation otherwise there may be warnings related to them which are not really relevant as the files are generated from ASN.1 and it might also take a longer to process them. The configuration profiles should therefore include a corresponding pattern in **`ignoredResourceRegExp`**, e.g. `(.*asn[.]json[.].*ttcn)`. |
| | 43 | |
| | 44 | === Remote usage for Stage 1 === |
| | 45 | |
| | 46 | If Eclipse TITAN is not available for the first stage (e.g. due to compatibility, platform, or other concerns), T3Q has the option `--serve-asn1-compiler` to provide the first stage remotely, e.g. on another computer on online server which can run Eclipse TITAN and is reachable from the local computer. Two steps are necessary: |
| | 47 | |
| | 48 | 1. Run T3Q on the remote computer that has Eclipse TITAN installed with the option `--serve-asn1-compiler` which will expose an HTTP endpoint `/compile_asn` at port `3005`, which accepts `POST` requests carrying the ASN.1 files and provides a response carrying the resulting `asn.json` file after running the Eclipse TITAN compiler. |
| | 49 | 2. Update the **`titanCompilerPath`** setting in the configuration profile to point to the endpoint on the remote computer `http://<IP or DOMAIN>:3005/compile_asn` and run T3Q on the local computer that does not have Eclipse TITAN available with the `--convert-asn1-to-schema` option (or also adding the `--convert-schemas` option for an integrated run). |
| | 50 | |
| | 51 | Instead of running Eclipse TITAN locally, T3Q will connect to the remote computer and send the ASN.1 files included in the input paths. It can then proceed with the received `asn.json` file as if it were generated locally. |
| | 52 | |
| | 53 | === Limitations === |
| | 54 | |
| | 55 | There are some restrictions due to upstream issues with Eclipse TITAN (for example parameterised types), which affect the generated schema and TTCN-3 modules. These will be investigated and resolved in future releases. |
| | 56 | |
| | 57 | The remote functionality is experimental and not yet ready for public deployment. It is intended to bridge circumstances where Eclipse TITAN is not available locally. If needed, authentication and further features can be added to make it more robust and publicly deployable. |
| | 58 | |
| | 59 | As ASN.1 files often include thousands of definitions, resolving and processing these definitions, especially in a single file can impact the overall duration of processing. If quick feedback is desired or the duration is a concern, preliminary check without ASN.1 support is sufficient for most quality checks as they do not rely on ASN.1 definitions. Some checks such as `checkNoUninitializedFieldsInTemplates` benefit from the ASN.1 definitions as otherwise templates for types defined in ASN.1 cannot be checked. |