29.9.10

Basic Encoding Rule (BER)

http://en.wikipedia.org/wiki/Basic_Encoding_Rules

 

The Basic Encoding Rules (BER) is one of the encoding formats defined as part of the ASN.1 standard specified by the IT in X.690.

TLV encoding

TLV: Type + Length + Value

I developed many protocols using TLV encoding in my previous jobs. It’s very flexible and efficient.

However, in my designs, the structures are flat. The encoding of a PDU consists of cascaded TLV encodings, encapsulating types are SEQUENCE, SET and CHOICE.

More over, in my designs, types are 32 bits integers, while other people develop the type as an octet specifying the characteristics of the value field. The reason is very simple: I usually don’t care too much about the network efficiency, while the public protocol designer must take good care about it.

Class bits

00 – Universal

The value is of a type native to ASN.1.

01 – Application

The Application class is only valid for one specific application.

10 – Context specific

Context-specific depends on the context (such as within sequence, set of choice)

11 – Private

Private can be defined in private specifications.

Universal Class Tags

http://luca.ntop.org/Teaching/Appunti/asn1.html

Name P/C Number (decimal) Number (hexadecimal)
EOC (End-of-Content) P 0 0
BOOLEAN P 1 1
INTEGER P 2 2
BIT STRING P/C 3 3
OCTET STRING P/C 4 4
NULL P 5 5
OBJECT IDENTIFIER P 6 6
Object Descriptor P 7 7
EXTERNAL C 8 8
REAL (float) P 9 9
ENUMERATED P 10 A
EMBEDDED PDV C 11 B
UTF8String P/C 12 C
RELATIVE-OID P 13 D
SEQUENCE and SEQUENCE OF C 16 10
SET and SET OF C 17 11
NumericString P/C 18 12
PrintableString P/C 19 13
T61String P/C 20 14
VideotexString P/C 21 15
IA5String P/C 22 16
UTCTime P/C 23 17
GeneralizedTime P/C 24 18
GraphicString P/C 25 19
VisibleString P/C 26 1A
GeneralString P/C 27 1B
UniversalString P/C 28 1C
CHARACTER STRING P/C 29 1D
BMPString P/C 30 1E

Usage

Despite its perceived problems, BER is a popular format for transmitting data, particularly in systems with different native data encodings.

  • The SNMP protocol specifies ASN.1 with BER as its required encoding scheme.

No comments: