[SNMP4J] request / response

Torsten Curdt tcurdt at apache.org
Tue Oct 24 13:24:06 CEST 2006


In order to get a bit more into the snmp4j API I am currently trying a
bit with the request / response handling. I am sending and answering
to a GET

request PDUGET[requestID=1758401584, errorStatus=Success(0),
errorIndex=0, VBS[1.3 = Null]]
response PDUGET[requestID=0, errorStatus=Success(0), errorIndex=0,
VBS[1.3 = 1161688402134]]
done

With this code:

	public void processPdu(CommandResponderEvent pRequest) {
		final PDU requestPdu = pRequest.getPDU();
		if (requestPdu != null) {
			
			System.out.println("request PDU" + requestPdu);

            try {

            	final PDU responsePdu = new PDU();
            	responsePdu.add(new VariableBinding(new OID("1.3"), new
Counter64(System.currentTimeMillis())));

    			System.out.println("response PDU" + responsePdu);
            	
            	pRequest.getStateReference().setTransportMapping(pRequest.getTransportMapping());
            	pRequest.getMessageDispatcher().returnResponsePdu(
            			pRequest.getMessageProcessingModel(),
            			pRequest.getSecurityModel(),
            			pRequest.getSecurityName(),
            			pRequest.getSecurityLevel(),
            			responsePdu,
            			pRequest.getMaxSizeResponsePDU(),
            			pRequest.getStateReference(),
            			new StatusInformation()
            			);
            	
            	System.out.println("done");
            	
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

But it seems horrible slow until it shows up in the MIB browser.
Something wrong with the code?

cheers
--
Torsten



More information about the SNMP4J mailing list