SNMP GETBULK Problem: only records of parts can be obtained (for example, 59 records, but there are more than 100 records)

I would like to get the interface information for the snmp GETBULK router, but when I use it, only parts of the record are returned.

Code below:

public static void main(String[] args) throws IOException, InterruptedException { Snmp snmp = new Snmp(new DefaultUdpTransportMapping()); snmp.listen(); CommunityTarget target = new CommunityTarget(); target.setCommunity(new OctetString("public")); target.setVersion(SnmpConstants.version2c); target.setAddress(new UdpAddress("127.0.0.1/161")); target.setTimeout(3000); //3s target.setRetries(1); PDU pdu = new PDU(); pdu.setType(PDU.GETBULK); pdu.setMaxRepetitions(200); pdu.setNonRepeaters(0); pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.31.1.1.1.1"))); ResponseEvent responseEvent = snmp.send(pdu, target); PDU response = responseEvent.getResponse(); if (response == null) { System.out.println("TimeOut..."); } else { if (response.getErrorStatus() == PDU.noError) { Vector<? extends VariableBinding> vbs = response.getVariableBindings(); for (VariableBinding vb : vbs) { System.out.println(vb + " ," + vb.getVariable().getSyntaxString()); } } else { System.out.println("Error:" + response.getErrorStatusText()); } } } 

After completing this process, 59 records are returned, but if I use GETNEXT to retrieve them, about 197 records are returned.

Any ideas?

Hope someone can help me, thanks in advance.

+4
source share
1 answer

How big are your answers? Remember - getbulk response must correspond to one UDP packet. This is the absolute limit of 65535 bytes - or if you have MTU limits potentially equal to 1500 bytes.

+3
source

Source: https://habr.com/ru/post/1492042/


All Articles