[SNMP4J] SNMP4J behavior when DHCP MediaSense is disabled
BLANC Jérôme
jerome.blanc at infotel.com
Wed Oct 23 18:17:08 CEST 2013
Hi,
We have a problem with the SNMP4J time-out management when the SNMP server is not reachable.
Our environment is composed by:
- A distant SNMP server.
- A laptop that hosts the SNMP client.
On this laptop:
· the OS is Windows XP,
· the network interfaces are configured to be still available even when the laptop is no connected to the server (DHCP MediaSense disabled),
· no SNMP server has been installed.
The timeout is set to 1 second (refer to the code above).
We performed the following tests, in order to check the client behavior when no SNMP server is reachable:
1. When using a local IP address (127.0.0.1) for the server
ð the client took approximately 10 seconds to perform 4 successive SNMP requests.
2. When using the real IP address of the distant server
ð the request took approximately 50 seconds to perform 4 successive SNMP requests.
Can anybody explain us this difference of time ?
Here is the extract of the code:
// Create TransportMapping and Listen
TransportMapping transport = null;
Snmp snmp = null;
Hashtable<String, Variable> result = new Hashtable<String, Variable>();
try
{
transport = new DefaultUdpTransportMapping();
transport.listen();
// Create Target Address object
CommunityTarget comtarget = new CommunityTarget();
comtarget.setCommunity(new OctetString(aCommunity));
comtarget.setVersion(snmpVersion);
// aHostname = 127.0.0.1 on test1
// aHostname = 172.20.131.1 on test2
// port = 2161
comtarget.setAddress(new UdpAddress(aHostname + "/" + aPort));
comtarget.setRetries(0);
// timeout = 1000 ms
comtarget.setTimeout(timeout);
String oidString = "";
// Create the PDU object
PDU pdu = new PDU();
for (int i = 0; i < aOids.length; i++)
{
pdu.add(new VariableBinding(new OID(aOids[i])));
if (i > 0)
{
oidString = oidString + ", ";
}
oidString = oidString + aOids[i];
}
pdu.setType(PDU.GET);
pdu.setRequestID(new Integer32(1));
// Create Snmp object for sending data to Agent
snmp = new Snmp(transport);
ResponseEvent aresponse = snmp.get(pdu, comtarget);
if (aresponse != null)
{
System.out.println("Got Response from Agent : " + aresponse.toString());
}
else
{
System.out.println("No Response from Agent");
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (snmp != null)
{
try
{
snmp.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
Thank you in advance for your help.
Regards,
Jerome
More information about the SNMP4J
mailing list