Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
ASNP
1. ASN.1
Tomado de: http://www.obj-sys.
com/asn1tutorial/asn1only.html
2. Purpose of ASN.1
ASN.1 is a fundamental tool for use by
applications. It provides the ability to describe
the information that will be exchanged
independent of the way that information is
represented on each of the communicating
systems
3. Modules
The fundamental unit of ASN.1 is the module.
The sole purpose of a module is to name a
collection of type definitions and/or value
definitions (assignments) that constitute a data
specification.
A type definition is used to define and name a
new type by means of a type assignment and a
value definition is used to define and name a
specific value, when it is necessary, by means of
a value assignment.
4. Modules
Module reference optional object identifier
InventoryList {1 2 0 0 6 1} DEFINITIONS ::=
BEGIN
{ ItemId ::= SEQUENCE { partnumber IA5String,
quantity INTEGER,
wholesaleprice REAL,
saleprice REAL }
StoreLocation ::= ENUMERATED {
Baltimore (0),
Philadelphia (1),
Washington (2) }
} END
5. Type Assignment
InventoryList {1 2 0 0 6 1} DEFINITIONS ::=
BEGIN {
ItemId ::= SEQUENCE {
partnumber IA5String,
quantity INTEGER,
wholesaleprice REAL,
saleprice REAL }
StoreLocation ::= ENUMERATED {
Baltimore (0),
Philadelphia (1),
Washington (2)
} } END
Type reference (name of the type)
Component value
6. Value Assignment
A value assignment consists of a value reference
(the name of the value), the type of the value, ::=
(``is assigned the value''), and a valid value
notation.
gadget ItemId ::= {
partnumber "7685B2", quantity 73,
wholesaleprice 13.50,
saleprice 24.95 )
defines ``gadget" as a value of type ``ItemId".
7. Built-in Types
ASN.1 has built-in types that are simple and
structured. Structured types are composed of
component types, each of which is a simple or
structured type. A user-defined type is
composed of simple and structured types.
ASN.1 also has another category of types called
useful, which provide standard definitions for a
small number of commonly used types.
8. Simple Types
ASN.1 has built-in types that are simple and
structured. Structured types are composed of
component types, each of which is a simple or
structured type. A user-defined type is c
ASN.1 also has another category of types called
useful, which provide standard definitions for a
small number of commonly used types.
omposed of simple and structured types.
9. Simple Types
Type BOOLEAN takes values TRUE and FALSE.
Usually, the type reference for BOOLEAN
describes the true state.
For example:
Female ::= BOOLEAN
is preferable to
Gender ::= BOOLEAN.
10. Simple Types
Type INTEGER takes any of the infinite set of integer
values. It has an additional notation that names some of
the possible values of the integer. For example,
ColorType ::= INTEGER {
red (0)
white (1)
blue (2) }
indicates that the ``ColorType" is an INTEGER and its
values 0, 1, and 2 are named ``red", ``white", and ``blue",
respectively. The ColorType could also have any of the
other valid integer values, such as 4 or -62.
11. Simple Types
Type BIT STRING takes values that are an ordered
sequence of zero or more bits. The bit sequence is either
a binary or hexadecimal string delimited by single quotes
followed by B or H, respectively.
Occupation ::= BIT STRING{
clerk (0)
editor (1)
artist (2)
publisher (3) }
names the first bit ``clerk", the second bit ``editor", and
so on.
(editor, artist) and '0110'B are two representations for the
same value of ``Occupation".
12. Simple Types
• Type OCTET STRING takes values that are an
ordered sequence of zero or more eight-bit
octets.
• The sequence is written in the same form as a
BIT STRING sequence.
• Thus, `1101000100011010'B and `82DA'H are
valid values of OCTET STRING.
13. Simple Types
• Type OBJECT IDENTIFIER names information
objects (for example, abstract syntaxes or
ASN.1 modules).
• A list of positive numbers, enclosed in braces
and ordered by level starting from the root,
uniquely identifies an information object at a
node of the tree. This ordered list of positive
numbers delimited by braces is the value
notation for type OBJECT IDENTIFIER.
15. Simple Types
Type REAL takes values that are the machine
representation of a real number, namely the
triplet (m, b, e), where m is the mantissa (a
signed number), b the base (2 or 10), and e the
exponent (a signed number).
For example, the representation of the value
3.14 for the variable Pi, declared as
Pi ::= REAL,
can be
(314, 10, -2).
16. Simple Types
Type ENUMERATED is similar to the INTEGER
type, but names specific values only.
ColorType ::= ENUMERATED {
red (0)
white (1)
blue (2) }
ColorType can take only the values specifically in
the list;
17. Simple Types
Type CHARACTER STRING takes values that are
strings of characters from some defined (ISO- or
CCITT-registered) character set.
if Address is of type PrintableString, then
``Villanova, PA 19085'' is an Address value.
18. Structured Types
Type SEQUENCE is an ordered list of zero or more
component types. The type notation requires braces
around the list and permits a local identifier preceding
the list to act as the name of the sequence type.
There are two ways to specify that a component type is
optional in the ordered list: using OPTIONAL after the
component type and using DEFAULT followed by a value
after the component type. When DEFAULT is used, the
specified value is assumed whenever the type is absent
from the list. Any of the component types can be an
embedded sequence, in which case COMPOSED OF
precedes the embedded sequence.
19. Structured Types
The value notation for each sequence type is the list
of component values within braces.
{ airline "American",
flight "1106",
seats { 320, 107, 213 },
airport { origin "BWI", destination "LAX" },
crewsize 10 }
or
{ "American", "1106", { 320, 107, 213 }, { "BWI",
"LAX" }, 10 }
represent the same instance of the sequence type
20. Structured Types
The value notation for each sequence type is the list
of component values within braces.
{ airline "American",
flight "1106",
seats { 320, 107, 213 },
airport { origin "BWI", destination "LAX" },
crewsize 10 }
or
{ "American", "1106", { 320, 107, 213 }, { "BWI",
"LAX" }, 10 }
represent the same instance of the sequence type
22. Structured Types
Two components, Stop1 and Stop2 of the
sequence type airport are tagged with the
context-specific tags [0] and [1] to avoid
ambiguity due to consecutive optional
components not having distinct types. Without
the tags, the definition of airport would be
invalid in ASN.1.
23. Structured Types
Type SEQUENCE OF is similar to SEQUENCE,
except that all values in the ordered list must be
of the same type.
24. Structured Types
Type SET takes values that are unordered lists of
component types. The type and value notations for SET
are similar to SEQUENCE, except that the type of each
component must be distinct from all others and the
values can be in any order
{"Maggie", 4, TRUE} {TRUE, "Maggie", 4} {4,
TRUE,"Maggie"}
are three representations of the same instance of
Person ::= SET {
name IA5String,
age INTEGER,
female BOOLEAN }.
25. Structured Types
Type SET OF takes values that are unordered
lists of a single type.
26. Structured Types
Type CHOICE takes one value from a specified list of
distinct types.. The value notation is that for the
type chosen. For example, each of the three values,
(1) nothing TRUE, (2) car "Lincoln", (3) cash 25000
is a valid instance of
Prize ::= CHOICE {
car IA5String,
cash INTEGER,
nothing BOOLEAN }.
27. Structured Types
Type SELECTION enables the user to choose a
component type from a specified CHOICE type. The
less than symbol ``<" must precede the name of the
CHOICE type.
Winner ::= SEQUENCE {
lastName VisibleString,
ssn VisibleString,
cash < Prize }
with value notation
{ lastName `AUSTING', ssn `222334444', cash 5000 }
28. Structured Types
Type ANY, without further specification, is
incomplete. It must be supplemented by any
valid ASN.1 type . The value notation for the
type notation ANY is the specified type followed
by its value.
29. Structured Types
{ author "Shakespeare", reference IA5String
"ISBN0669123757" }
and
{ author "Shakespeare", reference INTEGER 1988
}
are two possible values of
TextBook ::= SEQUENCE {
author IA5String,
reference ANY }
30. Structured Types
Type TAGGED is used to enable the receiving
system to correctly decode values from several
datatypes that a protocol determines may be
transmitted at any given time. TAGGED has no
value notation of its own. Its type notation
consists of three elements: a user-defined tag,
possibly followed by IMPLICIT or EXPLICIT,
followed by the value notation of the type
being tagged.
31. Structured Types
• The user-defined tag consists of a class and
class number contained in braces.
• Class is UNIVERSAL, APPLICATION, PRIVATE,
or CONTEXT-SPECIFIC.
• The UNIVERSAL class is restricted to the ASN.1
built-in types. It defines an application-independent
data type that must be
distinguishable from all other data types. The
other three classes are user defined.
32. Structured Types
• The user-defined tag consists of a class and
class number contained in braces.
• Class is UNIVERSAL, APPLICATION, PRIVATE,
or CONTEXT-SPECIFIC.
• The UNIVERSAL class is restricted to the ASN.1
built-in types. It defines an application-independent
data type that must be
distinguishable from all other data types. The
other three classes are user defined.
33. Structured Types
The APPLICATION class distinguishes data types
that have a wide, scattered use within a
particular presentation context.
PRIVATE distinguishes data types within a
particular organization or country.
CONTEXT-SPECIFIC distinguishes members of a
sequence or set, the alternatives of a CHOICE, or
universally tagged set members. Only the class
number appears in braces for this data type; the
term COONTEXT-SPECIFIC does not appear.
34. Structured Types
a) seats SET { maximum INTEGER, occupied
INTEGER, vacant INTEGER }
b) b) seats SET { maximum [APPLICATION 0]
INTEGER, occupied [APPLICATION 1] INTEGER,
vacant [APPLICATION 2] INTEGER }
c) c) seats SET { maximum [APPLICATION 0]
IMPLICIT INTEGER, occupied [APPLICATION 1]
IMPLICIT INTEGER, vacant [APPLICATION 2]
IMPLICIT INTEGER }
d) d) seats SET { maximum [0] INTEGER, occupied
[1] INTEGER, vacant [2] INTEGER }
35. Additional Features
a) ASN.1 defines a subtype notation and value
sets, a method for handling recursion in data
types, and a macro facility.
37. Inner Type
• InnerType constrains the value ranges of
structured types.
• In particular, it can change an OPTIONAL
component of a structured type into one that
is always PRESENT or always ABSENT.
• The type notation requires the keywords
``WITH COMPONENTS'' followed by the
components of the structured type, each
component with or without a constraint.