[SNMP4J] snmp4j 2.2.5 3DES, AES192/256 not working

NarayanaRao Yenduri ynr_ind at yahoo.com
Sun May 11 07:12:43 CEST 2014




On Sunday, May 11, 2014 10:32 AM, NarayanaRao Yenduri <ynr_ind at yahoo.com> wrote:
 
Hi Team,
i am very new to using snmp4j. 
i am using the sample code to get use to this.
https://github.com/mchopker/myprojects/blob/master/TranSenderReceiver/src/SNMPTrapGeneratorClient.java


Following is the method which is working fine for DES and AES128. it is not working for other protocols.

/**
 * Sends the v3 trap
 */
private static void sendSnmpV3AuthTrap() {
try {
long start = System.currentTimeMillis();
Address targetAddress = GenericAddress.parse("udp:" + ipAddress
+ "/" + port);

// Create Transport Mapping
TransportMapping<?> transport = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(transport);
USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(
MPv3.createLocalEngineID()), 0);
USM usm1 = new USM(SecurityProtocols.getInstance(), new OctetString(
MPv3.createLocalEngineID(new OctetString("80001f88806a05a51f521dfd87"))), 0);
SecurityModels.getInstance().addSecurityModel(usm1);
transport.listen();
snmp.getUSM().addUser(
new OctetString("MD5DES"),
new UsmUser(new OctetString("MD5DES"), AuthMD5.ID,
new OctetString("UserName"), PrivAES128.ID,
new OctetString("UserName")));

// Create Target
UserTarget target = new UserTarget();
target.setAddress(targetAddress);
target.setRetries(1);

// set timeout
target.setTimeout(11500);
target.setVersion(SnmpConstants.version3);
target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
target.setSecurityName(new OctetString("MD5DES"));

// Create PDU for V3
ScopedPDU pdu = new ScopedPDU();
pdu.setType(ScopedPDU.NOTIFICATION);

// need to specify the system up time
long sysUpTime = (System.currentTimeMillis() - start) / 10;
pdu.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks(
sysUpTime)));

// Send the PDU
System.out.println("Sending V3 priv Trap to " + ipAddress + " on Port "
+ port+" time is "+new Date());
snmp.send(pdu, target);
/*snmp.addCommandResponder(new CommandResponder() {
@Override
public void processPdu(CommandResponderEvent arg0) {
System.out.println(arg0);
}
});*/
snmp.close();
} catch (Exception e) {
System.err.println("Error in Sending V3 Trap to " + ipAddress
+ " on Port " + port);
System.err.println("Exception Message = " + e.getMessage());
}
}

i am getting below exception with other modes.
"Exception Message = Message processing model 3 returned error: Encryption error"
org.snmp4j.MessageException: Message processing model 3 returned error: Encryption error
at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:501)
at org.snmp4j.Snmp.sendMessage(Snmp.java:1004)
at org.snmp4j.Snmp.send(Snmp.java:885)
at org.snmp4j.Snmp.send(Snmp.java:878)
at org.snmp4j.Snmp.send(Snmp.java:843)
at com.cisco.xbow.hpm.snmp.traps.SNMPTrapGeneratorClient.sendSnmpV3AuthTrap(SNMPTrapGeneratorClient.java:274)


Could you please help me to resolve this.
Thanks in advance,
Narayanarao


More information about the SNMP4J mailing list