IfIndex计算华为



我正试图通过SNMP通过Python连接到华为设备(MA5608T(。我了解到索引值和端口之间存在对应关系。

但我仍然不明白它是如何翻译的

例如:4194445056.0(索引(=0/17/7(端口(

有人知道该怎么做吗?

试试这个方法:

4194304000 + (slot * (256 * 32)) + pon * 256) + '.' + onu_id

此Javascript代码取自生产。二进制运算将为您提供如何从数据包中提取数据的线索。

function convert_snmp_packet( packet ){

let regex = /[^.]*/g;
let found = packet.match( regex );
if( found.length < 2 ) {
throw new Error( "wrong packet ? " + packet );
}
let left_part = parseInt( found[0] );
// found[1] is just the dot
let ont_index = parseInt( found[ 2 ] );
let slot_num;
let port_num;

slot_num = ( left_part & ( 15 << 13 ) ) >> 13;
port_num = ( left_part & ( 15 << 8 ) ) >> 8;
let json = {
slot_num: slot_num, 
port_num: port_num, 
ont_index: ont_index
};
return json;
}

测试代码:

class packet_Test extends Test {
test_packet(  ){
// packet must be a String for this to work
let p =  "4194445056.0";
let actual = convert_snmp_packet( p );
let expected = { slot_num: 1, port_num: 7, ont_index: 0 };
this.assertEquals( expected, actual );
this.done()
}
}    

对不起,巫师。在华为olt上查找有关SNMP的信息时遇到了这个问题。

最新更新