[SNMP4J] SNMP v3 Traps, Cannot receive from device

Ramsey Hage RHage at talkswitch.com
Thu Jun 9 21:33:25 CEST 2005


Hello,
 
I am interested in receiving SNMPv3 traps to my SNMP manager, using
SNMP4J 1.5,
JDK5.0 (on startup of manager).
 
According to SNMP standards, traditional SNMP managers require a 
"Notification Receiver Application" to handle the incoming trap.  It
seems that
to handle SNMPv3 traps with SNMP4J, we need to instantiate a
CommandResponder.
1) Is this correct?
2) I have tried it, with no success.  I am not receiving the trap
(below).
 
I am planning to keep a static variable for "Snmp" class, register a
CommandResponder 
instance to the static Snmp instance, and use the static Snmp instance
to send requests
and handle the traps.
 
The manager calls the initialize, at startup.  I expect to be able to
receive the trap (below)
after this call is done.  I am not receiving it.
 
Please advise, am I doing something wrong?
 
________________________________

Actual Code Snipet:
________________________________

public class X {
    private static Snmp snmp = null;
            
    public X() {
    }
    
    public static void initialize() {
        try {
            TransportMapping transport = new
DefaultUdpTransportMapping();
            snmp = new Snmp(transport);
            MPv3 mpv3 =
 
(MPv3)snmp.getMessageProcessingModel(MessageProcessingModel.MPv3);
            
            USM usm = new USM(SecurityProtocols.getInstance(),
                              new OctetString("abcd"), 0);
            SecurityModels.getInstance().addSecurityModel(usm);
            transport.listen();
        }
        catch (IOException e1) {
            e1.printStackTrace();
        }
 
        CommandResponder trapPrinter = new CommandResponder() {
                public synchronized void
processPdu(CommandResponderEvent e) {
                    e.setProcessed(true);
                    System.out.println("Caught");    // Not hit, PROBLEM
!!!!!!!
                }
        };
        snmp.addCommandResponder(trapPrinter);
        snmp.getUSM().addUser(
                new OctetString("admin"),
                new UsmUser(   new OctetString("admin"),
                                        AuthMD5.ID,
                                        new OctetString("bulu1234"),
                                        PrivDES.ID,
                                        new
OctetString("MD5DESUserPrivPassword")));
    }
 
 
________________________________

Captured SNMP trap on network:
________________________________

Frame 17 (153 bytes on wire, 153 bytes captured)
Ethernet II, Src: 00:0f:4d:00:01:16, Dst: 00:20:18:2c:10:6d
Internet Protocol, Src Addr: 192.168.0.105 (192.168.0.105), Dst Addr:
192.168.0.188 (192.168.0.188)
User Datagram Protocol, Src Port: snmp (161), Dst Port: snmptrap (162)
Simple Network Management Protocol
    Version: 3 (3)
    Message Global Header
        Message Global Header Length: 13
        Message ID: 1
        Message Max Size: 2000
        Flags: 0x00
            .... .0.. = Reportable: Not set
            .... ..0. = Encrypted: Not set
            .... ...0 = Authenticated: Not set
        Message Security Model: USM
    Message Security Parameters
        Message Security Parameters Length: 25
        Authoritative Engine ID: 61626364
        Engine Boots: 2
        Engine Time: 0
        User Name: admin
        Authentication Parameter: 
        Privacy Parameter: 
    Context Engine ID: 61626364
    Context Name: lan
    PDU type: TRAP-V2 (7)
    Request Id: 0x00000001
    Error Status: NO ERROR (0)
    Error Index: 0
    Object identifier 1: 1.3.6.1.2.1.1.3 (SNMPv2-MIB::sysUpTime)
    Value: Timeticks: (12) 0:00:00.12
    Object identifier 2: 1.3.6.1.6.3.1.1.4.1 (SNMPv2-MIB::snmpTrapOID)
    Value: OID: SNMPv2-MIB::coldStart 
________________________________

    



More information about the SNMP4J mailing list