ASN.1 has sets of rules precisely specifying how messages must be "encoded" for communication with other machines. Each set of "encoding rules" has specific characteristics, such as compactness or decoding speed, which make it best suited for particular environments. Note that all of the encoding rules are able to represent any messages you would like to exchange.
The oldest encoding rule, BER (BASIC ENCODING RULES), uses a Tag-Length-Value (TLV) format for encoding all information. BER always sends a tag to indicate what kind of data follows, then a length indicating the length of the data that follows, then the value which is the actual data. Two related encoding rules, DER (DISTINGUISHED ENCODING RULES) and CER (CANONICAL ENCODING RULES) are subsets of BER which eliminate some of the extra flexibility provided by BER. Note that DER is commonly used in security-related applications such as X.509 digital certificates.
The fastest of the ASN.1 encoding rules is OER (Octet Encoding Rules). The Octet Encoding Rules (OER), like the Packed Encoding Rules (PER), produce compact encodings by taking advantage of information present in the ASN.1 schema to limit the amount of information included in each encoded message. However, in contrast to PER, OER favors encoding/decoding speed and ease of implementation over compactness of the encodings. Unlike PER Aligned, OER is completely octet-oriented. Whereas in PER Aligned a fixed-size encoding occupying less than 8 bits may begin at any bit position within an octet and may end at any bit position within the same or another octet, in OER the encoding of every possible value of every ASN.1 type occupies a whole number of octets, and all the fields of the encoding are octet-aligned. OER is used in Intelligent Transportation protocols and is highly suited for any protocol for which the speed of encoding/decoding is essential.
The most compact of the encoding rules is PER (PACKED ENCODING RULES). PER differs from BER in that PER does not send the Tag of the TLV since the order in which components of the message occur is known. PER also does not send the Length of the TLV if the Value has a fixed length. PER also uses additional information from the ASN.1 message description to eliminate redundant information from the Value portion of the TLV, thus making PER messages quite compact and suitable for environments in which bandwidth conservation is important. There are two ways to encode messages in PER - Aligned and Unaligned. With the Aligned PER, a field can be aligned to 8-bit octet boundaries by inserting padding bits. With the Unaligned PER, pad bits are never inserted between fields. Unaligned PER is commonly used in 3GPP cellular technologies such as UMTS (3G) or LTE (4G) for protocols like RANAP, NBAP or RRC.
The least compact of the encoding rules, XER (XML ENCODING RULES), uses a textual XML format for its encodings of the form <start-tag> value <end-tag>. The XER and E-XER (Extended XER) differ in that the default encodings produced by E-XER are more suitable for exchanging information with XML Schema Definition (XSD) engines. Note that the same ASN.1 specification can be used with multiple encoding rules, which means that a PER message from a cell phone could be converted to E-XER for display and manipulation in a web browser.