Sei sulla pagina 1di 25

Abstract Syntax Notation one (ASN.

1)

Click to edit Master subtitle style

3/27/12

ASN.1

ASN.1 was developed jointly by ISO and ITU-T.

ASN.1 is a formal language to use with application layer for data transmission between systems that describes data structures for representing, encoding, transmitting, and decoding data.

It provides a set of formal rules for describing the structure of objects that are independent of machine-specific encoding techniques.
ASN.1 Rules

3/27/12

Abstract syntax Rules

Transfer syntax Rules

ASN.1

(cont.)

Abstract syntax rules are used to specify data types and structure for storage of information.

Transfer syntax rules are used for communicating information between systems.

Abstract syntax rules are applicable to information model and Transfer syntax rules are applicable to communication model.

The encoding rules are used to convert textual ASN.1 syntax to machine readable code (eg. BER, PER)

3/27/12

ASN.1

(cont.)

ASN.1 encoding rules:

Basic Encoding Rules (BER) Canonical Encoding Rules (CER) Distinguished Encoding Rules (DER) XML Encoding Rules (XER) Packed Encoding Rules (PER) Generic String Encoding Rules (GSER)

3/27/12

In conclusion ASN.1

ASN.1 together with specific ASN.1 encoding rules facilitates the exchange of structured data between application programs (manager and agent) over networks by describing data structures in a way that is independent of machine architecture and implementation language.

3/27/12

Module construction mechanism

Alternatives: List: Repetition:

CHOICE SET and SEQUENCE SET OF and SEQUENCE OF

(if, if-else, while) (structure in C) (for loop in C)

SEQUENCE transfers data in same order in which it is stored while SET transfers data in random order (unordered), same is applicable for SEQUENCE OF and SET OF for repetitive operation.

3/27/12

ASN.1 Symbols
Symbol ::= | -{} [] () .. Meaning Defined as or assignment Or, alternative Following symbols are comments Start and end of a list Start and end of a tag Start and end of a subtype Range (eg. 1..100)

3/27/12

Terminology, Symbols and Conventions

<Name> ::= <definition>

<Name> is defined as name of entity ::= is implies as defined as or assignment <definition> gives definition of entity

<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

| represents or

<operation> ::= + | - | | /
The definitions on the right side are called primitives (basic). Using these primitives 3/27/12 more entities can be constructed.

ASN module

A group of assignments makes up an ASN.1 module Example

SubjectName ::= { first Network middle Management last System }

A formal definition of a module

<Module Name> DEFINITIONS ::= BEGIN 3/27/12 <Name> ::= <definition>

ASN.1 Keywords
Keyword BEGIN END CHOICE DEFINITIONS EXPORTS IMPORTS IDENTIFIER INTEGER NULL OBJECT OCTET SEQUENCE SEQUENCE OF SET SET OF STRING Brief Description Start of an ASN.1 module End of an ASN.1 module List of alternative Definition of a data type or managed object Data type that can be exported to other modules Data type defined in other modules A sequence of non negative number Any negative or non-negative number A placeholder Used with IDENTIFIER to uniquely identify an object Unbounded 8-bit bytes (octets) of binary data (one octet = 8 bits) Ordered list maker Ordered array of repetitive data Unordered list maker Unordered list of repetitive data Used with OCTET for denoting string of octets

3/27/12

ASN.1 keyword (cont.)

Keywords are called primitives, they are built in expression that have special meaning.

ASN.1 definition allows both backward and forward references, as well as inline definition.

3/27/12

ASN.1 Data type conventions


Data Type Object name Application data type Module Macro, MIB module Keywords Convention Initial lowercase letter Initial uppercase letter Initial uppercase letter All uppercase letters All uppercase letters Example ethrStatsPkts Counter, IpAddress PersonalRecord RMON-MIB BEGIN, END, INTEGER

3/27/12

ASN.1 DATA Type Structure and Tag


Data Type

Structu
re

TAG

Simple

Structur e

Tagged

Other

Number Class

Univers al

Applicatio n

Context Specific

Private

3/27/12

Structure data type

Simple type : the values are specified directly


Marks ::= INTEGER

Eg. RollNo ::= INTEGER

Structure type : it contains different data types.

Eg. Inline, forward, backward & formal definition

Tagged type : is derived from another types that is given a new tag

Eg. Structure type which use unique tag to define a data type.

Other type : data type that is not predefined, it is chosen from CHOICE
and ANY types, which are contained in other type. 3/27/12

Value of class in Type


Class Universal Application Context-specific Private 8th bit (MSB) 0 0 1 1 7th bit 0 1 0 1

3/27/12

Universal Class Tag Assignment


Tag Universal 1 Universal 2 Universal 3 Universal 4 Universal 5 Universal 6 Universal . Universal . Universal 29 Reserved for future use Type Name BOOLEAN INTEGER BIT STRING OCTET STRING NULL OBJECT IDENTIFIER Set of Values TRUE or FALSE 0, positive and negative numbers A string of binary digits A string of octet Null, single value (place holder) Set of values associated with the object

3/27/12

Universal class

Data type in universal class are application independent. It is similar to global data type in C (Programming language) It does not need to be defined separately in the subroutines of the program.

Eg.
StudentInfo ::= SEQUENCE OF { Name ::= [UNIVERSAL 28] RollNo ::= [UNIVERSAL 2] }

3/27/12

Application Class

tags in application class are application specific. A universal class tag can be overridden with application tag.

BookInfo ::= SEQUENCE { [APPLICATION 1] Author Separator [APPLICATION 2] Title Separator [APPLICATION 3] Price } Author ::= [APPLICATION 1] IMPLICIT CharacterString 3/27/12

Context-Specific tag

Context specific type is a subset of an application type, is limited to that application.


[APPLICATION 1] Author, Separator [APPLICATION 2] TitleEdition, Separator [APPLICATION 3] Price }

BookInfo ::= SEQUENCE {

Auther ::= [APPLICATION 1] IMPLICIT CharacterString TitleEdition ::= [APPLICATION 2] SEQUENCE { [1] Title

3/27/12

[2] Edition

private class tag

The private type is used extensively by vendor of network products .


ErrorStatus ::= ENUMRATED { noError (0) genError (1) tooBigError (2) }

3/27/12

Encoding Structure in BER

TLV format of message in BER (Basic Encoding Rule)

Type

Length

Value

Class (7th -8th bits)

P/C (6th bit)

Tag Number (1st -5th bits)

3/27/12

BER Encoded Fields (Construct Data Type)

Using SEQUENCE & SET

Type

Length

Type

Length

Value

Type

length

Value

Example:- SwitchInfo ::= SEQUENCE { ObjectId ::= OBJECT IDENTIFIER MacAdd ::= OCTET STRING
SEQUENCE - [Universal 16] ; OBJECT IDENTIFIER- [Universal 6]; OCTET STRING [Universal 4]

3/27/12

BER encoding examples

INTEGER 1 INTEGER 256 MacAddress ::= OCTET STRING 4AFF3300FF11 H HostNumber ::= [UNIVERSAL 2] 5

3/27/12

Macros

ASN.1 language permits to define new data types and values by defining ASN.1 macros. Structure of an ASN.1 Macro

<macroname> MACRO ::= BEGIN TYPE NOTATION ::= <syntaxOfNewType> VALUE NOTATION ::= <syntaxOfNewValue> <auxiliary Assignments> END
3/27/12

Example of MACRO
NODE-INFO MACRO ::= BEGIN TYPE NOTATION ::= STATUS Status DETAILS Details VALUE NOTATION ::= Status ::= normal | under congestion| under fault Details ::= name-contactNo END
3/27/12

Potrebbero piacerti anche