[SNMP4J] Invalid trap checksum??
Neil Cohen
ncohen at verisign.com
Tue Mar 1 16:49:25 CET 2011
I have created a java program using SNMP4J which generates and sends an
SNMP v1 trap. The basic code looks like this:
private void sendTrap(String alertMsg) {
OID oid = new OID("1.2.3.4.5.2");
try {
PDUv1 pdu = new PDUv1();
pdu.setType(PDU.V1TRAP);
pdu.setAgentAddress(new IpAddress("2.2.2.2"));
pdu.setGenericTrap(PDUv1.ENTERPRISE_SPECIFIC);
pdu.setSpecificTrap(1);
pdu.setEnterprise(oid);
pdu.add(new VariableBinding(oid, new OctetString(alertMsg)));
CommunityTarget comTarget = new CommunityTarget();
comTarget.setCommunity(new OctetString(snmpCommunity));
comTarget.setVersion(SnmpConstants.version1);
comTarget.setAddress(new UdpAddress("1.2.3.4/162")); //
Host address is actuall a valid address...
comTarget.setRetries(2);
comTarget.setTimeout(5000);
TransportMapping transport = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(transport);
snmp.send(pdu, comTarget);
snmp.close();
transport.close();
transport = null;
Logger.info("SNMP sent...");
} catch (Exception e) {
Logger.error("Exception: " + e);
e.printStackTrace();
}
}
I ran tcpdump on the receiving system and got this:
[root at nbc-verisign ~]# tcpdump -vvv port 162
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size
65535 bytes
10:41:34.724763 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto
UDP (17), length 357)
nbc.vrsn.com.49834 > 1.2.3.4.snmp: [bad udp cksum 52d!]{ SNMPv1
C=<communityString> { Trap(310) .2.11etc. etc.
The incoming string looks to be correct. But I'm concerned about the
'bad udp cksum' section. Is there a way to create the checksum before
the message is sent? If not, what would be the error here, and how do I
correct it??
thanks very much,
nbc
--
NAME: Neil B. Cohen (Verisign Inc.)
PHONE: 703-948-4471
DOMAIN: ncohen at verisign.com
**********************************************************
* Murphy's Philosophy: Smile - tomorrow will be worse...
*
* O'Tooles Commentary: Murphy was an optimist!
**********************************************************
More information about the SNMP4J
mailing list