Overview | Package | Class | Tree | Deprecated | Index | Help
| SNMP Stack 5_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uk.co.westhawk.snmp.stack
Class TimeWindow

    java.lang.Object
      |
      +--uk.co.westhawk.snmp.stack.TimeWindow

public class TimeWindow
extends java.lang.Object

TimeWindow contains the lookup tables for the engine Id information. TimeWindow should be created only once. Use the `getCurrent()` method to access any other method, i.e.

     if (TimeWindow.getCurrent() == null)
     {
         TimeWindow timew = new TimeWindow();
     }
     boolean known = TimeWindow.getCurrent().isSnmpEngineIdKnown(hostaddr, port);

This class contains two lookup tables. One that maps the host address+port onto the SNMP engine ID and one that keeps the SNMP engine ID with the timeline details about this engine.

Version:
  $Revision: 3.13 $ $Date: 2006/02/09 14:30:19 $
Author:
  Birgit Arkesteijn
See Also:
  `getCurrent()`

Field Summary
`static int` | `MaxTimeDifference` The maximum number of seconds the engine time in the PDU is allowed to differ from my estimated engine time.

Constructor Summary
`TimeWindow()` Constructor.

Method Summary
`static TimeWindow` | `getCurrent()` Returns the current reference to this class.
`protected java.lang.String` | `getKey(java.lang.String hostaddr, int port)` Returns the key to the engine ID lookup table, based on the specified host address and port.
`java.lang.String` | `getSnmpEngineId(java.lang.String hostaddr, int port)` Returns the snmp engine ID.
`protected uk.co.westhawk.snmp.stack.TimeWindowNode` | `getTimeLine(java.lang.String snmpEngineId)` Returns the timeline details of the snmp engine ID.
`boolean` | `isEngineIdOK(java.lang.String hostaddr, int port, java.lang.String snmpEngineId)` Checks if the engine ID is OK.
`boolean` | `isOutsideTimeWindow(java.lang.String snmpEngineId, int bootsA, int timeA)` Returns if the time details are outside the time window.
`boolean` | `isSnmpEngineIdKnown(java.lang.String hostaddr, int port)` Returns if the snmp engine ID is known.
`boolean` | `isTimeLineKnown(java.lang.String snmpEngineId)` Returns if the timeline details of this snmp engine ID are known.
`void` | `setSnmpEngineId(java.lang.String hostaddr, int port, java.lang.String snmpEngineId)` Sets the SNMP engine ID that belongs to the specified hostaddr and port.
`protected uk.co.westhawk.snmp.stack.TimeWindowNode` | `setTimeLine(java.lang.String snmpEngineId, uk.co.westhawk.snmp.stack.TimeWindowNode newNode)` Sets the timeline details of the snmp engine ID.
`java.lang.String` | `toString()` Returns the string representation.
`boolean` | `updateTimeWindow(java.lang.String snmpEngineId, int bootsA, int timeA, boolean isAuthentic)` Tries to update the time window and returns if succeeded.
`protected void` | `updateTimeWindows()` Updates the estimated engine time of all gathered time details.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### MaxTimeDifference

    public static final int MaxTimeDifference

  The maximum number of seconds the engine time in the PDU is allowed to differ from my estimated engine time. Values `150`.

  See Also:
    Constant Field Values

Constructor Detail

### TimeWindow

    public TimeWindow()

  Constructor.

Method Detail

### getCurrent

    public static TimeWindow getCurrent()

  Returns the current reference to this class. TimeWindow should be created only once. Use this method to access any other method, i.e.

       if (TimeWindow.getCurrent() == null)
       {
           TimeWindow timew = new TimeWindow();
       }
       boolean known = TimeWindow.getCurrent().isSnmpEngineIdKnown(hostaddr, port);

  Returns:
    the current time window

### getSnmpEngineId

    public java.lang.String getSnmpEngineId(java.lang.String hostaddr,
                                            int port)

  Returns the snmp engine ID. This method will lookup the engine ID based on the host address and port. If it the engine ID is not known, null will be returned.

  Parameters:
    `hostaddr` - The host address of the engine ID
    `port` - The port number of the engine ID
  Returns:
    the snmp engine ID
  See Also:
    `isSnmpEngineIdKnown(String, int)`

### isSnmpEngineIdKnown

    public boolean isSnmpEngineIdKnown(java.lang.String hostaddr,
                                       int port)

  Returns if the snmp engine ID is known. This method will lookup if the engine ID belonging to this hostaddr and port is known.

  When the SNMP engine ID is known, this doesn't necessarily mean that the timeline details of this engine ID are known, since it takes a second discovery step to find out.

  Parameters:
    `hostaddr` - The host address of the engine ID
    `port` - The port number of the engine ID
  Returns:
    whether the snmp engine ID is known

### setSnmpEngineId

    public void setSnmpEngineId(java.lang.String hostaddr,
                                int port,
                                java.lang.String snmpEngineId)

  Sets the SNMP engine ID that belongs to the specified hostaddr and port. The old SNMP engine ID (if any) will be overwritten.

  Parameters:
    `hostaddr` - The host address of the engine ID
    `port` - The port number of the engine ID
    `snmpEngineId` - The engine ID

### isEngineIdOK

    public boolean isEngineIdOK(java.lang.String hostaddr,
                                int port,
                                java.lang.String snmpEngineId)

  Checks if the engine ID is OK. If there is no engine ID known for this hostaddr and port, the specified engine ID is added to the table.

  If there is already an engine ID for this hostaddr and port, the method returns true if the specified engine ID is the same as the existing one, and false if they differ. In the latter case the engine ID in the table is not updated.

  Parameters:
    `hostaddr` - The host address of the engine ID
    `port` - The port number of the engine ID
    `snmpEngineId` - The engine ID
  Returns:
    whether the engine ID matches the stored engine ID
  See Also:
    `setSnmpEngineId(String, int, String)`

### isTimeLineKnown

    public boolean isTimeLineKnown(java.lang.String snmpEngineId)

  Returns if the timeline details of this snmp engine ID are known.

  Parameters:
    `snmpEngineId` - The engine ID
  Returns:
    whether the timeline details are known

### isOutsideTimeWindow

    public boolean isOutsideTimeWindow(java.lang.String snmpEngineId,
                                       int bootsA,
                                       int timeA)

  Returns if the time details are outside the time window. When a response or report is received, the stack first checks the time window before updating it. It always does an update afterwards, even if the message was outside the time window!

  Parameters:
    `snmpEngineId` - The SNMP engine ID
    `bootsA` - The SNMP engine boots
    `timeA` - The SNMP engine time
  Returns:
    true if outside or when no details can be found, false if inside time window
  See Also:
    `updateTimeWindow(String, int, int, boolean)`

### updateTimeWindow

    public boolean updateTimeWindow(java.lang.String snmpEngineId,
                                    int bootsA,
                                    int timeA,
                                    boolean isAuthentic)

  Tries to update the time window and returns if succeeded. When a response or report is received, first check the time window before updating it.

  An update will only occur if the message was authentic and the bootsA and timeA meet the requirements. New data will be inserted if the (bootsA>0), irrespectively whether the message was authentic or not.

  Parameters:
    `snmpEngineId` - The SNMP engine ID
    `bootsA` - The SNMP engine boots
    `timeA` - The SNMP engine time
  Returns:
    true if update succeeded, or false when not succeeded or when no details could be found.
  See Also:
    `isOutsideTimeWindow(String, int, int)`

### updateTimeWindows

    protected void updateTimeWindows()

  Updates the estimated engine time of all gathered time details. It calculates the seconds that passed since the last call and updates all time window nodes accordingly.

  See Also:
    `setTimeLine(String, TimeWindowNode)`, `getTimeLine(String)`

### getKey

    protected java.lang.String getKey(java.lang.String hostaddr,
                                      int port)

  Returns the key to the engine ID lookup table, based on the specified host address and port.

  Parameters:
    `hostaddr` - The host address
    `port` - The port
  Returns:
    the key

### getTimeLine

    protected uk.co.westhawk.snmp.stack.TimeWindowNode getTimeLine(java.lang.String snmpEngineId)

  Returns the timeline details of the snmp engine ID. If there are no matching timeline details for this engine ID, null will be returned. The timeline details will be updated before the node is retrieved from the table.

  Parameters:
    `snmpEngineId` - The engine ID
  Returns:
    The timeline details
  See Also:
    `updateTimeWindows()`

### setTimeLine

    protected uk.co.westhawk.snmp.stack.TimeWindowNode setTimeLine(java.lang.String snmpEngineId,
                                                                   uk.co.westhawk.snmp.stack.TimeWindowNode newNode)

  Sets the timeline details of the snmp engine ID. The timeline details will be updated before the node is put in the table.

  Parameters:
    `snmpEngineId` - The engine ID
    `newNode` - The added time window node node
  Returns:
    The timeline details
  See Also:
    `updateTimeWindows()`

### toString

    public java.lang.String toString()

  Returns the string representation.

  Overrides:
    `toString` in class `java.lang.Object`
  Since:
    4_14

Overview | Package | Class | Tree | Deprecated | Index | Help
| SNMP Stack 5_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD