




已阅读5页,还剩35页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Contents0 Agent+ 总体说明: (1)Snmp+Snmp+是为网络管理应用程序开发者提供的具有SNMP服务的一套C+类的集合。它具有基于面向对象模型建立的SNMP应用程序接口,在最小化的范围内使用已经存在的SNMP库,保证了程序的高效和可移植性。对于使用TCP/IP协议的Internet来说,Snmp+封装了底层的Socket操作,提供了简单的API供开发者使用。(2)Agent+Agent+是在Snmp+的基础上,扩展了Snmp+中的概念,它是用来开发SNMP代理的一套C+类的集合。它继承了Snmp+的优点,封装了绝大部分的SNMP的标准操作,并且利用面向对象的特性,使开发者能够通过派生的子类,重载其中的虚函数,根据应用程序的需要灵活控制程序。 在Agent+类库,定义和实现了在SMI和MIB中的文本语法规定,如:Group,Table,TableEntry,Index等。主要的类与文本语法规定的对应关系如表1所示。SNMP 协议与 Agent +类 的表示的对应关系SNMP 协议Agent +类网关代理Mib用户MIBMibGroup TableMibTableTableEntryMibTableEntryInstanceMibleafSnmp 会话SnmpxPDUPdux变量绑定 VBVbx对象标志符(OID)Oidx按照功能划分,Agent+软件开发包由4个模块组成,如图3所示。通信模块消息处理模块操作定位模块MIB管理模块消息接收处理消息接收处理图3 Agent + 功能模块图通信模块负责接收和发送SNMP消息,它在指定端口(通常是161)接收到来的请求消息,并发送响应消息;在指定端口(通常是162)接收和发送陷阱、信息通知消息。同时,它还要给消息处理模块提供接收到消息、发送消息的工具函数。在Agent+中,属于通信模块的类主要有Snmpx、RequestList、Request等。消息处理模块负责解析输入的请求消息,进行安全验证。它对通信模块传来的SNMP消息进行解析,判断解析结果是否合法,同时,也要把解析出来的社团名(community)与规定的社团名进行比较验证。如果解析结果合法且社团名验证通过,才能进行下一步操作。在Agent+中,属于消息处理模块的类主要有Request等。操作定位模块负责根据消息处理模块解析的结果,在MIB库中查找管理对象。它按照消息中包含的管理对象的对象标志符(OID),查找需要访问的管理对象。在Agent+中,属于操作定位模块的类有Request、Mib、MibGroup、MibTable等。 MIB管理模块负责SNMP操作的具体实现。它按照操作类型(读或写),首先判断能否对管理对象进行操作,然后访问MIB库,按照要求读取数据或更新数据。在Agent+中,属于MIB管理模块的类有Request、MibTable、MibTableRow、Mibleaf等。 通信模块消息处理模块和操作定位模块对所有的MIB(包括私有的MIB)都是相同的,开发具体设备的代理时可以直接利用这些模块。MIB管理模块只提供了基本的操作,还需要根据具体的MIB文件,重新定制MIB管理模块。1Introduction 介绍Various Simple Network Management Protocol (SNMP) Application Programmers Interfaces (APIs) exist which allow the creation of network management applications. SNMP+ is such an API but in contrast to many others it offers the advantages of object oriented programming. An object oriented approach to SNMP network programming provides many benefits including ease of use, safety, portability and extensibility. The SNNP+ source code (C+) is freely available from the Hewlett Packard Company WWW server+ as long as their copyright notice is preserved. SNMP+ is designed to support the development of SNMP manager entities in the first place. AGENT+ extends the basic concepts of SNMP+ to support the development of SNMP agents and SNMP entities playing a dual role. Agent+ 扩展了 SNMP+ 的基本概念,支持 SNMP AGENT+ 和 SNMP 的双面角色。If you are looking for an introduction to SNMP and SNMP MIBs, I recommend Perkins97. 1Objectives of AGENT+Ease of UseAGENT+ has been designed to make the development of simple network management protocol agents simple. Using the AGENT+ API the programmer does not need to be concerned with details about SNMP protocol engine and dispatch table. The programmer can focus on implementing method routines and management instrumentation. The OO approach encapsulates and hides many internals like management of incoming SNMP requests, looking up mappings in the dispatch table, calling the appropriate method routines, sending responses and traps. Details concerning the simple network protocol itself are encapsulated by SNMP+ (see the SNMP+ specification for details). Rapidity of ImplementationThe AGENT+ API undertakes nearly any task of a SNMP agent implementation that can be generalised. Therefore the implementation of SNMP agents with AGENT+ saves a lot of time and money. The OO approach of AGENT+ supports the generalisation of the key tasks of a SNMP agent efficiently without making the API difficult to use. ExtensibilityExtensions to the AGENT+ API can be done in many ways. This includes supporting new versions of SNMP (e.g. version 3) and their administrative framework, base classes for additional types of managed objects, and adding new features. Through C+ class derivation, users of AGENT+ can inherit what they like and override what they wish to overload: A key concept of AGENT+ is the sub-classing of managed object base classes by the user. The user overrides virtual member functions of these base classes when she or he needs a specialisation to the default behaviour of the respective class member function.Portability/方便性AGENT+ offers a maximum of portability due to the use of pure C+ without any operating system specific calls. So its only portability limitation is SNMP+ which is available for many Unix derivates and Microsoft Windows. Nevertheless if you want to implement a multi-threaded SNMP agent AGENT+ is limited to POSIX threads compatible UNIX operating systems, e.g. Solaris, Digital Unix, and Linux. The public interface of the AGENT+ API remains the same across any platform. A programmer who codes to AGENT+ does not have to make changes to move it to another platform. Extensibility 扩展性Extensions to the AGENT+ API can be done in many ways. This includes supporting new versions of SNMP (e.g. version 3) and their administrative framework, base classes for additional types of managed objects, and adding new features. Through C+ class derivation, users of AGENT+ can inherit what they like and override what they wish to overload: A key concept of AGENT+ is the sub-classing of managed object base classes by the user. The user overrides virtual member functions of these base classes when she or he needs a specialisation to the default behaviour of the respective class member function. Agent+ 一个重要的概念就是由用户管理的子类积累。An Introductory ExampleTo get an idea of what benefits AGENT+ offers to a SNMP agent programmer, here is an example that shows the implementation of an agent for a coffee-percolator. For now, a single scalar managed object which represents the temperature of the coffee in the coffee-pot will do. Additional managed objects e.g. those that demonstrate how SNMP tables can be implemented with AGENT+ will follow later on. 简单标量管理对象。2Explanation of Introductory Example一个介绍性的例子。The main procedure of an AGENT+ SNMP agent (shown in figure 1) can be divided into three sections: 1. Setting up the SNMP protocol engine 设置SNMP 协议驱动First of all an extended version of the SNMP+ Snmp class ( Snmpx) is used to create a SNMP session that will be used for incoming SNMP requests. The example uses the standard SNMP port 161 to listen on, although any (available) UDP port can be chosen. If the session has been created successfully the session object snmp has to be registered to the static class RequestList which queues and manages SNMP requests. SNMPX 类 用来产生一个 SNMP 线程,使用标准的 SNMP 口 161 监听,snmp 线程注册到 RequestList 类中,RequestList 能够管理 SNMP 的请求。2. Create and register the MIB objects 产生和注册MIB 对象。The mib object is created which represents the conceptual database containing the management information of the agent (Management Information Base).MIB 对象代表了 Agent 的管理信息。 Then all objects that should be supported by the agent MIB are added. Each such object contains one or more instances of managed objects related to a subtree of the management information tree. The classes systemGroup, snmpGroup, and trapDestGroup are provided by AGENT+, which include the managed objects of the MIB II system and snmp group, as well as managed objects needed for trap destination registration. systemGroup, snmpGroup, and trapDestGroup 类 包含了 MIB II 系统和snmp 组 的管理信息。也包含了 trap 目的的注册信息。3. Loop forever for incoming SNMP requests 循环等待到来的 snmp 请求。The receive method of the RequestList object is used to wait for incoming SNMP request. The method takes as argument the maximum time to wait for a request in seconds. Note: If the agent uses multi-threading the RequestList can contain more than one request. A SNMP request is processed through the process_request method which propagates each sub-request to the appropriate MIB object. RequestList 对象用来等待到来的 snmp 请求。使用process_request 方法来处理子需求。 How a simple managed object like coffeeTemperature can be implemented using the AGENT+ API is shown by figures 2 and 3. The class coffeeTemperature is derived from MibLeaf which is itself derived from MibEntry. MibLeaf is the base class for all instances of managed objects that are leafs of the management information tree, also called scalar managed objects. The constructor of coffeeTemperature calls the constructor of its base class MibLeaf with three arguments: coffeeTemperature 是一个简单的管理类,源于 MibLeaf 类,而MibLeaf 类又源自 MibEntry。MibLeaf 是所有管理控制类的基类,是管理信息树的叶子,也称作标量控制对象。 coffeeTemperature 的构造 调用了MibLeaf的构造,在以下3点需要说明: the object identifier of the managed object instance the MIB object is representing. 实例化MIB对象,表示 the access rights to be used (coffeeTemperature is read only) 使用的入口权限(coffeeTemperature 是只读)the syntax in form of a from SnmpSyntax derived object that represents an object oriented view of Structure of Management Information (SMI) Abstract Syntax Notation (ASN.1) data types which are used by SNMP (see figure 4 or the SNMP+ specification for sub-classes of SnmpSyntax).源自SnmpSyntax 类的对象的语法组成,代表了面向对象的ASN.1规范的 SMI 管理信息,由 SNMP 使用。Because coffeeTemperature has not a constant value, we need to redefine the virtual member function get_request inherited from MibLeaf to get the actual temperature of the coffee from the management instrumentation. To translate between the different management information representations used by the management instrumentation (temperature measured in Fahrenheit) and the SNMP MIB definition (Celsius) the method get_coffee_temperature is used. 因为 coffeeTemperature 没有常量,我们需要重新定义从MibLeaf 继承而来的get_request 函数,以便从管理机制中得到实际的coffee的温度。The coffeeTemperature:get_request method first gets the actual temperature and stores it in value which is a pointer to the SnmpSyntax object that has been given as third parameter to the MibLeaf constructor. Then MibLeaf:get_request is called to actually answer the SNMP request using the value of value. ThatS all! Everything else is done by AGENT+.coffeeTemperature:get_request 方法第一次得到实际的温度把它存到了value ,这是一个指向SnmpSyntax 对象的指针,构造的时候采用了MibLeaf 的第三个参数。然后MibLeaf:get_request 被调用,使用value 值来应答SNMP 的请求, 其它事情都由 AGENT+处理了。 Figure 1: An example for a main routine of a SNMP agent to manage a coffee-percolator. Figure 2: Class definition for the managed object representing the coffee temperature图2 :代表 coffee temperature 类定义Figure 3: Class implementation of the managed object representing the coffee temperature图3:代表 coffee temperature 类的执行3.AGENT+ Features Power and Flexibility AGENT+ (in conjunction with SNMP+) provides a power and flexibility which would otherwise be difficult to implement and manage. A programmer using the AGENT+ API can concentrate his affords on the management instrumentation and method routines. He or she needs nothing to know about a SNMP protocol engine or dispatch table. Even the tricky task to manage dynamic SNMP tables that follow the SMIv2 row status textual convention is undertaken by AGENT+. Multi-Threaded Request Processing (New!) A MIB object method routines and thus its management instrumentation can run in an extra thread (pseudo) parallel executed to the agent main process. So time intensive calculations or information retrievals do not block the agent. This could increase the availability and reliability of the agent. Version 1.x of AGENT+ supported multi-processing. The use of multi-processing has had the following disadvantages: o Multi-processing needs a significant larger amount of system resources (i.e., memory and CPU) than multi-threading. o Processes need to communicate with each other. For this purpose System V Inter Process Communication (IPC) has been used by AGENT+ 1.x. A lot of coding had to be done to get this communication working, nevertheless the IPC could not completely hidden. As a result, the user interface was not as simple as it could have been. Consequently, AGENT+v2.0 user interface, as well as its code, is much easier to understand. o Multi-threading offers a (pseudo) parallel working management instrumentation access to the memory of the whole agent and its MIB. A child process has only a copy of the agents memory at the childs birth time, so it cannot recognise intermediate updates to the agent MIB. What is new: Agent+ Version 2.0 and greater supports the execution of the management instrumentation+ as multiple threads. Each SNMP request can be separately executed as a thread. For each instance of a MIB object (MibLeaf or MibTable) there can be only a single thread executing one of its method routines at the same time. Thus, you do not have to worry about synchronising memory reads/writes within your instrumentation methods. 新内容:Agent+ 2.0版本 支持管理控制作为多线程。每个snmp请求都可以分做 单线程。对每一个mib 对象(MibLeaf or MibTable)来说,在同一时间仅仅有一个单线程执行它的一个方法,因此,不需要担心执行方法的读写同步问题。As multi-processing is no longer supported, the methods MibEntry:update, MibEntry:result, Mib:busy, and Mib:process_updates known from version 1.0x have been removed. MIB II System and SNMP Group For the programmer convenience an implementation of the MIB IIS system and snmp group is provided with AGENT+. 提供了MIB IIS 系统和snmp group。 Proxy Support for Arbitrary Management Information Subtrees An arbitrary subtree of another agentS management information tree can be included in an agentS MIB simply be give the other agentS management transport address and the subtreeS object identifier when defining such an proxy MIB object. As long as the proxy subtrees are disjunctive any combination of such proxy MIB objects can be used at the same time with local MIB objects. Support for Persistent MIB Objects Scalar and table managed objects can be saved to disk and reloaded from it. This enables a user to easily save management information persistently. Support for SNMPv1 and SNMPv2c SNMP+ supports SNMPv1 and SNMPv2c thus AGENT+ likewise supports both versions. A support for SNMPv3 and its user and view based administrative model will follow in the near future. Detailed Logging / 详细的日志AGENT+ has a detailed logging mechanism supporting five log classes (error, warning, info, debug, event) with each supporting up to 16 levels. This makes debugging of your agent very easy and gives you full control about what is happening when your agent is running. 4An Introduction to SNMP+SNMP+ is a set of C+ classes which provide SNMP services to a network management application developer. An overview over these C+ classes gives figure 4. For further documentation about SNMP+ please read the corresponding specification which is freely available+ from the Hewlett Packard company. AGENT+ comes with a set of subclasses for some classes of SNMP+ which are shown in figure 4. Those subclasses provide extended functionality to their SNMP+ base classes, so their class names contain an appended x. Significant extensions and improvements have been made to Snmp by Snmpx, to Vb by Vbx, and to Oid by Oidx. AGENT+ 提供了一系列的snmp+的子类集,这些子类集由 snmp+ 扩展而来,因此类名后包含了x。Figure 4: Object Modelling Technique (OMT) view of the SNMP+ Framework图 4: SNMP+框架的OMT视图5 Agent+ 类5.1 Mib ClassThe AGENT+ Mib class represents a central part of any agent - the Management Information Base (MIB). The MIB of a SNMP agent is a conceptual database rather than a real database. An Agent has exactly one MIB, thus the Mib class is a singleton. Mib has three functional areas: MIB类代表了任何agent 的核心-管理信息库,它是一个概念上的库,而不是一个真正的库。一个agent只有一个mib.有3个功能:1. Registration of MIB objects 注册MIB对象。Use the add member function to add a MIB object (any C+ object derived from MibEntry) to the agents MIB. Use the remove member function to remove a MIB object from the agents MIB. Both functions can be used while the agent is running. 使用MIB对象(源自MibEntry 的一个C+ 对象)add 方法, 向 Agent 添加MIB 对象。2. Receive and Process SNMP Requests 接收和处理 snmp 请求。Incoming SNMP requests are accepted by using the receive member function. The receive function waits for such a request until a given timeout is reached. The timeout is given in seconds and if it is zero receive looks for a pending request and returns it immediately or if is not such a request receive returns the null pointer. 到来的 SNMP 请求使用 receive 函数处理。receive 函数 会一直等到超时。A request is processed by the agent by calling the process_request member function of the agents MIB. Depending of the request type the get_request, get_next_request, or prepare_set_request, commit_set_request, undo_set_request, and cleanup_set_request of each target MIB object is called. Because the targets of SNMP requests are managed objects, but the MIB contains only MIB objects (see figure 6) the mib object determines which MIB object manages which managed object. So, process_request calls the appropriate of the above mentioned functions for each target managed object. Agent MIB 类的成员函数 process_request 来处理snmp 的请求,根据请求的类型不同,可以采用get_request, get_next_request, or prepare_set_request, commit_set_request, undo_set_request, and cleanup_set_request 几个不同的方法进行。When the agent is t multi-threaded the method routines called by a request are executed within the same thread. This thread is then different from the master thread accepting new request. Figure 6: Example of an AGENT+ Mib StructureThe structure of an AGENT+ MIB slightly differs from the corresponding SNMP MIB structure. An Example of an AGENT+ MIB structure shows figure 6. Generally managed objects with SNMP syntax NO-ACCESS contain no management information and are therefore not represented by AGENT+ MIB objects. These managed objects are logical nodes of the management information tree and can not be instantiated. All instances of SNMP managed objects are represented by MIB leaf objects (derived from MibLeaf). 如图6,AGENT+ MIB 的结构和相应的 SNMP MIB 结构稍有不同,通常 SNMP 语法的 管理对象没有包含语法信息,应此不能由Agent + 的MIB对象代表。这些管理对象是管理信息树的逻辑上的节点并且不能被实例化。所有的SNMP管理对象由MIB leaf 对象代表(来自MibLeaf)。To concentrate the management of a whole management information subtree in a single MIB object the managed object at the root of the subtree is represented by a
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 文化创意产业项目建议书编写与推广合同
- 医院患者隐私保护管理办法
- 2025秦皇岛市海港区招聘社区工作者200人考试模拟试题及答案解析
- 机电设备购销合同示范文本
- 2025重庆临空艺术团招聘1人备考考试题库附答案解析
- 2025四川宜宾凯翼国际招聘备考模拟试题及答案解析
- 2025重庆市两江新区星海学校教师招聘备考考试题库附答案解析
- 2025山西省第二人民医院招聘合同制工作人员备考考试试题及答案解析
- 专业录音棚租赁服务合同
- 供货合同和销售合同(标准版)
- 服务业绿色低碳发展
- 教材研讨问题参考答案(课件)四年级上册科学教科版
- 2024年企业现场管理5S培训课件
- 综合测试01 识记默写(高考背诵课内分篇训练)高考语文一轮复习考点帮(北京专用)
- 北京导游资格考试外语口试题四
- 高中数学必修一第一、二章综合测试卷(含解析)
- 1.3集合的基本运算(第1课时)课件高一上学期数学人教A版
- 《学前儿童卫生与保健》高职全套教学课件
- 第4课 中国历代变法和改革 学案
- 2024-2025学年八年级地理上册 第一章 单元测试卷(湘教版)
- 六年级上册写字教案表格式全册
评论
0/150
提交评论