From OpenTTCN DocZone

Jump to: navigation, search

  OpenTTCN DocZone

  Home | Developer's corner | Knowledge base | Working documents | Documentation | Tutorials | Training | How do I | Frequently asked questions | Technical support


Last modified September 30, 2008

Using ASN.1 Information Object Classes and Type Parameterization



Use of ASN.1 Information Object Classes and ASN.1 type parameterization is best illustrated by the example contained in two modules, ASN.1 module PDU-Definitions.asn1 and TTCN-3 module Main.ttcn.

You can download PDU-Definitions.asn1 and Main.ttcn used in this example:

  • using Firefox: press right mouse button and select: Save Link As...
  • using Internet Explorer: press right mouse button and select: Save Target As...

To compile the example, type:

importer3 load ioc_test PDU-Definitions.asn1
importer3 load ioc_test Main.ttcn

You also need an echo (robo) adapter before running tests that can be started as follows:

start robo -q -s 127.0.0.1:5500:ioc_test TRI TRI

To run tests, you can type the following command:

tester run ioc_test @all

The example is based on definitions used in the S1AP protocol.

ASN.1 part of the example (PDU-Definitions.asn1) is structured as explained in subsequent sections.

Contents

Information Object Class Definition

Consider the following portion of PDU-Definitions.asn1:

PROTOCOL-ELEMS ::= CLASS
{
    &id             ProtocolElem-ID UNIQUE,
    &priority       Priority,
    &Value,
    &conditionality Conditionality
}
WITH SYNTAX
{
    ID                  &id
    PRIORITY            &priority
    TYPE                &Value
    CONDITIONALITY      &conditionality
}

The PROTOCOL-ELEMS Information Object Class defines fixed-type fields id, priority and conditionality, as well as Value field which is of open type (mapped to TTCN-3 anytype).

Information Object Classes are not directly importable into TTCN-3, however they are used by ASN.1 module compiler internally to resolve types of fields of conventional ASN.1 types that refer to Information Object Class fields as part of type definition.

The WITH SYNTAX clause defines syntax used to define Information Object Set elements, ies-Set-Element-1 and ies-Set-Element-2.

Information Object Set Specification

Consider the following portion of PDU-Definitions.asn1:

ies-Set-Element-1 PROTOCOL-ELEMS ::=
{
    ID 0
    PRIORITY low
    TYPE INTEGER
    CONDITIONALITY mandatory
}

ies-Set-Element-2 PROTOCOL-ELEMS ::=
{
    ID 1
    PRIORITY high
    TYPE IA5String
    CONDITIONALITY optional
}

Elems-Set PROTOCOL-ELEMS ::= { ies-Set-Element-1 | ies-Set-Element-2 }

Elems-Set defines a set of logical interdependencies between fields of an Information Object Class. Multiple sets of this kind can be defined. Information Object Set defines interdependencies at semantic level of a protocol and is therefore not exploited directly in TTCN-3.

Information Object Set can be used to verify validity and consistency of values of corresponding ASN.1 types parameterized with Information Object Set in question, although this requirement is not enforced by the TTCN-3 standard.

Parameterized ASN.1 Types

Consider the following portion of PDU-Definitions.asn1:

ProtocolElem-ContainerList
{INTEGER : lowerBound, INTEGER : upperBound, PROTOCOL-ELEMS : ElemsSetParam} ::=
    SEQUENCE (SIZE (lowerBound..upperBound)) OF
    ProtocolElem-SingleContainer {{ElemsSetParam}}

ProtocolElem-SingleContainer {PROTOCOL-ELEMS : ElemsSetParam} ::= 
    ProtocolElem-Field {{ElemsSetParam}}

ProtocolElem-Field {PROTOCOL-ELEMS : ElemsSetParam} ::= SEQUENCE
{
    id                  PROTOCOL-ELEMS.&id            ({ElemsSetParam}),
    priority            PROTOCOL-ELEMS.&priority      ({ElemsSetParam}{@id}),
    val                 PROTOCOL-ELEMS.&Value         ({ElemsSetParam}{@id})
}

ProtocolElem-ContainerList is parameterized with value formal parameters lowerBound and upperBound, as well as with Information Object Set formal parameter ElemsSetParam.

ProtocolElem-Field parameterized ASN.1 type uses references to fields of Information Object Class PROTOCOL-ELEMS to define types of its fields. Value interdependencies between fields of ProtocolElem-Field are further constrained by an Information Object Set specification passed as a formal parameter.

Parameterized ASN.1 types cannot be exploited directly in TTCN-3. A type instance with the list of actual parameters must be defined in ASN.1 module in order to make ASN.1 type parameterization usable in TTCN-3.

Parameterized ASN.1 Type Instances

Consider the following portion of PDU-Definitions.asn1:

ProtocolElem-ContainerList-1 ::= ProtocolElem-ContainerList{ 1, 2, Elems-Set }
ProtocolElem-ContainerList-2 ::= ProtocolElem-ContainerList{ 3, 4, Elems-Set }

ProtocolElem-ContainerList-1 and ProtocolElem-ContainerList-2 type definitions are directly usable in a TTCN-3 module.

A typical usage scenario is illustrated below:

var ProtocolElem_ContainerList_1 v1;

v1[0] :=
{
    id := 0,
    priority := low,
    val := { integer := 10 }
}

v1[1] :=
{
    id := 1,
    priority := high,
    val := { charstring := "HELLO" }
}

See also

Information Object Classes (ASN.1)

Views
Personal tools