I have OID of 1.3.6.1.2.1.2.2.1.8.4096 (ifOperStatus)
In my code I have:
MIB[0]=0x2b
MIB[1]=0x06
MIB[2]=0x01
MIB[3]=0x02
MIB[4]=0x01
MIB[5]=0x02
MIB[6]=0x02
MIB[7]=0x01
MIB[8]=0x08
MIB[9]=0xA0
MIB[10]=0x00
where A0 00 represents 4096.
4096 in HEX is 1000. Breaking this in 2 bytes will give me 10 00. SNMP data should be sent in single byte format. Therefore, a special rule is required for large numbers because one byte (eight bits) can only represent a number from 0-255. The rule is the highest order bit is used as a flag to let the recipient know that this number spans more than one byte.
I have shifted the bits to the left and added 1 to the 8th bit.
Shift left: 20 00
Bit 8 becomes 1: A0 00
Reference: [OID Encoding] (http://www.rane.com/note161.html)
Have I encoded the 4096 correctly?
What about decoding string of data to the original OID ?
Examples would be good for me to understand the concept.
Subtract the base from the actual octet value: 1500 – 1408 = 92. Encode this value as a single byte = 0x5C (92 in decimal). As a result encoded value of the OID = 1500 will be: 0x8B 0x5C. Using these rules we can encode OID octets with the value up to 16383 (0xff 0x7f).
Click Get SNMP variable icon (the 7th icon below the menu bar) or go to Operations > Get. The attribute values of each row in the selected SNMP OID are displayed as a result.
An SNMP OID is an object identifier, which is essentially just a string of numbers. Each of these numbers represents a different value, and SNMP uses these to quickly generate relevant information about the data that it receives in this format.
The system object ID of a device is identical to the object ID of the jnxProductName for the platform. For example, for an M7i Multiservice Edge Router, the jnxProductNameM7i is . 1.3.
Yes, you have encoded the OID correctly (as far as the contents go). The full encoding (with tag for OID and length, which were omitted) would be 06 0b 2b 06 01 02 01 02 02 01 08 a0 00.
With regards to encoding/decoding strings in OIDs (presumably an INDEX), the rules depend on whether or not the value in question is for an object defined as a fixed-length or variable-length string, and whether or not the IMPLIED keyword was used in defining the INDEX.
If it's a fixed-length string, or variable-length string with IMPLIED keyword (which would have to be the last INDEX object) then it is encoded simply as one subidentifier per byte of string. Otherwise, a variable-length string is encoded with one subidentifier to indicate the length of the string, followed by each byte encoded in a single subidentifier as with fixed-length.
RFC 2578 section 7.7 details the rules for encoding values for INDEX objects in an OID.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With