[SNMP4J] Usm_Stats_Not_In_Time_Window problem in SNMP4j

Jigar Shah jigarshah5124 at yahoo.co.in
Wed Nov 17 06:46:42 CET 2010


Hi,

I know to reduceing time is not allowed. And SNMPv3 has no defined procedure to recover from such a situation.This is expected.

But Scenario is when both r in sync.

-> Manager has NE Engine boot count 5, Engine Time 250
    NE has its own Engine boot count 5, Engine Time 250

Now assume that I have reduced time from NE (Agent) side....

So now
-> Manager has NE Engine boot count 5, Engine Time 150
    NE has its own Engine boot count 5, Engine Time 10

Now when NE gets request from EMS(Mgr)side, NE will generate Report as EMS having more Engine time then NE(Diff is more then 150). And NE will send that report to EMS saying USMStatsNotInTimeWindow. 

As per my knowledge, this is the code where SNMP4j accepts all packet at Manager side:

Code :

public void run() {
      try {
        socket.setSoTimeout(getSocketTimeout());
        if (receiveBufferSize > 0) {
          socket.setReceiveBufferSize(Math.max(receiveBufferSize,
                                               maxInboundMessageSize));
        }
        if (logger.isDebugEnabled()) {
          logger.debug("UDP receive buffer size for socket " +
                       getAddress() + " is set to: " +
                       socket.getReceiveBufferSize());
        }
      }
      catch (SocketException ex) {
        logger.error(ex);
        setSocketTimeout(0);
      }
      while (!stop) {
        DatagramPacket packet = new DatagramPacket(buf, buf.length,
                                                   udpAddress.getInetAddress(),
                                                   udpAddress.getPort());
        try {
          try {
            socket.receive(packet);         
            logger.fatal("Receiving Packet on Local Address : " + socket.getLocalAddress());
            logger.fatal("Receiving Packet on Local Port : " + socket.getLocalPort());
          }
          catch (InterruptedIOException iiox) {
            if (iiox.bytesTransferred <= 0) {
              continue;
            }
          }
          
     //     if (logger.isDebugEnabled()) {
            logger.fatal("Received message from "+packet.getAddress()+"/"+
                         packet.getPort()+
                         " with length "+packet.getLength()+": "+
                         new OctetString(packet.getData(), 0,
                                         packet.getLength()).toHexString());
      //    }
          
          ByteBuffer bis;
          // If messages are processed asynchronously (i.e. multi-threaded)
          // then we have to copy the buffer's content here!
          if (isAsyncMsgProcessingSupported()) {
            byte[] bytes = new byte[packet.getLength()];
            System.arraycopy(packet.getData(), 0, bytes, 0, bytes.length);
            bis = ByteBuffer.wrap(bytes);
          }
          else {
            bis = ByteBuffer.wrap(packet.getData());
          }
          fireProcessMessage(new UdpAddress(packet.getAddress(),
                                            packet.getPort()), bis);
        }
        catch (SocketTimeoutException stex) {
          // ignore
        }
        catch (PortUnreachableException purex) {
          synchronized (DefaultUdpTransportMapping.this) {
            listener = null;
          }
          logger.error(purex);
          if (logger.isDebugEnabled()) {
            purex.printStackTrace();
          }
          if (SNMP4JSettings.isFowardRuntimeExceptions()) {
            throw new RuntimeException(purex);
          }
          break;
        }
        catch (SocketException soex) {
          if (!stop) {
            logger.error("Socket for transport mapping " + toString() +
                         " error: " + soex.getMessage(), soex);
          }
          stop = true;
        }
        catch (IOException iox) {
          logger.warn(iox);
          if (logger.isDebugEnabled()) {
            iox.printStackTrace();
          }
          if (SNMP4JSettings.isFowardRuntimeExceptions()) {
            throw new RuntimeException(iox);
          }
        }
      }
      synchronized (DefaultUdpTransportMapping.this) {
        listener = null;
        stop = true;
        DatagramSocket closingSocket = socket;
        if ((closingSocket != null) && (!closingSocket.isClosed())) {
          closingSocket.close();
        }
      }
      if (logger.isDebugEnabled()) {
        logger.debug("Worker task stopped:" + getClass().getName());
      }
    }

-> If this Report is thrown away at Manager side then can u pls tell me the class Name and Method name frm wer it throws away.







--- On Wed, 17/11/10, Jochen Katz <katz at agentpp.com> wrote:

From: Jochen Katz <katz at agentpp.com>
Subject: Re: [SNMP4J] Usm_Stats_Not_In_Time_Window problem in SNMP4j
To: snmp4j at agentpp.org
Date: Wednesday, 17 November, 2010, 2:14 AM

Hi,

> And second time means after both Mgr and Agent in sync, m reducing
> time of NESIM,

this is not allowed. Time information is only allowed to increase.
SNMPv3 has no defined procedure to recover from such a situation.

> So NESIM will send report saying
> usmStatsOutofTImeWindow after getting SET or GET request.

> I can see this report in Ethereal, but ReportHandler doesn't get
> invoke.

This report is too old and therefore considered INVALID and thrown away.
There is no handler to be called, as the report is not processed.
This is the expected behaviour.

> And One more thing I want to ask is if I dont override my own
> ReportHandler then default ReportHandler gets invoke on getting each
> Report from agent side to Mgr.

I don't understand this question, but maybe the following is an answer:
If you set your own report handler, the default report handler is not
called any more. So, you have to call the default handler from your
handler, if you need to.

Regards,
  Jochen
_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j





More information about the SNMP4J mailing list