SNMP GETBULK

 

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

M is the Max-Repetitions field of the request

 

R is the maximum of

Thus the total number of varbinds in the response message is (N + M x R).

 

Using High-Level API explains the usage of high-level API in performing the SNMP GETBULK operation.

 

Using Low-Level API 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.

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 <tutorials/highlevelapi/SnmpGetBulk.java>.

 

Using Low-Level API

 

Refer the topic SNMP GET Using Low-level API, which discusses the SNMP GET operation. The additional parameters for the SNMP GETBULK operations can be set using the following methods.

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 <tutorials/lowlevelapi/SnmpGetBulk.java>.



Copyright © 2012, ZOHO Corp. All Rights Reserved.