Brrr….Its Hot : –
The compilation rules for converting data-types into bits and bytes is called the transfer syntax.Basic Encoding Rules or BER is the transfer syntax for SNMP and LDAP. BER and ASN.1 were designed by the same people (not network administrators alone) and hence go hand in hand. This fact makes life simpler on this planet. But how does BER manage to do all this, after all it has to take case of so many data-types, and it is used to write hundreds of protocols. It is indeed mind boggling. To know more about BER lets get cracking Fortunately we will only discuss BER in the context of ASN.1 implementation of SNMP and LDAP.
BER uses the concept of an ‘identifier’. An identifier is a unique code assigned to every data-type. This identifier acts as the calling code for that data-type. We distinguish between two data-types using these identifiers. The data-types are further classified into groups. But before we proceed any further answer this simple question. Are the books in your college or school library piled one over the other with no semblance of order? The answer is a definite NO. (Those answering yes will have to get a new librarian). The books out there are classified into various groups according to a pre-defined order like subject, ISBN number etc. The designers of BER being an inspired lot, did the same thing. They classified the BER identifiers into 4 classes.
- Universal Available for use within any protocol. The primitive data-types -INTERGER, OCTECT string, OBJECT IDENTIFIER, and NULL, are universal. The basic constructors, such as SEQUENCE, also are universal.
- Application Available within a specific application. For example, the IpAddress data-types is available for use throughout the TCP/IP network management application.
- Context-specific This data-type is contained in a larger data-type. The identifier has a unique meaning within the context of the larger data-type (like those featured in 2 and 5 above)
- Private Included so that ASN.1 could be used by private organizations to define proprietary data-types.
Lets look at the structure of a BER identifier
|1||Non Primitive Data-type – Constructed|
The eighth and the seventh bits combine to denote the class of the BER identifier. The implications of these bits have been summarized in the table shown above. The sixth bit of the identifier indicates whether the represented data-type is a primitive or constructed one. The remaining bits of the identifier represent a numeric tag associated with a data-type. Some of the data-types and the numeric tag associated with them are as shown below.
|04||0 0100||OCTET String|
It makes a very interesting observation that when we are representing the length of a structure, integer etc. the byte following the structure tag, or the ‘keyword’ integer is used to indicate the length of the corresponding data type. Does this mean that the maximum length that can be indicated in BER related ‘languages’ is 255 bytes long. Wrong!, BER is far too advanced to be held back by such a drawback. In a situation where the length of the datatype exceeds one byte, the byte succeeding the data-type declaration has ‘1’ in the 8th field followed by the length of the succeeding bytes which are used to represent the datatype. For example to indicate a length of an structure which is ‘0xabcd’ bytes (43981) large we will use the following representation
|0x82||length of structure is spread over two byte|
|the actual length|
Thus we assign a unique numeric tag to each of the countless data-types possible. These data-types along with their class names and their type name uniquely identifies the variable in the protocol. These rules are adopted across the board irrespective of the protocol in which they are used. We believe that this much background information is sufficient for knowing the basics of BER. So it’s time we took a peek at how the BER is used in the various protocols
The above tutorial is a joint effort of
Mr. Vijay Mukhi
Ms. Sonal Kotecha
Mr. Arsalan Zaidi
Mr. Vinesh Kurup
(This blog appeared in Vijay Mukhi Technology Cornucopia website in 1996)