分类:
2010-06-03 05:27:13
The GETBULK operation is normally used for retrieving large amount of data, particularly from large tables. A GETBULK request is made by giving an OID list along with a Max-Repetitions value and a Nonrepeaters value.
The GETBULK operation performs a continuous GETNEXT operation based on the Max-Repetitions value. The Nonrepeaters value determines the number of variables in the variable list for which a simple GETNEXT operation has to be done. For the remaining variables, the continuous GETNEXT operation is done based on the Max-Repetitions value.
In other words, the SNMP GETBULK operation does a simple GETNEXT operation for the first N variable bindings in the request and does M GETNEXT operation (continuous) for each of the remaining R variable bindings in the request list where
N is the minimum of
the value of the Non-Repeaters field in the request
the number of variable bindings in the request
M is the Max-Repetitions field of the request
R is the maximum of
the number of variable bindings in the request
zero
Thus the total number of varbinds in the response message is (N + M x R).
explains the usage of high-level API in performing the SNMP GETBULK operation.
explains the usage of low-level API in performing the SNMP GETBULK operation.
Using High-Level API
The additional parameters for the SNMP GETBULK operation can be set using the following methods.
setMaxRepetitions(int) - the default value is 50.
setNonRepeaters(int) - the default value is 0.
The snmpGetBulkList() method of the SnmpTarget Bean can be used for the SNMP GETBULK operation.
//instantiate the SnmpTarget SnmpTarget target = new Snmptarget(); //set the host in which the SNMP agent is running target.setTargetHost("localhost"); //set the OID target.setObjectID(".1.3.6.1.2.1.3.1"); //perform GETNEXT String result = target.snmpGetBulkList(); System.out.println("Response: "+result); |
View the complete example present in <>.
Using Low-Level API
Refer the topic , which discusses the SNMP GET operation. The additional parameters for the SNMP GETBULK operations can be set using the following methods.
setMaxRepetitions(int max_rep)
setNonRepeaters(int non_rep)
To perform an SNMP GETBULK operation, the command constant GETBULK_REQ_MSG defined in the SnmpAPI class is used.
//Build GET Request PDU SnmpPDU pdu = new SnmpPDU(); UDPProtocolOptions option = new UDPProtocolOptions("localhost"); session.setProtocolOptions(option); //sets the host in which the agent is running pdu.setCommand(SnmpAPI.GETBULK_REQ_MSG); pdu.setMaxRepetitions(10); pdu.setNonRepeaters(0); //Specify OID SnmpOID oid = new SnmpOID("1.3.1"); pdu.addNull(oid); |
The rest of the steps will remain the same as the SNMP GET operation. View the complete example present in <>.