本文介绍了SNMP PDU中的变量绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用C#开发一个Snmp实用程序,可以从设备的指定Oid获取数据.我正在使用Snmp version1数据包格式.
我已经快完成了,但是他们是我无法解决的问题.

我通过发送单个"Get"数据包成功查询了一个变量,但我需要通过发送单个数据包查询多个变量.

我以这种方式尝试过:

I am developing a Snmp utility in C# which can fetch data from a specified Oid of a device.I am using Snmp version1 packet format.
I have almost completed it but their is a problem that I am not able to resolve.

I am successfully querying one variable by sending single "Get" packet but I need to query multiple variables by sending single packet.

I tried it in this way:

//variable bindings
                p[bytepos++] = 0x30; //variable bindings sequence
                p[bytepos++] = Convert.ToByte(6 + oid_len - 1 + 6 + oid_len2 - 1); // Size of variable binding

                p[bytepos++] = 0x30; //first variable bindings sequence
                p[bytepos++] = Convert.ToByte(4 + oid_len - 1); // size
                p[bytepos++] = 0x06; //Object type
                p[bytepos++] = Convert.ToByte(oid_len - 1 ); //length
                //Start of MIB
                p[bytepos++] = 0x2b;
                for (i = 2; i < oid_len; i++)
                    p[bytepos++] = Convert.ToByte(oid[i]);
                p[bytepos++] = 0x05; //Null object value
                p[bytepos++] = 0x00; //Null


                //start of second variable bindings sequence
                p[bytepos++] = 0x30; //Second variable bindings sequence
                p[bytepos++] = Convert.ToByte(4 + oid_len2 - 1 ); // size
                p[bytepos++] = 0x06; //Object type
                p[bytepos++] = Convert.ToByte(oid_len2 - 1); //length
                //Start of MIB
                p[bytepos++] = 0x2b;
                //Place MIB array in packet
                for (i2 = 2; i2 < oid_len2; i2++)
                    p[bytepos++] = Convert.ToByte(oid2[i2]);
                p[bytepos++] = 0x05; //Null object value
                p[bytepos++] = 0x00; //Null





我在Google上搜索了很多,但是找不到任何相关的东西.请帮忙!





I googled a lot but couldnot find any thing relevent.Please Help!!

推荐答案


这篇关于SNMP PDU中的变量绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 10:36