[SNMP4J] getting responseing snmp4j

Tayyab Akram mail.tayyab at gmail.com
Tue Jul 15 12:18:50 CEST 2008


Hi Shweta,

[Sorry for duplicate reply. I forgot to add mailing list in CC in previous
message]

There is nothing wrong with your code except that you are expecting the
response of a V1TRAP.
SNMP Version-1 only supports TRAPs and these traps are not acknowledged. So
when the Trap Listener receives your trap it will not send any response.

If you want to use acknowledged traps where you get the response from the
Trap Listener, then you have to use the Version-2c or Version-3 of SNMP.
These are called INFORMS.

Or in simple words INFORM is acknowledged TRAP and is not supported in SNMP
Version-1.

Regards,
--Muhammad Tayyab




On Tue, Jul 15, 2008 at 3:19 PM, Shweta <shweta_naik at persistent.co.in>
wrote:

> HI all, I facing one problem tht getting response always null
>
> I tried following code, when I print response that shows me null but if I
> run this code & check in the runnig tool on my machin i.e in trap receiver
> I
> able to seen mag
>
> But I want to handle response programmatically but it showing me null
>
>
>
>
>
>
>
>
>
>                        Address targetAddress = GenericAddress.parse("udp:"
> + "localhost"
>
>                                                + "/162");
>
>                        CommunityTarget target = new CommunityTarget();
>
>                        target.setCommunity(new OctetString("public"));
>
>                        target.setAddress(targetAddress);
>
>                        target.setRetries(1);
>
>                        target.setTimeout(2000);
>
>                        target.setVersion(SnmpConstants.version1);
>
>                        PDUv1 pdu1 = new PDUv1();
>
>                        pdu1.setGenericTrap(PDUv1.COLDSTART);
>
>                        pdu1.setSpecificTrap(Integer.parseInt(("0")));
>
>                        pdu1.setEnterprise(new org.snmp4j.smi.OID());
>
>                        //pdu1.setEnterprise(new OID(".1.3.6.1.2.1.1.1.0"));
>
>                        pdu1.setType(PDUv1.V1TRAP);
>
>
>
>                        VariableBinding vb = new VariableBinding();
>
>                        vb.setOid(new OID(".1.3.6.1.2.1.1.1.0"));
>
>                        vb.setVariable(new OctetString("This is just test
> trap"));
>
>                        pdu1.add(vb);
>
>                        //pdu1.addOID(new VariableBinding(new
> OID("1.3.6.1.2.1.1.1.0")));
>
>                        try {
>
>                                    //IpAddress sourceIp = new
> IpAddress("10.77.200.82");
>
>                                    IpAddress sourceIp = new
> IpAddress(InetAddress.getLocalHost());
>
>                                    pdu1.setAgentAddress(sourceIp);
>
>                                    //System.out.println("so PDU
> is......."+pdu1);
>
>
>
>                                    DefaultUdpTransportMapping
> udpTransportMap = new DefaultUdpTransportMapping();
>
>                                    udpTransportMap.listen();
>
>                                    Snmp snmp = new Snmp(udpTransportMap);
>
>                                    ResponseEvent response = snmp.send(pdu1,
> target,udpTransportMap);
>
>
>
>
>
>                                    System.out.println("SnmpNotificationTrap
> : pdu1: " + pdu1);
>
>                                    System.out.println("SnmpNotificationTrap
> : response: " + response.getSource());
>
>                                    snmp.close();
>
>
>
>
>
>                        }
>
>                        catch (Exception e) {
>
>                                    e.printStackTrace();
>
>
>
>                        }
>
>
>
>
>
> Thanks
>
> Shweta
>
>
> DISCLAIMER
> ==========
> This e-mail may contain privileged and confidential information which is
> the property of Persistent Systems Ltd. It is intended only for the use of
> the individual or entity to which it is addressed. If you are not the
> intended recipient, you are not authorized to read, retain, copy, print,
> distribute or use this message. If you have received this communication in
> error, please notify the sender and delete all copies of this message.
> Persistent Systems Ltd. does not accept any liability for virus infected
> mails.
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
>



More information about the SNMP4J mailing list