23.0 Plugging In Other Transport Protocols

 


23.1 Overview

23.2 APIs Used for Plugging In Your Protocol

23.3 Plugging the Protocol in SNMP Transport Provider Framework


 

23.1 Overview

 

SNMP standards define UDP to be used as the default protocol for communication. UDP, being a connectionless protocol, is most suitable for exchanging messages with smaller packet sizes and also where the Network Management System requires to do quick queries on a lot of devices.

 

When the packet sizes are large like in the case of database retrievals and updates, TCP might be the preferred protocol. You might also want to choose your own protocol for implementation such as IPX, HTTP, TCP, Serial port communication, etc. You can also implement SSL below the SNMP for secured communication.

 

To facilitate this, a new transport provider framework is provided, whereby you can plug in your own transport protocol. This enables you to implement the protocol of your choice for SNMP communication. The API implements UDP/IP as the default protocol implementation. Also,TCP/IP is provided as the reference implementation that uses the transport provider framework.

 

The transport provider is responsible for all communication between the SNMP Manager and Agent and uses the configured protocol to do so. So, it essentially acts as a bridge between the SNMP API and the actual (underlying) transport protocol used.

 

The advantage of using this approach is that the SNMP API need not be aware of the underlying protocol used and you can virtually run SNMP over anything. For using a particular protocol as the transport, you have to implement that protocol and plug in (or register) it with the SNMP transport provider. Two transport protocols can be registered with the provider at a time, i.e., you can use TCP and UDP protocols for communication at the same time.

 

We have provided a reference implementation of SnmpAgent on TCP/IP protocol over the SNMP transport provider.

 

23.2 APIs Used for Plugging In Your Protocol

 

These interfaces are a part of the com.adventnet.snmp.snmp2 package and are used for plugging your protocol.

 

SnmpTransportProvider

 

This interface provides the basic Input-Output (I/O) operations that can be expected by any transport protocol. It contains the following API methods (Please see the javadocs files for the exact syntax).

ProtocolOptions

 

This interface defines some parameters that have to be implemented by the user. It contains the following API method (Please see the javadocs files for the exact syntax) :

 

getSessionId(): Returns a unique sessionId for each SnmpSession. This is used by the SnmpV3module and need not be implemented by those using Snmp V1 and Snmp V2.

 

SnmpTransportPacket

 

This class contains the details of the ProtocolOptions, which is used by the SnmpAPI and the details of data, i.e., the SNMP message that is sent or received. This contains the following API methods (Please see the javadocs files for the exact syntax):

23.3 Plugging the Protocol in SNMP Transport Provider Framework

 

Provide implementation of SnmpTransportProvider for the protocol (default implementation class iscom.adventnet.snmp.snmp2.agent.AgentTcpTransportImpl ) - This class should provide the open(), close(), read(), and write() implementation required for TCP/IP communication. This can be used to set up the basic communication and transfer data between the SNMP entities.

 

The transport provider option can be enabled in the SnmpAgent by setting the protocol as SnmpAgent.TRANSPORT_PROVIDER . The code looks like this :

 

snmpagent.setProtocol(SnmpAgent.TRANSPORT_PROVIDER);

 

Similarly, to use the transport provider for SnmpTrapService, the code should look like this :

 

snmptrapservice.setProtocol(SnmpAgent.TRANSPORT_PROVIDER);

 

Provide implementation of ProtocolOptions  - This class should provide the necessary parameters needed for the protocol communication, e.g., the host, port, etc. in case of TCP/IP. In the case of V3 module, this class should contain the implementation for getSessionId(). This is used by the SNMP V3 module to uniquely identify each session connection between the SNMP entities. So, for TCP/IP, this can be a combination of the destination host and port.  The default implementation class used by the SnmpAgent class is com.adventnet.snmp.snmp2.agent.AgentTcpProtocolOptionsImpl. If you wish to have your own implementation of this protocol options, you need to override the method createProtocolOptions in SnmpAgent.

 

public ProtocolOptions

createProtocolOptions(String remoteHost, int

remotePort, int localPort)

{

return new MyProtocolOptions(remoteHost,

remotePort, localPort);

}

 

Similarly, for traps to be sent using the transport provider framework, the user needs to override the method createProtocolOptions in SnmpTrapService.

 

Provide a configuration file in the name snmpTransport.config, which contains the name of the implemented SnmpTransportProvider class file.

 

To avail the reference TCP implementation, change the implementation class name in snmpTransport.config in the <Agent Toolkit Home>/jars/AdventNetSnmp.jar file from com.adventnet.snmp.snmp2.TcpTransportImpl to com.adventnet.snmp.snmp2.agent.AgentTcpTransportImpl. 



Copyright © 2013, ZOHO Corp. All Rights Reserved.