ASN.1 (Abstract Syntax Notation One)
ASN.1 (Abstract Syntax Notation One) is a standard way to describe a message (a unit of application data) that can be sent or received in a network. ASN.1 is divided into two parts: (1) the rules of syntax for describing the contents of a message in terms of data type and content sequence or structure and (2) how you actually encode each data item in a message. ASN.1 is defined in two ISO standards for applications intended for the Open Systems Interconnection (OSI) framework:
- ISO 8824/ITU X.208 specifies the syntax (for example, which data item comes first in the message and what its data type is)
- ISO 8825/ITU X.209 specifies the basic encoding rules for ASN.1 (for example, how to state how long a data item is)
Here's an example of a message definition specified with ASN.1 notation:
Report ::= SEQUENCE { author OCTET STRING, title OCTET STRING, body OCTET STRING, biblio Bibliography }
In this very simple example, "Report" is the name of this type of message. SEQUENCE indicates that the message is a sequence of data items. The first four data items have the data type of OCTET STRING, meaning each is a string of eight-bit bytes (the term OCTET was used rather than BYTE because it can't be assumed that all computers will have eight bits in a byte). The bibliography data item is another definition named "Bibliography" that is used within this one. It might look like this:
Bibliography ::= SEQUENCE { author OCTET STRING title OCTET STRING publisher OCTET STRING year OCTET STRING }
Other data types that can be specified include: INTEGER, BOOLEAN, REAL, and BIT STRING. An ENUMERATED data type is one that takes one of several possible values. Data items can be specified as OPTIONAL (not necessarily present).