Abstract Syntax Notation One
Encyclopedia
Data generated at various sources of observation need to be transmitted to one or more locations that process it to generate useful results. For example, voluminous signal data collected by a radio telescope from outer space. The system recording the data and the system processing it later may be diverse in nature and may also be from different vendors. As such, a consistent mechanism is needed to record, transmit and be able to read data across such diverse systems. In telecommunication
s and computer networking, Abstract Syntax Notation One (ASN.1) is a standard
and flexible notation that describes rules and structures for representing, encoding, transmitting, and decoding
data
. The formal rules enable representation of objects that are independent of machine-specific encoding techniques. Formal notation makes it possible to automate the task of validating whether a specific instance of data representation abides to the specifications. In other words, software tools can be used for the validation.
ASN.1 is a joint ISO
/IEC and ITU-T
standard, originally defined in 1984 as part of CCITT X.409:1984. ASN.1 moved to its own standard, X.208, in 1988 due to wide applicability. The substantially revised 1995 version is covered by the X.680 series. The latest available version is dated 2002, and is backward compatible with the 1995 version.
of information but does not restrict the way the information is encoded. Various ASN.1 encoding rules provide the transfer syntax (a concrete representation) of the data values whose abstract syntax is described in ASN.1.
The standard ASN.1 encoding rules include:
ASN.1 together with specific ASN.1 encoding rules facilitates the exchange of structured data especially between application programs over networks by describing data structures in a way that is independent of machine architecture and implementation language.
Application layer
protocols such as X.400
electronic mail, X.500
and LDAP
directory service
s, H.323
(VoIP), Kerberos, BACnet
and SNMP
use ASN.1 to describe the protocol data units (PDUs)
they exchange. It is also extensively used in the Access and Non-Access Strata of UMTS. There are many other application domains of ASN.1.
A particularly useful new application of ASN.1 is Fast Infoset
. Fast Infoset
is an international standard that specifies a binary encoding
format for the XML Information Set
(XML Infoset) as an alternative to the XML
document format. It aims to provide more efficient serialization than the text-based XML format.
This could be a specification published by creators of Foo protocol. ASN.1 does not define conversation flows. This is up to the textual description of the protocol.
Assuming a message, which complies with Foo protocol and which will be sent to the receiving party. This particular message (PDU
) is:
To send the above message through the network one needs to encode it to a string of bit
s. ASN.1 defines various algorithms to accomplish that task, called Encoding rules. There are plenty of them; one of the simplest is Distinguished Encoding Rules (DER)
.
The Foo protocol specification should explicitly name one set of encoding rules to use, so that users of the Foo protocol know which one they should use.
format (all numbers are in hexadecimal):
(Note: DER uses a pattern of tag-length-value
triplets)
So what one actually gets is the string of 21 octets:
The scope of ASN.1 and DER ends here. It is possible to transmit the encoded message to the party by any means (utilizing TCP
or any other protocol). The party should be able to decode the octets back using DER.
) to achieve greater human readability "over the wire". It would then appear like the following 108 octets:
are employed, the following 122 bits (less than 16 octets) will be produced:
Other communication protocols, such as Internet protocols HTTP and SMTP, define messages using text tags and values, sometimes based on the Augmented Backus-Naur form (ABNF) notation. The definition also defines the encoding, which is in text.
There has been much debate over the two approaches, and both have their merits; the ASN.1 approach is believed to be more efficient, and with Packed Encoding Rules
, certainly provides a more compact encoding. The textual approach is claimed to be easier to implement (through creation and parsing of text strings) and easier to debug, as one can simply read an encoded message. In the case of the Megaco
protocol, consensus between the two points of view was not reached and so two encodings, one based on ASN.1 and one on ABNF, were defined.
The ASN.1 XML Encoding Rules
(XER) attempts to bridge the gap by providing a textual encoding of data structures defined using ASN.1 notation. Generic String Encoding Rules
were also defined for the sole purpose of presenting and inputting data to/from a user.
(ECN) is a notation to specify specific encodings of ASN.1 types. ECN is useful to describe legacy protocols in ASN.1. It is possible to specify only the encoding of some types and then complete with a standard encoding rules (usually unaligned PER).
Standards describing the ASN.1 encoding rules:
Telecommunication
Telecommunication is the transmission of information over significant distances to communicate. In earlier times, telecommunications involved the use of visual signals, such as beacons, smoke signals, semaphore telegraphs, signal flags, and optical heliographs, or audio messages via coded...
s and computer networking, Abstract Syntax Notation One (ASN.1) is a standard
Standardization
Standardization is the process of developing and implementing technical standards.The goals of standardization can be to help with independence of single suppliers , compatibility, interoperability, safety, repeatability, or quality....
and flexible notation that describes rules and structures for representing, encoding, transmitting, and decoding
Decoding
Decoding is the reverse of encoding, which is the process of transforming information from one format into another. Information about decoding can be found in the following:* Digital-to-analog converter, the use of analog circuit for decoding operations...
data
Data
The term data refers to qualitative or quantitative attributes of a variable or set of variables. Data are typically the results of measurements and can be the basis of graphs, images, or observations of a set of variables. Data are often viewed as the lowest level of abstraction from which...
. The formal rules enable representation of objects that are independent of machine-specific encoding techniques. Formal notation makes it possible to automate the task of validating whether a specific instance of data representation abides to the specifications. In other words, software tools can be used for the validation.
ASN.1 is a joint ISO
International Organization for Standardization
The International Organization for Standardization , widely known as ISO, is an international standard-setting body composed of representatives from various national standards organizations. Founded on February 23, 1947, the organization promulgates worldwide proprietary, industrial and commercial...
/IEC and ITU-T
ITU-T
The ITU Telecommunication Standardization Sector is one of the three sectors of the International Telecommunication Union ; it coordinates standards for telecommunications....
standard, originally defined in 1984 as part of CCITT X.409:1984. ASN.1 moved to its own standard, X.208, in 1988 due to wide applicability. The substantially revised 1995 version is covered by the X.680 series. The latest available version is dated 2002, and is backward compatible with the 1995 version.
ASN.1 in transfer
ASN.1 defines the abstract syntaxAbstract syntax
The abstract syntax of data is its structure described as a data type , independent of any particular representation or encoding....
of information but does not restrict the way the information is encoded. Various ASN.1 encoding rules provide the transfer syntax (a concrete representation) of the data values whose abstract syntax is described in ASN.1.
The standard ASN.1 encoding rules include:
- Basic Encoding RulesBasic Encoding RulesThe Basic Encoding Rules is one of the encoding formats defined as part of the ASN.1 standard specified by the ITU in X.690.-Description:...
(BER) - Canonical Encoding RulesCanonical Encoding RulesCanonical Encoding Rules is a message transfer syntax specified by the ITU in X.690. It is a restricted variant of Basic Encoding Rules for producing unequivocal transfer syntax for data structures described by ASN.1....
(CER) - Distinguished Encoding RulesDistinguished Encoding RulesDistinguished Encoding Rules , is a message transfer syntax specified by the ITU in X.690. The Distinguished Encoding Rules of ASN.1 is an International Standard drawn from the constraints placed on basic encoding rules encodings by X.509. DER encodings are valid BER encodings...
(DER) - XML Encoding RulesXML Encoding RulesXML Encoding Rules , defined in ITU-T standard X.693, are a set of ASN.1 encoding rules for producing an XML-based verbose textual transfer syntax for data structures described in ASN.1....
(XER) - Packed Encoding RulesPacked Encoding RulesPacked encoding rules are ASN.1 encoding rules for producing a compact transfer syntax for data structures described in ASN.1, defined in 1994....
(PER) - Generic String Encoding RulesGeneric String Encoding RulesGeneric String Encoding Rules are a set of ASN.1 encoding rules for producing a verbose, human-readable textual transfer syntax for data structures described in ASN.1....
(GSER)
ASN.1 together with specific ASN.1 encoding rules facilitates the exchange of structured data especially between application programs over networks by describing data structures in a way that is independent of machine architecture and implementation language.
Application layer
Application layer
The Internet protocol suite and the Open Systems Interconnection model of computer networking each specify a group of protocols and methods identified by the name application layer....
protocols such as X.400
X.400
X.400 is a suite of ITU-T Recommendations that define standards for Data Communication Networks for Message Handling Systems — more commonly known as "email"....
electronic mail, X.500
X.500
X.500 is a series of computer networking standards covering electronic directory services. The X.500 series was developed by ITU-T, formerly known as CCITT, and first approved in 1988. The directory services were developed in order to support the requirements of X.400 electronic mail exchange and...
and LDAP
Lightweight Directory Access Protocol
The Lightweight Directory Access Protocol is an application protocol for accessing and maintaining distributed directory information services over an Internet Protocol network...
directory service
Directory service
A directory service is the software system that stores, organizes and provides access to information in a directory. In software engineering, a directory is a map between names and values. It allows the lookup of values given a name, similar to a dictionary...
s, H.323
H.323
H.323 is a recommendation from the ITU Telecommunication Standardization Sector that defines the protocols to provide audio-visual communication sessions on any packet network...
(VoIP), Kerberos, BACnet
BACnet
BACnet is a communications protocol for building automation and control networks. It is an ASHRAE, ANSI, and ISO standard protocol....
and SNMP
Simple Network Management Protocol
Simple Network Management Protocol is an "Internet-standard protocol for managing devices on IP networks. Devices that typically support SNMP include routers, switches, servers, workstations, printers, modem racks, and more." It is used mostly in network management systems to monitor...
use ASN.1 to describe the protocol data units (PDUs)
Protocol data unit
In telecommunications, the term protocol data unit has the following meanings:#Information that is delivered as a unit among peer entities of a network and that may contain control information, address information, or data....
they exchange. It is also extensively used in the Access and Non-Access Strata of UMTS. There are many other application domains of ASN.1.
A particularly useful new application of ASN.1 is Fast Infoset
Fast Infoset
Fast Infoset is an international standard that specifies a binary encoding format for the XML Information Set as an alternative to the XML document format...
. Fast Infoset
Fast Infoset
Fast Infoset is an international standard that specifies a binary encoding format for the XML Information Set as an alternative to the XML document format...
is an international standard that specifies a binary encoding
Binary XML
Binary XML refers to any specification which defines the compact representation of XML in a binary format. While there are several competing formats, none has been widely adopted by a standards organization or accepted as a de facto standard...
format for the XML Information Set
XML Information Set
XML Information Set is a W3C specification describing an abstract data model of an XML document in terms of a set of information items...
(XML Infoset) as an alternative to the XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....
document format. It aims to provide more efficient serialization than the text-based XML format.
Example
Data structures of FooProtocol defined using the ASN.1 notation:FooProtocol DEFINITIONS ::= BEGIN
FooQuestion ::= SEQUENCE {
trackingNumber INTEGER,
question IA5String
}
FooAnswer ::= SEQUENCE {
questionNumber INTEGER,
answer BOOLEAN
}
END
This could be a specification published by creators of Foo protocol. ASN.1 does not define conversation flows. This is up to the textual description of the protocol.
Assuming a message, which complies with Foo protocol and which will be sent to the receiving party. This particular message (PDU
Protocol data unit
In telecommunications, the term protocol data unit has the following meanings:#Information that is delivered as a unit among peer entities of a network and that may contain control information, address information, or data....
) is:
myQuestion FooQuestion ::= {
trackingNumber 5,
question "Anybody there?"
}
To send the above message through the network one needs to encode it to a string of bit
Bit
A bit is the basic unit of information in computing and telecommunications; it is the amount of information stored by a digital device or other physical system that exists in one of two possible distinct states...
s. ASN.1 defines various algorithms to accomplish that task, called Encoding rules. There are plenty of them; one of the simplest is Distinguished Encoding Rules (DER)
Distinguished Encoding Rules
Distinguished Encoding Rules , is a message transfer syntax specified by the ITU in X.690. The Distinguished Encoding Rules of ASN.1 is an International Standard drawn from the constraints placed on basic encoding rules encodings by X.509. DER encodings are valid BER encodings...
.
The Foo protocol specification should explicitly name one set of encoding rules to use, so that users of the Foo protocol know which one they should use.
Example encoded in DER
Below is the data structure shown above encoded in the DERDistinguished Encoding Rules
Distinguished Encoding Rules , is a message transfer syntax specified by the ITU in X.690. The Distinguished Encoding Rules of ASN.1 is an International Standard drawn from the constraints placed on basic encoding rules encodings by X.509. DER encodings are valid BER encodings...
format (all numbers are in hexadecimal):
30 -- tag indicating SEQUENCE
13 -- length in octets
02 -- tag indicating INTEGER
01 -- length in octets
05 -- value
16 -- tag indicating IA5String
0e -- length in octets
41 6e 79 62 6f 64 79 20 74 68 65 72 65 3f -- value
("Anybody there?" in ASCII)
(Note: DER uses a pattern of tag-length-value
Type-length-value
Within data communication protocols, optional information may be encoded as a type-length-value or TLV element inside of the protocol. TLV is also known as tag-length value....
triplets)
So what one actually gets is the string of 21 octets:
30 13 02 01 05 16 0e 41 6e 79 62 6f 64 79 20 74 68 65 72 65 3f
The scope of ASN.1 and DER ends here. It is possible to transmit the encoded message to the party by any means (utilizing TCP
Transmission Control Protocol
The Transmission Control Protocol is one of the core protocols of the Internet Protocol Suite. TCP is one of the two original components of the suite, complementing the Internet Protocol , and therefore the entire suite is commonly referred to as TCP/IP...
or any other protocol). The party should be able to decode the octets back using DER.
Example encoded in XER
Alternatively, it is possible to encode the same ASN.1 data structure with XER (XML Encoding RulesXML Encoding Rules
XML Encoding Rules , defined in ITU-T standard X.693, are a set of ASN.1 encoding rules for producing an XML-based verbose textual transfer syntax for data structures described in ASN.1....
) to achieve greater human readability "over the wire". It would then appear like the following 108 octets:
5
Anybody there?
Example encoded in PER (unaligned)
Alternatively, if Packed Encoding RulesPacked Encoding Rules
Packed encoding rules are ASN.1 encoding rules for producing a compact transfer syntax for data structures described in ASN.1, defined in 1994....
are employed, the following 122 bits (less than 16 octets) will be produced:
01 05 0e 83 bb ce 2d f9 3c a0 e9 a3 2f 2c af c0
ASN.1 versus other data structure definition schemes
As commonly used for defining messages for communication protocols, ASN.1, with its associated encoding rules, results in a binary encoding.Other communication protocols, such as Internet protocols HTTP and SMTP, define messages using text tags and values, sometimes based on the Augmented Backus-Naur form (ABNF) notation. The definition also defines the encoding, which is in text.
There has been much debate over the two approaches, and both have their merits; the ASN.1 approach is believed to be more efficient, and with Packed Encoding Rules
Packed Encoding Rules
Packed encoding rules are ASN.1 encoding rules for producing a compact transfer syntax for data structures described in ASN.1, defined in 1994....
, certainly provides a more compact encoding. The textual approach is claimed to be easier to implement (through creation and parsing of text strings) and easier to debug, as one can simply read an encoded message. In the case of the Megaco
Megaco
Megaco is a gateway control protocol. and an implementation of the Media Gateway Control Protocol architecture for controlling media gateways in Internet Protocol networks and the public switched telephone network...
protocol, consensus between the two points of view was not reached and so two encodings, one based on ASN.1 and one on ABNF, were defined.
The ASN.1 XML Encoding Rules
XML Encoding Rules
XML Encoding Rules , defined in ITU-T standard X.693, are a set of ASN.1 encoding rules for producing an XML-based verbose textual transfer syntax for data structures described in ASN.1....
(XER) attempts to bridge the gap by providing a textual encoding of data structures defined using ASN.1 notation. Generic String Encoding Rules
Generic String Encoding Rules
Generic String Encoding Rules are a set of ASN.1 encoding rules for producing a verbose, human-readable textual transfer syntax for data structures described in ASN.1....
were also defined for the sole purpose of presenting and inputting data to/from a user.
Encoding Control Notation (ECN)
The Encoding Control NotationEncoding Control Notation
The Encoding Control Notation is a standardized formal language that is part of the Abstract Syntax Notation One family of international standards...
(ECN) is a notation to specify specific encodings of ASN.1 types. ECN is useful to describe legacy protocols in ASN.1. It is possible to specify only the encoding of some types and then complete with a standard encoding rules (usually unaligned PER).
ASN.1 Information Object Class
Information Object Classes is a concept used in ASN.1 to address specification needs similar to the ones addressed by CORBA/IDL specifications.Using ASN.1 in practice
One may use an ASN compiler which takes as input an ASN.1 specification and generates computer code (for example in the C programming language) for an equivalent representation of the data structures. This computer code, together with supplied run-time libraries, can then convert encoded data structures to and from the computer language representation. Alternatively, one can manually write encoding and decoding routines.Standards
Standards describing the ASN.1 notation:- ITU-T Rec. X.680 | ISO/IEC 8824-1 (Specification of basic notation)
- ITU-T Rec. X.681 | ISO/IEC 8824-2 (Information object specification)
- ITU-T Rec. X.682 | ISO/IEC 8824-3 (Constraint specification)
- ITU-T Rec. X.683 | ISO/IEC 8824-4 (Parameterization of ASN.1 specifications)
Standards describing the ASN.1 encoding rules:
- ITU-T Rec. X.690 | ISO/IEC 8825-1 (BER, CER and DER)
- ITU-T Rec. X.691 | ISO/IEC 8825-2 (PER)
- ITU-T Rec. X.692 | ISO/IEC 8825-3 (ECN)
- ITU-T Rec. X.693 | ISO/IEC 8825-4 (XER)
- ITU-T Rec. X.694 | ISO/IEC 8825-5 (XSD mapping)
- ITU-T Rec. X.695 | ISO/IEC 8825-6 (PER registration and application)
- RFC 3641 (GSER)
See also
- Comparison of data serialization formatsComparison of data serialization formatsThis is a comparison of data serialization formats, different ways to convert complex objects to sequences of bits. It does not include markup languages used exclusively as document file formats.-Overview:*a. The current default format is binary....
- TTCNTTCNTTCN is a programming language used for testing of communication protocols and web services. A TTCN test suite consists of many test cases written in the TTCN programming language....
- TTCN-3TTCN-3TTCN-3 is a strongly typed test scripting language used in conformance testing of communicating systems and a specification of test infrastructure interfaces that glue abstract test scripts with concrete communication environments. TTCN-3 has been developed by ETSI and its predecessor is TTCN-2...
- EBMLExtensible Binary Meta LanguageExtensible Binary Meta Language is a generalized file format for any kind of data, aiming to be a binary equivalent to XML. It provides a basic framework for storing data in XML-like tags...
External links
- ITU-T website - Introduction to ASN.1
- Standards describing the ASN.1 notation
- The ASN.1 Consortium
- ASN.1 Tutorial Tutorial on basic ASN.1 concepts
- A Layman's Guide to a Subset of ASN.1, BER, and DER A very good introduction for beginners
- Erlang Asn1 application Erlang compile-time and run-time support for ASN.1 (part of Erlang/OTP distribution)
- tlve, A common tlv parser. Tlve can parse ASN.1 BER encoded data
- IvmaiAsn ASN1/ECN/XDR Tools (a collection of the ASN.1/ECN parser, XDR-to-ASN.1 converter and pretty-printer scripts for ASN.1/ECN specifications)
- pyasn1 ASN1 types and codecs for PythonPython (programming language)Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
- BinaryNotes Open Source ASN.1 Framework for JavaJava (programming language)Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
and Microsoft .NET.NET FrameworkThe .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability... - jASN1 Java ASN.1 BER encoding/decoding library at openmuc.org, LGPL-licensed
- ASN1SCC An open source, dual-license ASN.1 compiler for CC (programming language)C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
, C++ and AdaAda (programming language)Ada is a structured, statically typed, imperative, wide-spectrum, and object-oriented high-level computer programming language, extended from Pascal and other languages...
. - A free online tool that allows decoding ASN.1 encoded messages into XML output.