我碰到了一堵砖墙。我有一个小型系统,通过SNMP与DSLAM通信。 一切都运行了好几个月,但是当我最近在系统中添加了一个新的DSLAM时,我无法从中得到答案。试过其他IP并且没有问题。
一个小时左右后,其他DSLAM突然停止接听我。所以现在我有两个单位没有任何沟通,这有点糟糕。所以当然我检查了单位,并没有发现问题。通过我的MIB浏览器,我可以访问所有单元......但不能通过我的软件。所以错误就在我的软件中。所以我检查了Wireshark,发现getNext请求已经出去了,但我似乎没有得到答案。当我通过MIB浏览器进行操作时,会有一个答案。但有趣的是:两个请求是相同的。所以我一定不听 - 是的,它正在倾听。
为什么世界上某些知识产权是特定的,亲爱的主为什么会互相污染?
让我们看看一些代码:
public String GetNextValue(String OID, Dslam dslam) throws IOException {
Snmp snmp = new Snmp(new DefaultUdpTransportMapping());
snmp.listen();
CommunityTarget target = initializeTarget(dslam);
PDU request = new PDU();
request.setType(PDU.GETNEXT);
OID oid= new OID(OID);
request.add(new VariableBinding(oid));
PDU responsePDU=null;
ResponseEvent responseEvent;
responseEvent = snmp.send(request, target);
if (responseEvent != null){
System.out.println("resonse event not null..");
responsePDU = responseEvent.getResponse();
if ( responsePDU != null){
System.out.println("pdu not null..");
@SuppressWarnings("unchecked")
Vector <VariableBinding> tmpv = (Vector<VariableBinding>) responsePDU.getVariableBindings();
if(tmpv != null){
System.out.println("tmpv not null..");
VariableBinding vb = (VariableBinding) tmpv.get(0);
if(!vb.isException()){
return vb.getVariable().toString()
}
}
}
}
_errorHandler.criticalError("Response error in DSLAM communication");
return null;
}
初始化程序:
private CommunityTarget initializeTarget(Dslam dslam){
Address addr = new UdpAddress(dslam.getAddress() + "/" + dslam.getManagementPort() );
System.out.println("IP: " + dslam.getAddress() + " port: " + dslam.getManagementPort());
CommunityTarget target = new CommunityTarget(addr, new OctetString("public"));
target.setVersion(SnmpConstants.version2c);
target.setTimeout(3000);
target.setRetries(3);
return target;
}
如果我们对正在运行的DSLAM进行测试:
@Test
public void Lowtest() throws IOException{
SnmpController snmpController = SnmpController.GetInstance();
DslamGrabber dslamGrabber = new DslamGrabber();
Dslam dslam = dslamGrabber.getByDslamId("test5xda5");
String result = snmpController.GetNextValue(".1.3.6.1.4.1.637.61.1.39.3.3.1.1.2", dslam);
System.out.println(result);
}
结果:
IP: 195.215.96.135 port: 161
resonse event not null..
pdu not null..
tmpv not null..
OID: 1.3.6.1.4.1.637.61.1.39.3.3.1.1.2.1
BF512_2048
我们尝试对抗test5xda9(第二个屈服于这种可怕的疾病般的错误)
我们在Wireshark中重试了3次,输出如下:
IP: 192.215.96.139 port: 161
resonse event not null..
Response error in DSLAM communication
null
我真的希望有人能帮助我。我要在几个小时之后才能流泪或打破DSLAM。
祝你好运 本
答案 0 :(得分:0)
好吧,正如一位朋友指出192不等于195。