Abstract Syntax Notation One ASN 1 These slides

Abstract Syntax Notation One ASN. 1 These slides are based in parts upon slides of Prof. Dssouli (Concordia university)

Abstract Syntax Notation One q q q Both the information and communications models need to be specified syntactically and semantically. This requires a language that specifies the management protocol in the application layer. This is where Abstract Syntax Notation One (ASN. 1) plays a role. ASN. 1 is actually more than a syntax; it’s a language that addresses both syntax and semantics Two type of syntax n n q q Abstract syntax: set of rules that specify data type and structure for information storage Transfer syntax: set of rules for communicating information between systems Can generate machine-readable code: Basic Encoding Rules (BER) ASN. 1 is based on the Backus system and uses the formal syntax and grammar of the Backus-Nauer Form (BNF)

Backus-Nauer Form (BNF) q Definition: <name> : : = <definition> where <name> denotes “entity” and the symbol “: : =“ represents “defined as” q primitive definitions: q q q <digit> : : = 0|1|2|3|4|5|6|7|8|9 <op> : : = +|-|x|/ similarly, an entity number can be constructed from primitives: q <number> : : = <digit> | <digit> <number> q Example: q 9 is primitive 9 q 19 is construct of 1 and 9 q 619 is construct of 6 and 19

ASN. 1 Assignments q Assignments <Boolean. Type> : : = BOOLEAN data type assignment (or name of the entity) <Boolean. Value> : : = TRUE | FALSE value assignment (assigned value to the data type) q Group of assignments: Modules q q q Start with capital letters Usually modules are built from primitive (atomic) data types (e. g. , INTEGER, REAL, etc. . ) May use ASN. 1 constructs (e. g. , SET, SEQUENCE, etc. ) Constructors are used to build structured data types Backward and forward references, and inline definition

ASN. 1 Modules Constructs: “list makers” A module Personnel. Record (a set of data types) Primitives data types Construct: alternatives Three construction mechanisms (develop structured data types): Alternatives: CHOICE List: SET and SEQUENCE Repetition: SET OF and SEQUENCE OF

ASN. 1 Modules Lists built with “SEQUENCE” maintains the correct order Personnel. Record is a set of different data types, each uniquely associated with a name and can be encoded and transmitted in any order. Example: “Smith”, “Manager”, {“North”, “Chile”} “Manager”, “Smith”, {“North”, “Chile”}, “Smith”, “Manager”
![ASN. 1 Symbols Symbol : : = | -{} [] (). . Meaning Defined ASN. 1 Symbols Symbol : : = | -{} [] (). . Meaning Defined](http://slidetodoc.com/presentation_image_h2/e67732aa882d83aa0575bbd180ae806e/image-7.jpg)
ASN. 1 Symbols Symbol : : = | -{} [] (). . Meaning Defined as or, alternative, options of a list Signed number Following the symbol are comments Start and end of a list Start and end of a tag Start and end of subtype Range

Data Types Data types are generally defined based on a structure and a tag: q q Structure: simple (or atomic), structured, etc. . Tag: class and a tag

Data Type: Structure & Tag • Structure defines how data type is built • Tag uniquely identifies the data type

ASN. 1 simple types q Basic Types o o o q BOOLEAN INTEGER ENUMERATED REAL BIT STRING OCTET STRING Character String Types (various subsets of ISO 10646 -1) o o o o Numeric. String (0 -9, <space>) Printable. String (0 -9, A-Z, a z, <space>, <special>) Visible. String Graphic. String Teletex. String UTF 8 String IA 5 String

ASN. 1 simple types q q Syntax : <type name> : : = type Example: counter : : = INTEGER Ip. Address : : = OCTET STRING Page. Number : : = INTEGER Chapter. Number: : = INTEGER Months : : = ENUMERATED {january (1), february (2), march (3), april (4), may (5), june (6), july (7 august (8), september (9), october (10), november (11), december (12)}

ASN. 1 simple types q A subtype is derived from a parent type q Syntax: <subtype name> : : = <type> ( <constraint> ) Examples: Counter : : = INTEGER ( 0. . 4294967295 ) Ip. Address : : = OCTET STRING ( SIZE(4) ) Spring : : = Months ( march | april | may ) Summer : : = Months ( june | july | august ) Small. Prime : : = INTEGER ( 2 | 3 | 5 | 7 | 11 )

Structure • • Simple Page. Number : : = INTEGER Chapter. Number : : = INTEGER Structured / Construct Book. Page. Number : : = SEQUENCE {Chapter. Number, Separator, Page. Number} Tagged • Derived from another type; given a new ID • In Fig. 3 -14, INTEGER is either universal or application specific Other • CHOICE, ANY

Structured Type n SEQUENCE q n SEQUENCE OF q n Ordered array of repetitive data SET q n Ordered list maker Unordered list maker SET OF q Unordered list of repetitive data

ASN. 1 structured types q A data type is structured type when it contains other types (i. e. , have components) Book. Page. Number : : = SEQUENCE {Chapter. Number, Separator, Page. Number} separator is a Visible. String data type with value “-” Example: {1 -1, 2 -3, 3 -39} Book. Pages : : = SEQUENCE OF { Book. Page. Number } Book. Pages : : = SEQUENCE OF { SEQUENCE {Chapter. Number, Separator, Page. Number}} Example: {1 -1, 1 -2, . . , 2 -1, 2 -2, …. . }

ASN. 1 structured types q The pages of a book could also be specified as a collection of individual pages in random order Book. Pages : : = SET OF { SEQUENCE {Chapter. Number, Separator, Page. Number} }

ASN. 1 Tagged Types q q q Tag uniquely identifies a data type and is required for encoding the data types for communication Comprises class and tag number Class: o o Universal - similar to global variables Application - only in the application used Context-specific - specific context in application Private - used extensively by commercial vendors Example: BOOLEAN INTEGER research product-based Universal 1 Universal 2 Application [1] Context-specific under research [0]

ASN. 1 Tagged Types UNIVERSAL 1 BOOLEAN UNIVERSAL 2 INTEGER UNIVERSAL - basic types 3 BIT STRING UNIVERSAL 4 OCTET STRING UNIVERSAL 9 REAL UNIVERSAL 10 ENUMERATED UNIVERSAL 6 - object types UNIVERSAL 7 OBJECT IDENTIFIER Object. Descriptor UNIVERSAL 26 types Visible. String - character string UNIVERSAL 5 . . . NULL UNIVERSAL 23 types UTCTime - miscellaneous UNIVERSAL 24 Generalized. Time UNIVERSAL 16 SEQUENCE [OF] - structured types UNIVERSAL 17 SET [OF]

ASN. 1 Tagged Types Tag nb is 1 (overrides that of BOOLEAN) Application specific Context specific (subset of an application, and limited to the application)

ASN. 1 Object Types q Used to name and describe information objects q q Such as standard documents, data structures, managed objects In general, an information object is a class of information, e. g. , file format, rather than an instance of such a class (i. e. , individual file) Object identifier is a unique identifier for a particular object and its value consist of a set of integers Object descriptor is a human readable description of an information object

ASN. 1 Object Types root ccitt(0) iso(1) joint-iso-ccitt(2) org(3) internet(1) mgmt(2) mib-2(1) dod(6) private(4) experimental(3) enterprise(1) internet OBJECT IDENTIFIER : : = {iso(1) org(3) dod(6) 1 } private OBJECT IDENTIFIER : : = {internet 4 }

ASN. 1 Object Types n n Private type is used extensively by vendors of network products A vendor is assigned a node on the MIT, all branches and leaves under that node will be assigned private data types by the vendor ibm OBJECT IDENTIFIER : : = {iso(1) org(3) dod(6) internet(1) private(4) enterprize(1) 2}

Encoding Structure q ASN. 1 syntax containing management information is encoded using the Basic Encoding Rules (BER) that is defined for the transfer syntax q BER is a specification developed and standardized by CCITT and OSI q ASCII data is converted to bit-oriented data q TLV, Type-Length-Value: is a specific encoding structure q q q Type: indicates the ASN. 1 type, class of the type Length: length of the actual value representation Value: the value of the ASN. 1 type as a string of octets

Encoding Structure 1 byte q P/C (1 -bit) specifies whether the structure is simple or a construct q q 0 for simple 1 for construct

Encoding Structure 1 byte q Class (2 bits): specifies the class being used

Encoding Structure 1 byte q Tag Number: designates the tag value in binary q Example: 00 0 00010 for encoding INTEGER Universal class Primitive Tag value = 2

Tag number < 31 Identifier Octet Bits 8 7 Class 6 5 4 P/C 3 2 Tag number 0 = Primitive 1 = Constructed 0 0 = Universal 0 1 = Application 1 0 = Context-specific 1 1 = Private 1

Tag number >= 31 Leading octet Class P/C 1 1 1 2 nd octet 1 Last octet. . . 1 +. . . + = Tag number 0 +

Encoding of Length Field q Short form ( L < 128 octets) one octet 0 Length L L octets Contents (or Value) field q Long form ( 128 L < 21008 octets) first octet 1 K K octets Length L Contents field Example, L = 128: 10000001 10000000 Binary equivalent of 128

BER, Examples Type Length Value distance INTEGER : : = 27 02 01 1 B 00 0 00010 UNIVERSAL P today INTEGER : : = 129 02 02 2 00 81 Length is 2 to indicate 2 octets for Value Day. Of. Year : : = [APPLICATION 17] IMPLICIT INTEGER today Day. Of. Year : : = 129 51 02 01 0 10001 APPLICATION P 17 00 81

BER, Examples Birthday name day } : : = SEQUENCE { Visible. String, Day. Of. Year Type Definition UNIVERSAL 16 00 1 10000 Value Assignment my. Birthday : : = { name "Jane", day 129 } Birthday Length Contents 30 ? ? 0 A Visible. String 1 A Day. Of. Year 51 BER Encoding Length 04 Length 02 Contents "Jane" Contents 00 81

Example: SNMP Message Tag Message : : = SEQUENCE { version INTEGER { version-1(0) }, community OCTET STRING, data ANY } 30 02 04

Example: SNMP Message Type 30: SEQUENCE Length 82 01 c 0: 448 octets 82: 10000010

Type 30: SEQUENCE Length 32: 50 octets

Macros <macroname> MACRO : : = BEGIN TYPE NOTATION : : = <syntax. Of. New. Type> VALUE NOTATION : : = <syntax. Of. New. Value> <auxiliary. Assignments> END

Macro Example OBJECT-TYPE MACRO : : = BEGIN TYPE NOTATION : : = "SYNTAX" type (TYPE Object. Syntax) “ACCESS" Access "STATUS" Status VALUE NOTATION : : = value (VALUE Object. Name) Access : : = "read-only" | "read-write“ | "write-only | "not-accessible" Status : : = "mandatory” | "optional“ END | "obsolete"

Object-Type Example sys. Name OBJECT-TYPE SYNTAX Display. String (SIZE (0. . 255)) ACCESS read-write STATUS mandatory : : = { system 5 }

Marco Example 2 CAR MACRO: : = BEGIN TYPE NOTATION : : = Brand Engine Car. Type Year VALUE NOTATION : : = value (VALUE OBJECT IDENTIFIER) Brand : : = “BRAND” value (Printable. String) Engine : : = “CC” Ccs : : = Cc | Ccs”, ” Cc Cc : : = value (INTEGER (600. . 5000)) Car. Type : : = “STYLE” CType : : = “Sedan” | “Liftback” | “SUV” | “Other” Year : : = “YEAR” value (INTEGER) END

Camry CAR BRAND Toyota CC 2000, 2400, 3000 STYLE Sedan YEAR 2006 : : = {toyota 3}
- Slides: 39