280 likes | 296 Views
Learn about ASN.1, a formal language by CCITT and ISO/IEC for data transfer, with examples and syntax explanations.
E N D
CITA 440 Week 3 ASN.1
ASN.1 • A formal language developed jointly by CCITT (ITU-T) and ISO/IEC for use with application layers for data transfer between systems • Can generate machine-readable code: BasicEncoding Rules (BER) can be used
Application fields of ASN.1 • http://www.itu.int/en/ITU-T/asn1/Pages/Application-fields-of-ASN-1.aspx
ASN.1 Example -- type definition of Person-Name type: Person-Name ::= SEQUENCE { first VisibleString, middle VisibleString, last VisibleString } -- value assignment of an actual person name: person-name Person-Name ::= { first "John", middle "I", last "Smith" }
ASN.1 • Layout is not significant; multiple spaces and line breaks can be considered as a single space. • Comments are delimited by a pair of hyphens (--) and a line break. • Type references (names of types) and identifiers (names of objects) and consist of upper- and lower-case letters, digits, hyphens, and spaces; identifiers begin with lower-case letters; type references begin with upper-case letters.
ASN.1 Symbols SymbolMeaning ::= 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
ASN.1 Data Types • Simple types: • PageNumber ::= INTEGER • ChapterNumber ::= INTEGER • Structured types: • BookPageNumber ::= SEQUENCE {ChapterNumber, Separator, PageNumber} • Example: 1-1, 2-3, 3-39 • Tagged types: • Derived from another type; given a new tag ID • Other types: • CHOICE, ANY
ASN.1 Module Definitions <module name> DEFINITIONS ::= BEGIN <name> ::= <definition> … <name> ::= <definition> END
Tag • Tag uniquely identifies a data type • Comprises class and tag number • Class: • Universal • Application • Context-specific • Private (used extensively by commercial vendors)
ASN.1 Example A keyboard has 44 keys in 4 rows of 11 keys per row. Each of the keys can be pressed or not pressed. It is permitted to press multiple keys at the same time. Specify an ASN.1 declaration for transferring information about which of the keys are pressed.
Solutions • Solution 1: KeyPosition ::= SEQUENCE {row INTEGER(1..4), column INTEGER(1..11)} PressedKeys ::= SET OF KeyPosition • Solution 2: Keyboard ::= SET OF SEQUENCE {row INTEGER(1..4), column INTEGER(1..11), pressed BOOLEAN}