The Advent SNMP Package is designed to enable writing object-oriented Java applets and Java applications that use SNMP to talk to managed nodes.
We can broadly divide this package into four categories. These are
Part of the SNMP communication classes is an SASClient class for enabling communication for applets on Java browsers that do not permit socket access to any host but the applet host. You will not need to use this class directly, but will be able to decide if it get's used through the open method in the SnmpSession class. The only method in SASclient you may need to use is the saveFile method, useful for saving applet data to a file on the Web Server.
The ancestor of all SNMP variable classes is an abstract class called SnmpVar. This class contains abstract methods for printing, ASN encoding, ASN decoding, etc., not all of whch are public, i.e. some of the abstract methods are used only by the other classes in the package.
The SnmpVar class has five direct sub-classes. They are:
The following are the SnmpString sub-classes.
SnmpUnsignedInt has the following sub-classes.
A variable binding is a combination of an Object Identifier and an SNMP variable that's commonly used in SNMP manager-agent interactions. The SnmpVarBind class is used for variables and methods needed for variable bindings. ASNTypes is a bunch of utility functions and constants, needed in encoding and decoding SNMP variables. You will not need to use this class in your applications.
The Advent SNMP package uses the SnmpAPI class to manage sessions created by the user application, manage the MIB modules that have been loaded, and store some key parameters for SNMP communication, e.g. SNMP ports to be used. An SNMPapplication (manager or agent) often needs to manage multiple sessions on account of interacting with multiple SNMP peers. The SnmpAPI class has a list of sessions attached to it and monitors each of the sessions for timeouts and retransmits via a separate thread. It enables a few methods across all sessions, e.g. checking if responses have come in on any of the sessions, etc. Multiple threads can work with a single SnmpAPI instance. You will need to instantiate and start the SnmpAPI class to use it.
The SnmpSession class is used to manage a session with an SNMP peer. You can talk to more than one host via a single session, but it makes sense to use separate sessions for hosts you talk to often in an application. Each session runs as a separate thread (primarily to do receive tasks) and provides functions to open sessions (on a particular local port if needed), synchronously or asynchronously send and receive SNMP requests, check for responses and timeouts, and close sessions. You will need to instantiate and open an SnmpSession instance to be able to use it to communicate with an SNMP peer.
The SnmpCallback class is used when an asynchronus response to a snmprequest is to be delivered to the user application from a separate thread other than the SnmpSession receiver thread. If the user sets the SnmpSession.CALLBACK_THREAD to true then the users callback method will be called from a separate thread when aresponse arrives. If the SnmpSesssion.CALLBACK_THREAD is set to false (default), then the callback method is called from the same thread as the receiver thread and subsequent responses can be received only if the user returns from the callback method. But calling from a separate thread, the performance of the receiver thread in receiving responses or traps is little bit poorer.
Interaction between the SNMP manager and the agent is via SNMP protocol data units, PDUs. The SnmpPDU class will be used to provide the variables and methods to create and use the SNMP PDU. The methods include adding null valued variable bindings and printing all variable bindings.
In order to get around the security restriction in browsers where socket access from the browser is not allowed, except to communicate with the applet host, we've added an SASClient class. This class does not need to be directly used. The open method in the SnmpSession class can be used to specify whether this class should be used to communicate with an SNMP peer.
In order to save applet data to a file for use later (for example to save user configuration for the next time the applet is started), the saveFile method in SASClient can be used. It saves the specified data to the specified file in the SASusers sub-directory on the applet host.
MIBmodules allow an SNMP managed agent to let users know about the structure and format of data available on the agent. The MIB modules are usually specified in a MIB module file, which needs to be parsed to understand the syntax and structure of the data available on the agent. The MibModule class provides a means to parse and use the data available in a MIB module file. Each MibModule instance is created from a MIB module file, and you can load and unload MIB modules by creating and deleting these instances. The instance contains all the nodes of the MIB tree as well as defined traps and textual conventions. A few utility methods and variables are provided, e.g. getNode() to search the module for a node matching a specified OID.
The MibModule class makes use of a number of other classes, some of which are useful for getting additional information on the MIB module, or specific nodes in the MIB. The MibMacro class is used to parse MIB macros, and only OBJECT-TYPE and TRAP-TYPE macros are supported. Any parsing of MIB modules would instantiate the macros for the module being parsed. The MibTrap class is used to keep data on trap types defined in a module.
The MibNode class represents a node in the parsed MIB tree. A list of instances of this class is contained in a MibModule and represents the MIB tree. This class may also be contained in an SnmpOID instance. A number of attributes and methods in the MibNode class are provided to simplify development of applications using the MIB definitions.
The LeafSyntax class is used to represent any unique syntax, including textual conventions, that is defined in a MIB module. For example, INTEGER (SIZE(1..5)), would have it's own LeafSyntax class instance that represents this syntax. For leaf nodes in the MIB tree, the MibNode instance contains a LeafSyntax reference. Thus for a MIB leaf node you can use the LeafSyntax to determine if a value is within the allowed range, for example.
The following classes do not fall into the above categories, or apply across all categories.