Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SNMP packet length encoding vs OID encoding

679 views
Skip to first unread message

Praki

unread,
Jan 21, 2009, 6:02:26 AM1/21/09
to
Greetings All,

When I check the snoop pf the packets, i had confusion about the
encoding of the length integer and integer value in the OID. For
length it is said as 82 00 3E it means that next two bytes gives the
length of the packet. Then in the OID the integer value is given as
94 78 for 2680. it means that (0x14 *128) + 0x78 = 2680. now my doubt
is both the calculations are some or it has different method to
calculate.

Thanks in advance

Thanks,
Prakash

Dr. Juergen Schoenwaelder

unread,
Jan 22, 2009, 2:23:13 PM1/22/09
to
Praki <visitpra...@gmail.com> wrote:

> When I check the snoop pf the packets, i had confusion about the
> encoding of the length integer and integer value in the OID. For
> length it is said as 82 00 3E it means that next two bytes gives the
> length of the packet. Then in the OID the integer value is given as
> 94 78 for 2680. it means that (0x14 *128) + 0x78 = 2680. now my doubt
> is both the calculations are some or it has different method to
> calculate.

An INTEGER is an INTEGER and an OBJECT IDENTIFIER is an OBJECT
IDENTIFIER. Search for the Basic Encoding Rules for these ASN.1
base types.

/js

--
Juergen Schoenwaelder Jacobs University Bremen gGmbH
Phone: +49 421 200 3587 Campus Ring 1, 28759 Bremen, Germany
Fax: +49 421 200 3103 <http://www.jacobs-university.de/>

shamshe...@gmail.com

unread,
Sep 19, 2012, 11:32:14 PM9/19/12
to
I want to ask a question regarding sequence length format in snmp response.

from some device we receive snmp response as "30 3f 02 01 00 ...."
here 3f gives the length of the PDU length.
But from some other device we receive "30 82 00 3b 02 01 00 ........". Here "82 00 3b" represents the length of PDU.
Here how do we translate "82 00 3b" to the length of PDU. Also Basic encoding rule cannot resolve this because of "00".

These two different types of responses are confusing me.
Any body having some information regarding this then please help me.
Shamsher

shamshe...@gmail.com

Jürgen Schönwälder

unread,
Oct 11, 2012, 6:01:45 PM10/11/12
to
shamshe...@gmail.com wrote:
> I want to ask a question regarding sequence length format in snmp response.
>
> from some device we receive snmp response as "30 3f 02 01 00 ...."
> here 3f gives the length of the PDU length.
> But from some other device we receive "30 82 00 3b 02 01 00 ........".
> Here "82 00 3b" represents the length of PDU.
> Here how do we translate "82 00 3b" to the length of PDU. Also Basic
> encoding rule cannot resolve this because of "00".
>

Both are valid BER encodings:

In the first case, the length is encoded directly following the
tag. The length is 3f, which is 63 in the decimal number system.
This encoding works for length value up to 127 (the most
significant bit must be zero).

The second case has the most significant bit set and the remaining
bits now indicate the number of following octets that carry the
length value. In this case, 82 means that the following 2 octets
carry the length. In this example, you have 00 3b, which is 59 in
the decimal number system.

Producing the first more compact encoding requires a bit more effort
since the encoder needs to know how many octets the data encoded in
the sequence before encoding the length value. The second encoding is
often used by encoders that are too lazy to produce compact encoding.
By starting the encoding with 30 82 00 00, one can later 'patch' the
length value into the encoding buffer once the encoding of the data
in the sequence is complete, that is the encoding size is known.
0 new messages