[SNMP4J] SNMP4J V3 perfromance
Deon van der Merwe
dvdm at truteq.co.za
Wed Oct 26 08:29:22 CEST 2005
Hi Scott,
Not sure if it works the same with V2c and V3, but here is how I
handle INFORM's using V2c. I simply set the type of message to
RESPONSE and send it straight back.
public synchronized void processPdu(
org.snmp4j.CommandResponderEvent aEvent) {
org.snmp4j.PDU vPDU = aEvent.getPDU();
switch(vPDU.getType()) {
case org.snmp4j.PDU.TRAP:
case org.snmp4j.PDU.V1TRAP:
newTrap(vPDU);
break;
case org.snmp4j.PDU.INFORM:
newTrap(vPDU);
try {
vPDU.setType(org.snmp4j.PDU.RESPONSE);
sendResponse(vPDU);
} catch (java.lang.Exception vException) {
mLogger.error(vException.getMessage(), vException);
}
break;
}
}
At 12:55 AM 10/26/2005, Scott VanWart wrote:
>Frank,
>
>This is what I am trying to do. If I reply with getBulk, the trap seems
>to process properly, but it's slow. If I respond with
>MessageDispatcher.returnResponsePdu it is very fast but the response
>does not seem correct since I receive the trap 6 times.
>
>How should I properly be responding the INFORM?
>
>Thanks,
>Scott
>
>private class SNMPResponder implements CommandResponder
>{
> public synchronized void processPdu(CommandResponderEvent e)
> {
> PDU command = null;
> String payload = "";
> String src = "";
>
>
> try
> {
> command = e.getPDU();
> //command.setType(PDU.INFORM);
> Address source = e.getPeerAddress();
> e.setProcessed(true);
>
> if (e.getMessageProcessingModel() ==
>MessageProcessingModel.MPv3)
> {
> //MultiThreadedMessageDispatcher md =
>(MultiThreadedMessageDispatcher) e.getMessageDispatcher();
>
>
> // send response.
> UserTarget target = new UserTarget();
> target.setAddress(source);
>
>target.setVersion(SnmpConstants.version3);
> target.setSecurityName(new
>OctetString(user));
>
>target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
>
> snmp.getBulk(command, target);
>
>-----Original Message-----
>From: Frank Fock [mailto:fock at agentpp.com]
>Sent: Tuesday, October 25, 2005 7:50 PM
>To: Scott VanWart
>Cc: snmp4j at agentpp.org
>Subject: Re: [SNMP4J] SNMP4J V3 perfromance
>
>Hi Scott,
>
>Sorry, I do not see how the code snippet is related to that?
>
>Best regards,
>Frank
>
>Scott VanWart wrote:
>
> >Hi Frank,
> >
> >I am not actually trying to send traps. I am trying to simply respond
>to
> >the Request that I receive. I am listening for Informs and not sending,
> >but the Inform requires a respsonse. Is this not the correct way to do
> >it? Should I be sending a GetBulk? The getBulk is Veerrrrry slow.
> >
> >Thanks,
> >Scott
> >
> >-----Original Message-----
> >From: Frank Fock [mailto:fock at agentpp.com]
> >Sent: Wednesday, October 19, 2005 4:04 PM
> >To: Scott VanWart
> >Cc: snmp4j at agentpp.org
> >Subject: Re: [SNMP4J] SNMP4J V3 perfromance
> >
> >Scott,
> >
> >You are sending SNMP requests while you are handling a trap event.
> >While your are waiting for the response of your request, you are not
> >able
> >to handle any traps. I recommend therefore either sending an async
> >request
> >or using the MultiThreadedMessageDispatcherImpl as message disptacher.
> >
> >Best regards,
> >Frank
> >
> >Scott VanWart wrote:
> >
> >
> >
> >>Frank,
> >>
> >>Is this the correct way to set the UDP Buffer size? And what number is
> >>reasonable to handle roughly 600-1000 events per second? Should it be
> >>400 X 1000 ?
> >>
> >>When you say decouple trap handling, I am not certain what you mean?
> >>
> >>Something like this?
> >>
> >>MessageDispatcher md = e.getMessageDispatcher();
> >>
> >>md.returnResponsePdu(e.getMessageProcessingModel(),e.getSecurityModel(
>)
> >>
> >>
> >,
> >
> >
> >>e.getSecurityName(), e.getSecurityLevel(), command,
> >>e.getMaxSizeResponsePDU(), e.getStateReference(), null);
> >>
> >>
> >>Thanks!
> >>Scott
> >>
> >>-----Original Message-----
> >>From: Frank Fock [mailto:fock at agentpp.com]
> >>Sent: Wednesday, October 19, 2005 3:38 PM
> >>To: Scott VanWart
> >>Cc: snmp4j at agentpp.org
> >>Subject: Re: [SNMP4J] SNMP4J V3 perfromance
> >>
> >>Hi Scott,
> >>
> >>You may check your UDP buffer size and you should probably decouple
> >>trap handling with sending out a synchronous request.
> >>
> >>Best regards,
> >>Frank
> >>
> >>Scott VanWart wrote:
> >>
> >>
> >>
> >>
> >>
> >>>Hey Guys,
> >>>
> >>>
> >>>
> >>>I am having problems with performance using SNMP4J. I have verified
> >>>
> >>>
> >>>
> >>>
> >>that
> >>
> >>
> >>
> >>
> >>>the device I am working with it sending more than 1 trap (inform) per
> >>>second, but all I seem to be able to receive is one event per second.
> >>>Here is my code, does anything jump out? Is there something I need to
> >>>set? Thanks!
> >>>
> >>>
> >>>
> >>>Thanks!
> >>>
> >>>Scott
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>try
> >>>
> >>>{
> >>>
> >>>command = e.getPDU();
> >>>
> >>> Address source = e.getPeerAddress();
> >>>
> >>> e.setProcessed(true);
> >>>
> >>>
> >>>
> >>> if (e.getMessageProcessingModel() ==
> >>>MessageProcessingModel.MPv3)
> >>>
> >>> {
> >>>
> >>> // send response.
> >>>
> >>> UserTarget target = new UserTarget();
> >>>
> >>> target.setAddress(source);
> >>>
> >>> target.setVersion(SnmpConstants.version3);
> >>>
> >>> target.setSecurityName(new OctetString(user));
> >>>
> >>>
> >>>target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
> >>>
> >>>
> >>>
> >>> snmp.getBulk(command, target);
> >>>
> >>> }
> >>>
> >>>
> >>>
> >>> VariableBinding varBinding;
> >>>
> >>> Variable var;
> >>>
> >>>
> >>>
> >>> // discover how many variables exist
> >>>
> >>> int length = command.size();
> >>>
> >>>
> >>>
> >>> // loop through variables and put them ALL into payload.
> >>>
> >>> for(int i = 0; i < length; i++)
> >>>
> >>> {
> >>>
> >>> varBinding = command.get(i);
> >>>
> >>> var = varBinding.getVariable();
> >>>
> >>> payload += var.toString() + "\t";
> >>>
> >>> }
> >>>
> >>>
> >>>
> >>> // Get source address of Trap.
> >>>
> >>> String test = source.toString();
> >>>
> >>> int colon = test.indexOf('/');
> >>>
> >>> src = test.substring(0, colon);
> >>>
> >>>
> >>>
> >>> }
> >>>
> >>>catch (Exception pe)
> >>>
> >>> {
> >>>
> >>> logger.error("Could not decrypt SNMP data:",
> >>>pe);
> >>>
> >>> }
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>_______________________________________________
> >>>SNMP4J mailing list
> >>>SNMP4J at agentpp.org
> >>>http://lists.agentpp.org/mailman/listinfo/snmp4j
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
>
>
>--
>AGENT++
>http://www.agentpp.com
>http://www.mibexplorer.com
>http://www.mibdesigner.com
>
>
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://lists.agentpp.org/mailman/listinfo/snmp4j
-Deon
_____________________________________________________
TruTeq Wireless (Pty) Ltd. | Tel: +27 (0)12 667 1530
http://www.truteq.co.za | Fax: +27 (0)12 667 1531
Wireless communications for remote machine management
More information about the SNMP4J
mailing list