gpt4 book ai didi

C# SNMP 编程

转载 作者:行者123 更新时间:2023-12-04 02:21:58 26 4
gpt4 key购买 nike

我尝试编写一些代码来检索 objectID,结果是 2B-06-01-04-01-82-31-01-03-01-01 .
这个值不正确吗?

// Send a SysObjectId SNMP request
response = conn.get("get", argv[0], argv[1], "1.3.6.1.2.1.1.2.0");
if (response[0] == 0xff)
{
Console.WriteLine("No response from {0}", argv[0]);
return;
}

// Get the community and MIB lengths of the response
commlength = Convert.ToInt16(response[6]);
miblength = Convert.ToInt16(response[23 + commlength]);

// Extract the MIB data from the SNMp response
datatype = Convert.ToInt16(response[24 + commlength + miblength]);
datalength = Convert.ToInt16(response[25 + commlength + miblength]);
datastart = 26 + commlength + miblength;
output= BitConverter.ToString(response, datastart, datalength);
Console.WriteLine(" sysObjectId - Datatype: {0}, Value: {1}",
datatype, output);

conn.get("get", argv[0], argv[1], "1.3.6.1.2.1.1.2.0")意味着它只执行get协议(protocol)?怎么设置?

最佳答案

真的,如果你想在 C# 中使用 SNMP,试试这个程序集 SNMPSharpNet .它非常有用。

您将在 this StackOverflow 中找到回答使用它的一种方式(高级)的示例。

但是看看文档。您可以通过两种方式使用此程序集:

  • 低级别创建您自己的 SNMP(V1、V2c、V3)PDU
  • 高级,您只需使用 SNMP

  • 就试一试吧。

    J.P

    关于C# SNMP 编程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5473198/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com