This is an open-source implementation of the SNMP protocol as a Java package. It provides support for basic SNMP client and agent operations as defined in SNMP versions 1 and 2 (excluding the security model proposed as part of SNMP version 2, which was never widely accept or deployed). The package provides a mechanism for “getting and setting” SNMP object identifier (OID) values through a simple communication interface, and represents SNMP structures and datatypes as corresponding Java objects. The package has been used to provide SNMP communication capabilities for the Apple Airport Configurator and SNMP Inquisitor applications.
- Version 1.1 adds support for SNMP Trap generation and reception.
- Version 1.2 provides separate classes for trap generation and monitoring, and a method for retrieving table data
- Version 1.3 adds SNMP agent functionality, and methods for setting and retrieving multiple OID values in a single PDU
- Version 1.4 improves error handling and reporting functionality, adds support for SNMPv2 Traps and Inform Requests, and includes Ant and GNU Make build scripts
The source distribution contains the Java source files for the package, as well as the source code for four sample applications which utilize the package, a simple example application that illustrates basic use of the package, a simple GUI agent application that listens for and responds to get- and set-requests, a simple GUI trap application that listens for and generates traps, and the source for the SNMP Inquisitor, a utility for querying SNMP-enabled devices.
JavaDoc documentation for the classes in the package:
Introduction and short tutorial:
- Added communityName parameter to processTrap methods of SNMPv1TrapListener and SNMPv2TrapListener classes, so listeners can accept or reject traps based on community name (thanks to Kim Le)
- Replaced SNMPInteger values in Get and GetNext requests with SNMP Nulls
- Changed SNMP TimeTicks in trap sender timestamp to 1/100ths of second rather than 1/1000ths
- Restricted SNMPTimeTicks to be 32-bit quantity (rather than arbitrarily large, which caused problems with some receivers)
- Added PrintWriter for error reporting in AgentListener and TrapListener interfaces so error reporting can be directed as desired (rather than always to System.out)
- Changed internal representation of SNMPObjectIdentifier to array of longs to accept OID components up to 2^32 – 1 (thanks to Norman Elton)
- Changed toString() methods to utilize StringBuffer internally, for efficiency (thanks to Philip Yarra)
- Added radix specification to SNMPInteger class toString() method
- Improved error handling:
- Messages and PDUs perform more detailed qualification of contents, reporting more specific errors (rather than passing on generic Java exception types)
- Agent Interface now catches and reports all exceptions
- Fixed bug in SNMPv1AgentInterface, in which handled OIDs checked by reference rather than by value (thanks to Roman Levandovsky)
- Added equals() and hashCode() methods to SNMP object subclasses for use in collections
- Added support for SNMPv2 traps and inform request messages. Note that as a result the 1.4 version of the package is not directly backward-compatible with the 1.3 version as all classes related to trap messages have been qualified to indicate whether the trap is a v1 or v2 trap. Thus applications which use traps will need to be changed to use the 1.4 version package; however, the changes should be simple textual substitutions, e.g., changing all references to SNMPTrapPDU to SNMPv1TrapPDU.
- Added build scripts for GNU Make and Apache Ant