[SNMP4J] Simple Get Request

Mark Roe mroe at planethost.com
Tue May 12 20:09:36 CEST 2009


Have a very simple program:

public static void main(String[] args) {
      CommunityTarget target = new CommunityTarget();
      target.setCommunity(new OctetString("w0lv3r1n3s!"));
      Address address = GenericAddress.parse("udp:10.99.3.1/161");
      target.setAddress(address);
      target.setVersion(SnmpConstants.version2c);
      target.setRetries(2);
      target.setTimeout(1000);

      PDU pdu = new PDU();
      pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.1.1"))); // sysDescr
      pdu.setType(PDU.GETNEXT);

      try {
     Snmp snmp = new Snmp(new DefaultUdpTransportMapping());
     ResponseEvent response = snmp.send(pdu, target);
     PDU responsePDU = response.getResponse();
     Address peerAddress = response.getPeerAddress();
     System.out.print("here" + peerAddress);
     System.exit(1);

      } catch (java.io.IOException ex) {
      }

   }

However, response is always null.  I have performed packet captures and do
in fact see the response from the polled device:
NetScreen-5GT-WLAN version 5.3.0r3.0

Any idea what I may be doing wrong?
-- 
Mark Roe
PlanetHost
http://www.planethost.com
866.661.HOST




More information about the SNMP4J mailing list