Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

SNMP4J

No description
by

RajashekarReddy Ereddy

on 27 May 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of SNMP4J

The Snmp class is transport protocol independent.

Support for a specific TransportMapping instance is added by calling the addTransportMapping(TransportMapping transportMapping) method or creating a Snmp instance by using the non-default constructor with the corresponding transport mapping.

Transport mappings are used for incoming and outgoing messages.


About Snmp Class
Snmp() : Creates a Snmp instance that uses a MessageDispatcherImpl with no message processing models and no security protocols (by default).
Snmp(MessageDispatcher messageDispatcher): Creates a Snmp instance by supplying a MessageDispatcher.
Snmp(MessageDispatcher messageDispatcher, TransportMapping transportMapping) : Creates a Snmp instance by supplying a MessageDispatcher and a TransportMapping.
Snmp(TransportMapping transportMapping): Creates a Snmp instance that uses a MessageDispatcherImpl with all supported message processing models and the default security protols for dispatching.
Snmp Constructors
Trap Method
ResponseEvent get(PDU pdu, Target target)
Sends a GET request to a target.
Snmp get Methods
SNMP4J
Java API for SNMP
pdu - a PDU instance. For SNMPv3 messages, the supplied PDU instance has to be a ScopedPDU instance.
Parameters used in Snmp get methods
Inform method
public ResponseEvent inform(PDU pdu,Target target) throws IOException
Notify Method
java.lang.Object
super class of all classes in java
AbstractTarget
MessageDispatcherImpl
The MessageDispatcherImpl decodes and dispatches incoming messages using MessageProcessingModel instances and encodes and sends outgoing messages using an appropriate TransportMapping(defines how the management protocol [RFC3416] may be carried over a variety of protocol suites) instances
PDU
The PDU class represents a SNMP protocol data unit. The PDU version supported by the BER decoding and encoding methods of this class is v2
Snmp
The Snmp class is the core of SNMP4J. It provides functions to send and receive SNMP PDUs. All SNMP PDU types can be send. Confirmed PDUs can be sent synchronously and asynchronously.
DefaultTimeoutModel
The DefaultTimeoutModel implements a timeout model that uses constant timeouts between retries
org.snmp4j package
A AbstratTarget class is an abstract representation of a remote SNMP entity. It represents a target with an Address object, as well protocol parameters such as retransmission and timeout policy.
(implements org.snmp4j.MessageDispatcher)
(implements org.snmp4j.asn1.BERSerializable, java.io.Serializable)
(implements org.snmp4j.CommandResponder, org.snmp4j.Session)
(implements org.snmp4j.Target)
CommunityTarget
A CommunityTarget represents SNMP target properties for community based message processing models (SNMPv1 and SNMPv2c).
SecureTarget
The SecureTarget is an security model independent abstract class for all targets supporting secure SNMP communication.
It has two subclasses UserTarget and CertifiedTarget
(extends AbstractTarget)
(implements java.io.Serializable)
(implements org.snmp4j.TimeoutModel)
void get(PDU pdu, Target target, Object userHandle, ResponseListener listener)
Asynchronously sends a GET request PDU to the given target.The response is then returned by calling the supplied ResponseListener instance.
We have getBulk and getNext with similar signature for synchronous and asynchronous.
get, getBulk and getNext method set pdu.type to PDU.GET, PDU.GETBULK and PDU.GETNEXT correspondingly
Target - the Target instance representing the target SNMP engine where to send the pdu.
listener - a ResponseListener instance that is called when pdu is a confirmed PDU and the request is either answered or timed out
userHandle - an user defined handle that is returned when the request is returned via the listener object.
Other Important Methods
Sends an INFORM request to a target. This method sets the PDU's type to PDU.INFORM and then sends a synchronous request to the supplied target. This method is a convenience wrapper for the send(PDU pdu, Target target) method.
public ResponseEvent inform(PDU pdu, Target target, Object userHandle,ResponseListener listener)) throws IOException
Asynchronously sends an INFORM request PDU to the given target. The response is then returned by calling the supplied ResponseListener instance.
public void trap(PDUv1 pdu, Target target) throws IOException
Sends a SNMPv1 trap to a target. This method sets the PDU's type to PDU.V1TRAP and then sends it to the supplied target. This method is a convenience wrapper for the send(PDU pdu, Target target) method.

Parameters:
pdu - a PDUv1 instance.
target - the Target instance representing the target SNMP engine where to send the pdu. The selected SNMP protocol version for the target must be SnmpConstants.version1.
public void notify(PDU pdu, Target target) throws IOException
Sends a SNMPv2c or SNMPv3 notification to a target. This method sets the PDU's type to PDU.NOTIFICATION and then sends it to the supplied target. This method is a convenience wrapper for the send(PDU pdu, Target target) method.
Parameters:
pdu - a PDUv1 instance.
target - the Target instance representing the target SNMP engine where to send the pdu. The selected SNMP protocol version for the target must be SnmpConstants.version2c or SnmpConstants.version2c.

Throws:
IOException - if the notification cannot be sent.
Other Important Methods in Snmp:
public ResponseEvent set(PDU pdu, Target target) throws IOException
Sends a SET request to a target. This method sets the PDU's type to PDU.SET and then sends a synchronous request to the supplied target.
Asychronous method has two more attributes UserHandle and ResponseListener
public ResponseEvent send(PDU pdu, Target target) throws IOException
Sends a PDU to the given target and returns the received response PDU.
There are other versions of send using TransportMapping that defines how the management protocol [RFC3416] may be carried over a variety of protocol suites
public void cancel(PDU request, ResponseListener listener)
Cancels an asynchronous request. Any asynchronous request must be canceled when the supplied response listener is being called, even if the ResponseEvent indicates an error.
setLocalEngine:
Sets the local engine ID for the SNMP entity represented by this Snmp instance
getLocalEngineID:
Gets the local engine ID if the MPv3 is available, otherwise a runtime exception is thrown.
(The MPv3 is the message processing model for SNMPv3.)
setTimeoutModel:
Sets the timeout model for this SNMP session. The default timeout model sends retries whenever the time specified by the timeout parameter of the target has elapsed without a response being received for the request. By specifying a different timeout model this behaviour can be changed.
getTimeoutModel:
Gets the timeout model associated with this SNMP session.
Thank You
Other Methods
initMessageDispatcher(), getMessageDispatcher(), addTransportMapping(TransportMapping), removeTransportMapping(TransportMapping), listen()
close(): closes the current SNMP session and frees allocated resources like sockets and threads
listen(): all transport mappings are put into listen mode
addNotificationListener(),removeNotificationListener()
Full transcript