【发布时间】:2015-10-09 12:02:20
【问题描述】:
我正在用 C# 编写软件,通过 SNMP 测量或利用输出或八位字节(字节)。我需要在 1000 秒内传递多少字节?
根据我的研究,它的值有时会超时或重置,因为某些结果给出了负值。
.1.3.6.1.2.1.2.2.1.10 用于 .139
在 1024 秒内,结果为 -2,1 MBytes。
如何准确测量流量(进出)?
编辑:我用于计算的这段代码。它在每一秒都有价值并得到结果。
private void timer1_Tick(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
SnmpObject objSnmpObject, objSnmpIfSpeed;
objSnmpObject = (SnmpObject)objSnmpManager.Get(".1.3.6.1.2.1.2.2.1.16.139");
objSnmpIfSpeed = (SnmpObject)objSnmpManager.Get(".1.3.6.1.2.1.2.2.1.5.139");
if (GetResult() == 0)
{
float value = Int64.Parse(objSnmpObject.Value);
float ifSpeed = Int64.Parse(objSnmpIfSpeed.Value);
float Bytes = (value * 8 * 100 / ifSpeed);
// float megaBytes = Bytes / 1024;
sum += Bytes;
tb_calc.Text = (sum.ToString() + " Bytes");
}
_gv_timeSec++;
lb_timer.Text = _gv_timeSec.ToString();
Cursor.Current = Cursors.Default;
}
【问题讨论】: