[SNMP4J] Problem when i receive SNMPv3 Trap...?
Bala Sundaram
balasundaram.06 at gmail.com
Sat Apr 11 08:39:59 CEST 2009
Dear friends,
am trying to send SNMPv3 trap,
when i monitor(using Wireshark tool) destination place am
getting SNMP protocol, but after i tried to expand header... it does not
have any content and it shows
*msgVersion: snmpv3 (3)
msgGlobalData
msgID: 1408349117
msgMaxSize: 65535
msgFlags: 04
.... .1.. = Reportable: Set
.... ..0. = Encrypted: Not set
.... ...0 = Authenticated: Not set
msgSecurityModel: USM (3)
msgAuthoritativeEngineID: <MISSING>
msgAuthoritativeEngineBoots: 0
msgAuthoritativeEngineTime: 0
msgUserName:
msgAuthenticationParameters: <MISSING>
msgPrivacyParameters: <MISSING>
msgData: plaintext (0)
plaintext
contextEngineID: <MISSING>
contextName: <MISSING>
data: informRequest (6)
informRequest
request-id: 0
error-status: noError (0)
error-index: 0
variable-bindings: 0 items*
*and my code part is,,,, i don't know where am doing mistake... Please
correct it....*
*try* {
*long* start = System.*currentTimeMillis*();
Address targetAddress = GenericAddress.*parse*("udp:" +
targetIP + "/" + 162**);
TransportMapping transport =
*new*DefaultUdpTransportMapping();
Snmp snmp = *new* Snmp(transport);
USM usm = *new* USM(SecurityProtocols.*getInstance*(),
*new* OctetString(MPv3.*createLocalEngineID*()),
0);
SecurityModels.*getInstance*().addSecurityModel(usm);
transport.listen();
snmp.getUSM().addUser(*new* OctetString("MD5DES"),
*new* UsmUser(*new* OctetString("MD5DES"),
AuthMD5.*ID*,
*new* OctetString(
"MD5DESUserAuthPassword"),
PrivDES.*ID*,
*new* OctetString(
"MD5DESUserPrivPassword")));
UserTarget target = *new* UserTarget();
target.setAddress(targetAddress);
target.setRetries(1);
// set timeout to 500 milliseconds -> 2*500ms = 1s total
timeout
target.setTimeout(11500);
target.setVersion(SnmpConstants.*version3*);
target.setSecurityLevel(SecurityLevel.*AUTH_PRIV*);
target.setSecurityName(*new* OctetString("MD5DES"));
ScopedPDU pdu = *new* ScopedPDU();
pdu.setType(PDU.*INFORM*);
// sysUpTime
*long* sysUpTime = (System.*currentTimeMillis*() - start)
/ 10;
pdu.add(*new* VariableBinding(SnmpConstants.*sysUpTime*, *
new* TimeTicks(sysUpTime)));
pdu.add(*new* VariableBinding(SnmpConstants.*snmpTrapOID*,
SnmpConstants.*linkDown*));
// payload
pdu.add(*new* VariableBinding(*new* OID(
"1.3.6.1.2.1.2.2.1.1.1"), *new* Integer32(1)));
// send the PDU
ResponseEvent response = snmp.send(pdu, target);
*if* (response.getResponse() == *null*)
{
System.*err*.println("Timeout...");
}
*else* {
System.*out*.println("Received response from : " +
response.getPeerAddress());
// dump response PDU
System.*out*
.println(response.getResponse().toString());
}
} *catch* (Exception e) {
e.printStackTrace();
}
Thank you,
Boss134
More information about the SNMP4J
mailing list