Introduction to SNMP Agent functions

Source: Internet
Author: User

Http://wenku.baidu.com/view/6a7903a9d1f34693daef3e9f.html

The location of the SNMP agent in the SNMP framework

1.1 SNMP is widely accepted and put into use by the industry standard, it uses the polling mechanism, it is easy for network administrators to retrieve any node information, modify, find fault, complete troubleshooting, capacity planning and report generation.

The structure of SNMP is divided into NMS and agent two parts (1.1.1), NMS (network Management station, currently commonly used network management platform Sunnetmanager and IBM NetView) to the agent to send a request, The agent is a process or task residing on the managed device, after receiving the request message from the NMS, decoding, analyzing, and then getting the value of the management variable from the relevant module, generating the response message, and encoding the return to the NMS. SNMP is an application-layer protocol that specifies how the NMS and the agent communicate management information.

There are now 3 versions of the 1.2 SNMP protocol.

SNMPV1 has 5 primitive primitives

L Get-request

L Set-request

L Get-next-request

L Get-reponse

L Trap

SNMPv2 added two primitives

L Get-bulk-request

L Inform-request

The SNMPv3 was mainly reinforced in safety.

1.3 In order to simplify agent (network management agent generally divided into two functional modules and a common Module MIB library) side of the development, SNMP rules only two operations get, set, the former is used to obtain management information from the managed device. The latter acts by setting the value of the variable to configure the managed device. Open port UDP Port162 UDP Port161 AGENT Response Trap

The management information is transmitted between the NMS and the agent by sending messages, and SNMPV1 requires only five messages: GET request message: Used to get the value of the specified management variable.

GetNext Request message: A value for successive acquisition of a set of management variables.

GetResponse message: Used to respond to a request, return a request value or error type, and so on.

Set request message: Used to set the specified management variable.

Trap message: Used to proactively send information to an NMS in an emergency situation by a managed device

GetResponse message: Used to respond to a request, return a request value or error type, and so on.

Set request message: Used to set the specified management variable.

Trap message: Used to proactively send information to an NMS in an emergency situation by a managed device

Second, the role and flow of SNMP agent

The SNMP agent plays a role in translation transfer between the network Management station and the relevant application module of the device. Specifically, there are two parts: one is to receive requests from the network management station, decode the message, verify that the community name is valid, search the MIB tree and call the corresponding Access function to notify the relevant module to do the corresponding operation, and according to the relevant modules sent back to the operation results of the construction of response messages, encoding and return to the network management station. The second is to provide active alarm to the network Management station function, initiated by the relevant module, in the agent structure trap message, and encoded sent.

The SNMP agent process is as follows (as an example of an agent based on the PSOs SNMP protocol stack):

Return 0 Other init snmpvar_init Bind Port 161 Create Socket Setup_mib Snmp_init () in other init to other interface modules (tcp_mib,ip_mib,ipx _mibetc.) To initialize. The primary is to allocate memory for the index of the corresponding table any function in the process fails, and this function returns 1

Figure 4:agent_body Process

In the agent_body process, the function process_received_snmp_packet () is the core. This function is provided by the PSOs protocol stack. The first decodes the message, and the decoding succeeds and the group name is verified. After validation is passed, the search for the MIB tree (MIB tree generation method is no longer described) finds the corresponding access function for invocation, and the corresponding module is notified in the Access function for processing. The Process_received_snmp_packet () constructs the message and encodes it based on the return result. There are four types of access functions: Test (), get (), Next (), set (), written by the developer, in fact, the very big piece of work that the SNMP agent develops is to write these access functions. The purpose of test () is to check whether the object instance that will get or set exists. If the test () check fails, the response message is directly constructed to indicate the type and location of the error and encode it. Otherwise, get () or set () is called. Next () is to check for the existence of the next instance of the object instance that will be getnext, and if the next () check fails, directly constructs a response message indicating the type and location of the error and encoding. Otherwise, get () or set () is called. The function of Get () is to get the value of the specified object instance. The function of set () is to set the value of the specified object instance.    

Start decoding successful community name Verification n y Success N y analysis package content, search in MIB tree for variable name corresponding node Switch PDU type does not make further processing return wait for next request message no further processing return wait for next request message case Gettest_pro C Success y n get_proc fill in error index ErrorStatus casegetnext next_proc success y N get_proc fill in error index ErrorStatus case SE T test_proc success y N set_proc fill in error index ErrorStatus will get value fill in Vorr Bind generate response PDU encoded return

Figure 5 Process_received_snmp_packet () process

Third, the SNMP agent and the relevant application module interface.

The various modules of the network management device, the actual data are stored in the relevant application module. Therefore, the access function needs to interface with other modules, notifies other modules to operate accordingly, and can get the result of the operation. There are several ways that an agent can interface with other application modules. Here's what we usually do: xxxx_ioctl (int cmd, char* arg), where cmd is the command word, indicating whether the type of operation is get or set, and it also indicates which column of the table is the list object. Arg is a pointer to a struct. The structure is divided into two parts, the first of which is the index of several columns in the table, and can uniquely determine which row of the action table. The second part is a C-language Union (Union), which holds the values to be set or retrieved.

Introduction to SNMP Agent functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.