The SNMP agent system consists of one Master Agent and optional Sub-agents.
The tool makes it easy to dynamically extend an SNMP agent in run-time. MIBs can be loaded and unloaded at any time. It is also easy to change the implementation of an MIB in run-time, without having to recompile the MIB. The MIB implementation is clearly separated from the agent.
To facilitate incremental MIB implementation, the tool can generate a prototype implementation for a whole MIB, or parts thereof. This allows different MIBs and management applications to be developed at the same time.
To implement an agent, the programmer writes instrumentation
functions for the variables and the tables in the MIBs that the
agent is going to support. A running prototype which handles
The toolkit provides the following:
The SNMP development toolkit works with all three versions of Standard Internet Management Framework; SNMPv1, SNMPv2 and SNMPv3. They all share the same basic structure and components. And they follow the same architecture.
The versions are defined in following RFCs
Over time, as the Framework has evolved from SNMPv1 , through SNMPv2, to SNMPv3 the definitions of each of these architectural components have become richer and more clearly defined, but the fundamental architecture has remained consistent.
The main features of SNMPv2 compared to SNMPv1 are:
The standard documents that define SNMPv2 are incomplete, in the sense that they do not specify how an SNMPv2 message looks like. The message format and security issues are left to a special Administrative Framework. One such framework is the Community-based SNMPv2 Framework (SNMPv2c), which uses the same message format and framework as SNMPv1. Other experimental frameworks as exist, e.g. SNMPv2u and SNMPv2*.
The SNMPv3 specifications take a modular approach to SNMP. All modules are separated from each other, and can be extended or replaced individually. Examples of modules are Message definition, Security and Access Control. The main features of SNMPv3 are:
All these specifications are commonly referred to as "SNMPv3", but it is actually only the Message module, which defines a new message format, and Security module, which takes care of encryption and authentication, that cannot be used with SNMPv1 or SNMPv2c. In this version of the agent toolkit, all the standard MIBs for agent configuration are used. This includes MIBs for definition of management targets for notifications. These MIBs are used regardless of which SNMP version the agent is configured to use.
The extensible agent in this toolkit understands the SNMPv1, SNMPv2c and SNMPv3. Recall that SNMP consists of two separate parts, the MIB definition language (SMI), and the protocol. On the protocol level, the agent can be configured to speak v1, v2c, v3 or any combination of them at the same time, i.e. a v1 request gets an v1 reply, a v2c request gets a v2c reply, and a v3 request gets a v3 reply. On the MIB level, the MIB compiler can compile both SMIv1 and SMIv2 MIBs. Once compiled, any of the formats can be loaded into the agent, regardless of which protocol version the agent is configured to use. This means that the agent translates from v2 notifications to v1 traps, and vice versa. For example, v2 MIBs can be loaded into an agent that speaks v1 only. The procedures for the translation between the two protocols are described in RFC 1908 and RFC 2089.
In order for an implementation to make full use of the enhanced SNMPv2 error codes, it is essential that the instrumentation functions always return SNMPv2 error codes, in case of error. These are translated into the corresponding SNMPv1 error codes by the agent, if necessary.
The translation from an SMIv1 MIB to an SNMPv2c or SNMPv3 reply
is always very straightforward, but the translation from a v2 MIB
to a v1 reply is somewhat more complicated. There is one data
type in SMIv2, called
The following steps are needed to get a running agent:
Write your MIB in SMI in a text file.
Write the instrumentation functions in Erlang and compile them.
Put their names in the association file.
Run the MIB together with the association file through the MIB compiler.
Configure the application (agent).
Start the application (agent).
Load the compiled MIB into the agent.
The figures in this section illustrate the steps involved in the development of an SNMP agent.
The compiler parses the SMI file and associates each table or
variable with an instrumentation function (see the figure
The binary output file produced by the compiler is read by the
agent at MIB load time (see the figure
The SNMP agent system consists of one Master Agent and optional sub-agents. The Master Agent can be seen as a special kind of sub-agent. It implements the core agent functionality, UDP packet processing, type checking, access control, trap distribution, and so on. From a user perspective, it is used as an ordinary sub-agent.
Sub-agents are only needed if your application requires special support for distribution from the SNMP toolkit. A sub-agent can also be used if the application requires a more complex set transaction scheme than is found in the master agent.
The following illustration shows how a system can look in runtime.
A typical operation could include the following steps:
The sequence of steps shown is probably more complex than normal, but it illustrates the amount of functionality which is available. The following points should be noted:
Most applications only need the Master Agent because an agent can have multiple MIBs loaded at the same time.
Since applications tend to be transient (they are dynamically loaded and unloaded), the management of these applications must be dynamic as well. For example, if we have an equipment MIB for a rack and different MIBs for boards, which can be installed in the rack, the MIB for a card should be loaded when the card is inserted, and unloaded when the card is removed.
In this agent system, there are two ways to dynamically install
management information. The most common way is to load an MIB into
an agent. The other way is to use a sub-agent, which is controlled
by the application and is able to register and unregister itself. A
sub-agent can register itself for managing a sub-tree (not to be mixed up
with
Compared to other SNMP agent packages, there is a significant difference in this way of using sub-agents. Other packages normally use sub-agents to load and unload MIBs in run-time. In Erlang, it is easy to load code in run-time and it is possible to load an MIB into an existing sub-agent. It is not necessary to create a new process for handling a new MIB.
Sub-agents are used for the following reasons:
Refer to the chapter
The communication protocol between sub-agents is the normal message passing which is used in distributed Erlang systems. This implies that sub-agent communication is very efficient compared to SMUX, DPI, AgentX, and similar protocols.
A context is a collection of management information accessible by an SNMP entity. An instance of a management object may exist in more than one context. An SNMP entity potentially has access to many contexts.
Each managed object can exist in many instances within a SNMP entity. To identify the instances, specified by an MIB module, a method to distinguish the actual instance by its 'scope' or context is used. Often the context is a physical or a logical device. It can include multiple devices, a subset of a single device or a subset of multiple devices, but the context is always defined as a subset of a single SNMP entity. To be able to identify a specific item of management information within an SNMP entity, the context, the object type and its instance must be used.
For example, the managed object type
In SNMPv1 and SNMPv2c, the community string in the message was used for (at least) three different purposes:
to identify the context
to provide authentication
to identify a set of trap targets
In SNMPv3, each of these usage areas has its own unique
mechanism. A context is identified by the name of the SNMP
entity,
There is a MIB, SNMP-COMMUNITY-MIB, which maps a community
string to a
For an agent, the
By default, the agent has no knowledge of any other contexts
than the default context,
There is a set of standard MIBs, which are used to control and configure an SNMP agent. All of these MIBs, with the exception of the optional SNMP-PROXY-MIB (which is only used for proxy agents), are implemented in this agent. Further, it is configurable which of these MIBs are actually loaded, and thus made visible to SNMP managers. For example, in a non-secure environment, it might be a good idea to not make MIBs that define access control visible. Note, the data the MIBs define is used internally in the agent, even if the MIBs not are loaded. This chapter describes these standard MIBs, and some aspects of their implementation.
Any SNMP agent must implement the
An SNMPv3 agent must implement the SNMP-FRAMEWORK-MIB and SNMP-MPD-MIB. These MIBs are loaded by default, if the agent is configured for SNMPv3. These MIBs can be loaded for other versions as well.
There are five other standard MIBs, which also may be loaded into the agent. These MIBs are:
SNMP-TARGET-MIB and SNMP-NOTIFICATION-MIB, which defines managed objects for configuration of management targets, i.e. receivers of notifications (traps and informs). These MIBs can be used with any SNMP version.
SNMP-VIEW-BASED-ACM-MIB, which defined managed objects for access control. This MIB can be used with any SNMP version.
SNMP-COMMUNITY-MIB, which defines managed objects for coexistence of SNMPv1 and SNMPv2c with SNMPv3. This MIB is only useful if SNMPv1 or SNMPv2c is used, possibly in combination with SNMPv3.
SNMP-USER-BASED-SM-MIB, which defines managed objects for authentication and privacy. This MIB is only useful with SNMPv3.
All of these MIBs should be loaded into the Master Agent. Once loaded, these MIBs are always available in all contexts.
The ASN.1 code, the Erlang source code, and the generated
The
-include_lib("snmp/include/SNMPv2-MIB.hrl").
The initial values for the managed objects defined in these
tables, are read at start-up from a set of configuration files.
These are described in
These MIBs contain the
If another implementation of any of these variables is needed,
e.g. to store the persistent variables in a Mnesia database,
an own implementation of the variables must be made. That MIB
will be compiled and loaded instead of the default MIB.
The new compiled MIB
must have the same name as the original MIB (i.e. STANDARD-MIB
or SNMPv2-MIB), and be located in the SNMP configuration
directory (see
One of these MIBs is always loaded. If only SNMPv1 is used, STANDARD-MIB is loaded, otherwise SNMPv2-MIB is loaded.
There are some new data types in SNMPv2 that are useful in
SNMPv1 as well. In the STANDARD-MIB, three data types are
defined,
The SNMP-FRAMEWORK-MIB and SNMP-MPD-MIB define additional read-only managed objects, which is used in the generic SNMP framework defined in RFC2271 and the generic message processing and dispatching module defined in RFC2272. They are generic in the sense that they are not tied to any specific SNMP version.
The objects in these MIBs are implemented in the modules
If SNMPv3 is used, these MIBs are loaded by default.
The SNMP-TARGET-MIB and SNMP-NOTIFICATION-MIB define managed objects for configuration of notification receivers. They are described in detail in RFC2273. Only a brief description is given here.
All tables in these MIBs have a column of type
These MIBs are not loaded by default.
An entry in the
An entry in the
An entry in the
Which SNMP version to use is implicitly defined by
specifying the Message Processing Model. This version of the
agent handles the models
Each row specifies which security model to use, along with security level and security parameters.
The SNMP-VIEW-BASED-ACM-MIB defines managed objects to control access to the the managed objects for the managers. The View Based Access Control Module (VACM) can be used with any SNMP version. However, if it is used with SNMPv1 or SNMPv2c, the SNMP-COMMUNITY-MIB defines additional objects to map community strings to VACM parameters.
All tables in this MIB have a column of type
This MIB is not loaded by default.
VACM is described in detail in RFC2275. Here is only a brief description given.
The basic concept is that of a MIB view. An MIB view is a subset of all the objects implemented by an agent. A manager has access to a certain MIB view, depending on which security parameters are used, in which context the request is made, and which type of request is made.
The following picture gives an overview of the mechanism to select an MIB view:
The
The
The
The
The MIB definition for the table looks as follows:
VacmViewTreeFamilyEntry ::= SEQUENCE { vacmViewTreeFamilyViewName SnmpAdminString, vacmViewTreeFamilySubtree OBJECT IDENTIFIER, vacmViewTreeFamilyMask OCTET STRING, vacmViewTreeFamilyType INTEGER, vacmViewTreeFamilyStorageType StorageType, vacmViewTreeFamilyStatus RowStatus } INDEX { vacmViewTreeFamilyViewName, vacmViewTreeFamilySubtree }
Each
An MIB view is a collection of included and excluded sub-trees. A sub-tree is identified by an OBJECT IDENTIFIER. A mask is associated with each sub-tree.
For each possible MIB object instance, the instance belongs to a sub-tree if:
Membership of an object instance in an MIB view is determined by the following algorithm:
If the OBJECT IDENTIFIER is longer than an OBJECT IDENTIFIER of an object type in the MIB, it refers to object instances. Because of this, it is possible to control whether or not particular rows in a table shall be visible.
The SNMP-COMMUNITY-MIB defines managed objects that is used for coexistence between SNMPv1 and SNMPv2c with SNMPv3. Specifically, it contains objects for mapping between community strings and version-independent SNMP message parameters. In addition, this MIB provides a mechanism for performing source address validation on incoming requests, and for selecting community strings based on target addresses for outgoing notifications.
All tables in this MIB have a column of type
This MIB is not loaded by default.
The SNMP-USER-BASED-SM-MIB defines managed objects that is used for the User-Based Security Model.
All tables in this MIB have a column of type
This MIB is not loaded by default.
The OTP-SNMPEA-MIB was used in earlier versions of the agent, before standard MIBs existed for access control, MIB views, and trap target specification. All objects in this MIB are now obsolete.
Notifications are defined in SMIv1 with the TRAP-TYPE macro in the definition of an MIB (see RFC1215). The corresponding macro in SMIv2 is NOTIFICATION-TYPE. When an application decides to send a notification, it calls one of the following functions:
snmpa:send_notification(Agent, Notification, Receiver
[, NotifyName, ContextName, Varbinds])
snmpa:send_trap(Agent, Notification, Community [, Receiver, Varbinds])
providing the registered name or process identifier of the agent where the MIB, which defines the notification is loaded and the symbolic name of the notification.
If the
If the
The
The function
The simplest way to send a notification is to call the function
If the caller of the function wants to know whether or not
acknowledgments are received for a certain notification
(provided it is sent as an inform), the
Sometimes it is not possible to retrieve the values for some
of the objects in the notification specification with a
get-operation. However, they are known when the
For example, to specify that
It is also possible to specify names and values for extra variables that should be sent in the notification, but were not defined in the notification specification.
The notification is sent to all management targets found in the tables. However, make sure that each manager has access to the variables in the notification. If a variable is outside a manager's MIB view, this manager will not receive the notification.
By definition, it is not possible to send objects with
ACCESS
It is possible to add notification filters to an agent. These filters will be called when a notification is to be sent. Their purpose is to allow modification, suppression or other type of actions.
A notification filter is a module implementing the
Unless otherwise specified, the order of the registered filters will be the order in which they are registered.
If a value for an object is not given to the
For a given notification, the variables, which are referred to in the notification specification, must be implemented by the agent that has the MIB loaded, or by some parent to this agent. If not, the application must provide values for the unknown variables. The application must also provide values for all elements in tables.
The sender is authoritative for messages containing payload which does not expect a response (for example SNMPv2-Trap, Response or Report PDU).
The receiver is authoritative for messages containing payload which expects a response (for example Get, GetNext, Get-Bulk, Set or Inform PDU).
The agent can both perform and respond to discovery.
The agent responds to discovery autonomously, without interaction by the user.
Initiating discovery towards a manager is done by calling the
Discovery can only be performed towards one manager at a time.