[SNMP4J] SNMP GET, SET, INFORM problem

Frank Fock fock at agentpp.com
Fri Jul 17 21:43:53 CEST 2009


Aidan,

If you do not specify a contextengineID, SNMP4J
will set it to the authoritative engine ID.

The usmNotInTimeWindow error can have many causes.
First, I would check if your engine ID differs from
that of the agent.

Best regards,
Frank

Aidan Diffey wrote:
> All.
> 
> I am writting an SNMP mamanger to perform GET / SET and receive INFORM
> messages from an SNMP agent.
> The agent is using SNMP V3.
> 
> I have looked through the list, and I think that I am creating the
> PDU, Target and adding the USM correctly. (below is the code).
> But, when I send the PDU to the SNMP agent, I get a usmNotInTimeWindow
> (1.3.6.1.6.3.15.1.1.2.0).
> 
> From looking at the code below, am I doing it correctly?
> 
> I userstand that the agent uses SHA authentication, but I am unsure if
> I need to specify the ContextEngineID of AuthoritiveEngineID when I
> create and send the PDU.
> 
> --Aidan
> 
> ====Adding USM user===
>  OctetString localEngineID = new OctetString(MPv3.createLocalEngineID());
>  USM usm = new USM(SecurityProtocols.getInstance(),
>                             new OctetString(localEngineID), 0);
> 
>  // add user to the USM
>  UsmUser user = new UsmUser(
>                                             new OctetString("UserName"),
>                             AuthSHA.ID,
>                             new OctetString("password")
>                            null, null
>                            );
> 
> SecurityModels.getInstance().addSecurityModel(usm);
> snmp.getUSM().addUser(user.getSecurityName(), user);
> ====
> 
> ===Send GET===
> Address targetAddress = GenericAddress.parse("udp:172.16.100.246/161");
> 
> UsmUserEntry userEntry = snmp.getUSM().getUserTable().getUser(new
> OctetString("UserName"));
> 
> UserTarget target = new UserTarget();
> target.setSecurityLevel(SecurityLevel.AUTH_NOPRIV);
> target.setSecurityName(userEntry.getUsmUser().getSecurityName());
> target.setVersion(SnmpConstants.version3);
> target.setAddress(targetAddress);
> target.setRetries(1);
> target.setTimeout(5000);
> 
> ScopedPDU pdu = new ScopedPDU();
> pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.1.3")));
> pdu.setType(PDU.GETNEXT);
> 
> ResponseEvent e = snmp.send(pdu, target);
> if (e != null)
> {
>  ScopedPDU pduR = (ScopedPDU)e.getResponse();
> }
> 
> 
> =============
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list