Asn 1
Asn 1
Asn 1
1)
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
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)
ASN.1
ASN.1 encoding rules:
(cont.)
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)
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.
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.
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)
<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 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 }
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
TAG
Structure
Number Class Simple Structure Tagged Other
Universal
Application
ContextSpecific
Private
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.
Universal 29
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] }
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 Title ::= [APPLICATION 2] IMPLICIT CharacterString Price ::= [APPLICATION 3] IMPLICIT REAL
Context-Specific tag
Context specific type is a subset of an application type, is limited to that application.
BookInfo ::= SEQUENCE { [APPLICATION 1] Author, Separator [APPLICATION 2] TitleEdition, Separator [APPLICATION 3] Price } Auther ::= [APPLICATION 1] IMPLICIT CharacterString TitleEdition ::= [APPLICATION 2] SEQUENCE { [1] Title [2] Edition } Title ::= CharacterString Edition ::= INTEGER Price ::= [APPLICATION 3] IMPLICIT REAL
Type
Length
Value
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]
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
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