2016-04-21 63 views
1

我碰到了一種磚牆。我有一個通過SNMP與DSLAM進行通信的小型系統。 一切都工作正常了幾個月,但當我最近添加一個新的DSLAM的系統,我無法從它得到答案。嘗試了其他知識產權並沒有問題。SNMP響應爲空[SNMP4j]

經過一個小時左右,其他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

那麼,作爲一個朋友指出192不等於195