I have OID 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. Violating this in 2 bytes will give me 10 00. SNMP data should be sent in single-byte format. Therefore, for large numbers, a special rule is required, because one byte (eight bits) can only represent a number from 0 to 255. The rule is that the highest order bit is used as a flag, so that the recipient knows that this number spans more than one byte.
I pushed the bits to the left and added 1 to the 8th bit.
Left Shift: 20 00
Bit 8 becomes 1: A0 00
Link: [OID Encoding] ( http://www.rane.com/note161.html )
Am I correctly encoded 4096?
What about decoding a data string in the original OID?
Examples would be good for me to understand the concept.
source share