|
The SNMP transport provider is responsible for all communication between the SNMP manager and agent. It essentially acts as a bridge between the SNMP API and the actual transport protocol used. The advantage of using this approach is that the SNMP API need not be aware of the underlying protocol used and the user can virtually run SNMP over anything. For using a particular transport protocol, the user has to implement that protocol and plug-in (or register) it with the SNMP transport provider. Multiple protocols, such as TCP, UDP, and Serial communication can be used simultaneously in an application to communicate with various agents having SNMP over different protocols. The corresponding protocol providers are to be implemented by the user.
We have provided simple command-line examples that use the TCP/IP protocol over SNMP transport provider to perform basic operations, such as GET, SET, GETNEXT, GETBULK, TRAPS, INFORM, and WALK. Also command-line example has been provided that performs SNMP GET operation with UDP/IP and SNMP GETNEXT operation with TCP/IP protocol.
APIs used for plugging-in your protocol implementation
These interfaces are part of the com.adventnet.snmp.snmp2 package.
SnmpTransportProvider - This interface provides the basic I/O operations. It contains the following API methods. Refer the javadocs files for exact syntax.
open - Opens the transport interface over which the data is sent/received.
close - Closes the transport interface after communication is over.
read - Receives data from the peer over the transport interface.
write - Sends data to the peer over the transport interface.
ProtocolOptions - This interface defines some parameters that are to be implemented by the user. It contains the following API methods. Refer the javadocs files for exact syntax.
getSessionId - Returns a unique session ID for each SNMP session. This needs to be implemented only for SNMPv3 module.
SnmpTransportPacket - This class contains the details of the ProtocolOptions used by the SNMP API and the details of message sent or received. This contains the following API methods. Refer the javadocs files for exact syntax.
getProtocolOptions - Returns the transport parameters set on the transport packet for sending/receiving messages.
setProtocolOptions - Sets the protocol options on SnmpTransportPacket.
getProtocolData - Gets the SNMP message to be sent or received.
setProtocolData - Sets the protocol data on SnmpTransportPacket.
You can also implement your own transport provider. Refer Custom Transport Provider for more information.
|