Fields Summary |
---|
public static int | defaultSnmpRequestPktSizeThe default SNMP packet size of an SNMP request (2 * 1024).
The maximum size is initially set to Ethernet maximum transfer unit (MTU). |
public static int | defaultSnmpResponsePktSizeThe default SNMP packet size of an SNMP response (8 * 1024).
This will be the default size that the session socket uses when receiving a packet. |
private int | maxVarBindLimitThe maximum number of variable bindings that can be packed into a request.
The default value is 25. |
private int | portNumPort number of the destination host.
The default port is 161. |
private int | maxTriesNumber of times to try before giving up.
The default number is 3. |
private int | timeoutThe amount of time to wait for a response from the peer.
The default amount of time is 3000 millisec. |
private com.sun.jmx.snmp.SnmpPduFactory | pduFactoryThe PDU factory. The default factory is an instance of SnmpPduFactoryBER . |
private long | _maxrttThe maximum round trip time for a packet with the peer. |
private long | _minrttThe minimum round trip time for a packet with the peer. |
private long | _avgrttThe average round trip time for a packet with the peer. |
private SnmpParams | _snmpParameterSNMP parameters for this peer are valid for all requests using this peer. |
private InetAddress | _devAddrInternet address of the peer to be used when communicating with the peer. |
private int | maxSnmpPacketSizeMaximum packet size of the request PDU. This can be set by the user.
If the request crosses this limit while encoding, the request is automatically split
into multiple small request. Each of these requests will again be within this limit.
The default value is (2 * 1024). |
InetAddress[] | _devAddrListList of alternate addresses. |
int | _addrIndexThe index of address currently being used. |
private boolean | customPduFactory |
Methods Summary |
---|
public boolean | allowSnmpSets()Determines whether an SNMP set operation is allowed with this
peer object. For now it just makes sure a parameter is configured for a write operation.
return _snmpParameter.allowSnmpSets() ;
|
public boolean | equals(java.lang.Object obj)Compares the two peer objects to determine whether they are the same. This is used
to determine whether requests can be multiplexed.
if (this == obj)
return true ;
/*
if (obj instanceof SnmpPeer) {
SnmpPeer peer = (SnmpPeer) obj ;
if (_devAddr.equals(peer.getDestAddr()) &&
portNum == peer.getDestPort())
return true ;
}
*/
return false ;
|
public void | finalize()Finalizer of the SnmpPeer objects.
This method is called by the garbage collector on an object
when garbage collection determines that there are no more references to the object.
Sets all the references to this SNMP peer object to null .
_devAddr = null ;
_devAddrList = null ;
_snmpParameter = null ;
|
public long | getAvgRtt()Gets the average round trip time for a packet with the peer.
return _avgrtt ;
|
public final java.net.InetAddress | getDestAddr()Gets the InetAddress object for this peer.
return _devAddr ;
|
public final java.net.InetAddress[] | getDestAddrList()Gets the list of alternate InetAddress configured for this peer.
return _devAddrList;
|
public final int | getDestPort()Gets the destination port number of the peer to which SNMP requests are to be sent.
return portNum ;
|
public final java.lang.String | getDevName()Gets the name specified in the constructor while creating this object.
return getDestAddr().getHostName() ;
|
public long | getMaxRtt()Gets the maximum round trip time for a packet with the peer.
return _maxrtt ;
|
public final int | getMaxSnmpPktSize()Gets the maximum request packet size that is currently used.
return maxSnmpPacketSize ;
|
public final int | getMaxTries()Gets the number of times to try before giving up.
return maxTries;
|
public long | getMinRtt()Gets the minimum round trip time for a packet with the peer.
return _minrtt ;
|
public SnmpParams | getParams()Gets the SnmpParams object associated with the peer.
return _snmpParameter;
|
public final int | getTimeout()Gets the timeout to wait for a response from the peer.
return timeout;
|
public final synchronized int | getVarBindLimit()Gets the maximum number of variable bindings that can be sent to a peer.
return maxVarBindLimit ;
|
public final synchronized java.lang.String | ipAddressInUse()Returns the dot-formatted IP address string (for example 171.69.220.224).
Useful when you want to know which IP address is used
when the address was resolved using a DNS name.
byte [] adr = _devAddr.getAddress() ;
return
(adr[0]&0xFF) + "." + (adr[1]&0xFF) + "." +
(adr[2]&0xFF) + "." + (adr[3]&0xFF);
|
boolean | isCustomPduFactory()
return customPduFactory;
|
public final synchronized void | setDestPort(int newPort)Changes the port address of the destination for the request.
portNum = newPort ;
|
public final synchronized void | setMaxSnmpPktSize(int newsize)Configures the maximum packet size that can be used when generating an SNMP request.
maxSnmpPacketSize = newsize ;
|
public final synchronized void | setMaxTries(int newMaxTries)Changes the maximun number of times to try before giving up.
if (newMaxTries < 0)
throw new IllegalArgumentException();
maxTries= newMaxTries;
|
public void | setParams(SnmpParams params)Sets the SnmpParams object associated with the peer.
_snmpParameter = params;
|
public final synchronized void | setTimeout(int newTimeout)Changes the timeout to wait for a response from the peer.
if (newTimeout < 0)
throw new IllegalArgumentException();
timeout= newTimeout;
|
public final synchronized void | setVarBindLimit(int limit)Configures the maximum number of variable bindings that can be sent to a peer.
maxVarBindLimit = limit ;
|
public java.lang.String | toString()Returns the String representation for this SnmpPeer .
return "Peer/Port : " + getDevName() + "/" + getDestPort() ;
|
private void | updateRttStats(long tm)
if (_minrtt > tm)
_minrtt = tm ;
else if (_maxrtt < tm)
_maxrtt = tm ;
else
_avgrtt = tm ; // to do later.
|
public final synchronized void | useAddressList(java.net.InetAddress[] adrList)Specifies the list of addresses to be used. When a host is not responding
the user can switch to the next address by calling useNextAddress .
_devAddrList = adrList ;
_addrIndex = 0 ;
useNextAddress() ;
|
public final synchronized void | useIPAddress(java.lang.String ipaddr)Sets a specific IP address to which the peer will communicate.
Typically used to set an alternate IP address or a specific address which is known to respond to requests.
The IP address String can either be a machine name, such as ibiza ,
or a String representing its IP address, such as "206.26.48.100".
_devAddr = InetAddress.getByName(ipaddr) ;
|
public final synchronized void | useNextAddress()Causes all subsequent requests to go to the new address
obtained from the specified list of alternate addresses.
If it reaches the end of list, it starts again at the first address.
if (_devAddrList == null)
return ;
/* NPCTE fix for bug 4486059, esc 0 MR 03-August-2001 */
/* if (_addrIndex > _devAddrList.length) */
if (_addrIndex > _devAddrList.length-1)
/* end of NPCTE fix for bugid 4486059 */
_addrIndex = 0 ;
_devAddr = _devAddrList[_addrIndex++] ;
|