Search code examples
snmp

How to reply to an snmp request with an SNMP agent?


So my question is how does an SNMP agent retrieve the information after it has decoded the oid?

For example a simple snmp request would be snmp-get the oid being sent would be 1.3.6.1.2.1.1.1 which would translate to "so.org.dod.internet.mgmt.mib-2.system.sysDescr" , this would be a request for the full name and version identification of the system's hardware type, software operating-system, and networking software.

After knowing what it requires how does the SNMP agent compose a response ? Does it query something else? If it does query the system how does it query it ..


Solution

  • Your best bet is to read and understand the standard RFC 3411 titled

                     An Architecture for Describing
    Simple Network Management Protocol (SNMP) Management Frameworks
    

    in particular section 3.1.3.2 "SNMP Agent" which shows the architecture of the agent. You are asking about the box "MIB instrumentation", which is further detailed down in section 3.3 .

    That standard is then implemented differently in each SNMP framework, usually via callbacks for each of the registered MIB objects. You compile the MIB that you want to handle in the agent, and it generates the stubs for the callbacks, which you then fill out to retrieve the information for each object and return it in the desired format.