Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SNMP getNext and walk - End of MIB!!! 1

Status
Not open for further replies.

stedju

Programmer
Nov 15, 2012
4
RS
Hi!

I am working on SNMPv1 for my device. I have a question about detecting end of MIB file. For example if I issue walk from manager and I get to the end of my objects list, how do I handle this situation? Do I set some error status field in the response and if so, what error status should I put in the response message so the manager will know that this is end of my objects list?

Some error codes include:
+-------------------+---------------------------------------------------------------------------+
| Error Status | |
+------------+------+ Description |
| Name | Code | |
+------------+------+---------------------------------------------------------------------------+
| noError | 0x00 | No error occurred. |
| tooBig | 0x01 | The response to your request was too big to fit into one response. |
| noSuchName | 0x02 | The OID in the request was not found.the OID doesn't exist. |
| badValue | 0x03 | A data type in the request did not match the data type in the SNMP agent. |
| readOnly | 0x04 | The SNMP manager attempted to set a read-only parameter. |
| genErr | 0x05 | General Error (some error other than the ones listed above). |
+------------+------+---------------------------------------------------------------------------+

Thanks!
 
You would return noError and EndOfMibView. rfc 1905 would have more details.

From net-snmp faq:
Why do I sometimes get "End of MIB" when walking a tree, and sometimes not?

This depends on which MIB modules are supported by the agent you are querying and exactly what you're asking for.
Note that a tree is walked by repeatedly asking for "the next entry" until all the values under that tree have been retrieved. However, the agent has no idea that this is what's happening - all it sees is a request for "the next entry after X".
If the object X happens to be the last entry in a sub-tree, the agent will provide the next object supported (as requested) even though this will be in a different subtree. It's up to the querying tool to recognise that this last result lies outside the area of interest, and simply discard it.
If the object X happens to be the last entry supported by the agent, it doesn't have another object to provide, so returns an "end of MIB" indication. The Net-SNMP tools report this with the message above.
But in either case, the actual information provided will be the same.
 
Thank you for your post! I have found this RFC as well but it's for SNMPv2 (Protocol Operations for Version 2) and here it's clear to me how to do it, but what if I have SNMPv1 where I don't have this EndOfMibView and I have only this ones:
noError(0), tooBig(1), noSuchName(2), badValue(3), readOnly(4), genErr(5).

Should I generate Error (not likely) or should I have some logic to send something like this: For the last get-next request I will put the same OID in the response PDU and NULL for the value?
Last two requests that I got in Wireshark when I issue a command snmpwalk on tree looks like this: There you can see that in the last get-next-request I got the same OID in get-response as in the get-next-request, but value is now NULL and not 1 as it was in the request before last one...

20481 4.792634 127.0.0.1 127.0.0.1 SNMP get-next-request 1.3.6.1.6.3.16.1.5.2.1.6.6.95.110.111.110.101.95.1.1
20482 4.792753 127.0.0.1 127.0.0.1 SNMP get-response 1.3.6.1.6.3.16.1.5.2.1.6.6.95.110.111.110.101.95.1.2 value = (integer) 1
20483 4.792845 127.0.0.1 127.0.0.1 SNMP get-next-request 1.3.6.1.6.3.16.1.5.2.1.6.6.95.110.111.110.101.95.1.2
20484 4.792947 127.0.0.1 127.0.0.1 SNMP get-response 1.3.6.1.6.3.16.1.5.2.1.6.6.95.110.111.110.101.95.1.2 value = NULL

Is this maybe a solution for my SNMPv1?

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top