Professional Documents
Culture Documents
Spring 2014
TOC
Simple Types
These are the basic types:
BOOLEAN
INTEGER
BIT STRING
ENUMERATED
PRINTABLESTRING
NUMERICSTRING
...
Structured Types
Built using type constructors:
SEQUENCE
SEQUENCE OF
SET
SET OF
CHOICE
Structured TypeSEQUENCE
A SEQUENCE in ASN.1 is similar to a struct in C++ or a class
with data fields only (without methods). In other words, a
SEQUENCE is a data structure that contains values of several
types. The order of the values is important.
Example
PDU ::= SEQUENCE{
header HeaderType,
body PDUBody
}
The example above defines a type called PDU. It means that a value of
type PDU will contain a value called header whose type is HeaderType,
and a value called body whose type is PDUBody. This definition should
be followed by the definitions of both types: HeaderType and PDUBody.
7
Tags
Consider the example:
Example
IntSeq ::=SEQUENCE{
number [0] INTEGER OPTIONAL,
count [1] INTEGER OPTIONAL,
order [2] INTEGER DEFAULT 0
}
Suppose during a protocol exchange, a sender sent to a receiver
the value 7 5, the receiver needs to know if 7 is the value of
number or count. Both values have the same type
(INTEGER), so there needs to be some extra information that
helps identify both values. For this we add extra tagsthe values
in square brackets shown above. So inside the sequence, 0
identifies number, 1 identifies count, etc.
9
Structured TypeSEQUENCE OF
10
Structured TypeCHOICE
11
12
ASN.1 Modules
13
ASN.1 ModuleStructure
h module-name i DEFINTIONS ::=
BEGIN
IMPORTS h list of types i FROM h module-name i
h type definitions are put here i
END
A module has a name followed by the keyword DEFINTIONS. The
type definitions are put between the two keywords BEGIN and END.
The IMPORTS keyword makes it possible to use types defined in
another module (the one whose name comes after the keyword
FROM). The names of these types should be listed between
IMPORTS and FROM.
14
ASN.1 ModuleExample
protocol-def DEFINTIONS ::=
BEGIN
PDU ::= SEQUENCE{
header HeaderType,
body PDUBody
}
HeaderType::= SEQUENCE OF Header-part
Header-part::= SEQUENCE{
part-code NumericString(SIZE(16)),
part-data NumericString(SIZE(16))
}
PDUBody::= CHOICE{
request Request-type,
response Response-type
}
Request-type::= . . .
Response-type::= . . .
...
END
15
16
Object Definitions
17
18
SEQUENCE {
JvmPositive32TC,
JvmJavaObjectNameTC,
JvmValidityStateTC
19
Assignment
20