[SNMP4J] pdu size

Tjip Pasma tjip.pasma at ericsson.com
Tue Jun 3 15:40:54 CEST 2008


Hi

During system test of my snmp manager implementation i ran into a
problem with the pdu size. My application creates a snmp get request
containing 55 get's resulting in a packet length of 2000+ bytes. 
I've been using the
"target.setMaxSizeRequestPDU(SnmpConstants.MIN_PDU_LENGTH);" setting and
thus expected that pdu packets never excedded this value. But now that
i've investigated my problem, i see that the max-size value only is used
by TableUtils.

At the moment I'm assuming that i need to make something like the code
snippet below to solve my problem. Is there a simpler solution than this
? 
Somehow i expected that this would be handled by snmp4j since it it is
possible to configure max size. Maybe at least an exception should be
thrown id a pdu is exceeding the configured size ?

Kind Regards
Tjip Pasma
System Engineer - Ericsson Diax

Code snippet:
------------------------------------------------------------

Vector<PDU> pduList = new Vector<PDU>();
PDU pdu = createPDU();
pduList.add(pdu);
                        
for (int i = 0; i < params.size(); i++)
{
	VariableBinding vb = new VariableBinding(new
OID(params.getParams(i).getParamIdAndInstance()));
	pdu.add(vb);
	if (pdu.getBERLength() > target.getMaxSizeRequestPDU()) 
	{
		pdu.trim(); //removes previous added vb
                                
		pdu = m_snmpInfo.createPDU(); //create new pdu
		pduList.add(pdu);
		pdu.add(vb);
	}
}

for (int n = 0; n < pduList.size(); n++)
{
	m_snmp.get(pdu, target, r.getSyncObject(n), r); // using
asyncroneous calls
}


------------------------------------------------------------



More information about the SNMP4J mailing list