📄 snmp_overview.tex
字号:
%% $XORP: xorp/docs/snmp/snmp_overview.tex,v 1.28 2007/03/15 00:43:16 pavlin Exp $%\documentclass[11pt]{article}%\usepackage[dvips]{changebar}\usepackage{subfigure}\usepackage{fullpage}\usepackage{setspace}\usepackage{times}\usepackage{latexsym}\usepackage{epsfig}\usepackage{graphicx}\usepackage{xspace}\usepackage{color}\usepackage{amsmath}\usepackage{rotating}\usepackage{moreverb}\usepackage{listings}\usepackage{alltt}\usepackage{stmaryrd}%\usepackage[dvipdf]{graphics}%\usepackage[dvips]{graphicx}%\usepackage{xorp}\definecolor{gray}{rgb}{0.5,0.5,0.5}\newcommand{\etc}{\emph{etc.}\xspace}\newcommand{\ie}{\emph{i.e.,}\xspace}\newcommand{\eg}{\emph{e.g.,}\xspace}%\newcommand{\comment}[1]{{\color{gray}[\textsf{#1}]}}%\newcommand{\comment}[1]{}% Changebar stuff% \newenvironment{colorcode}{\color{blue}}{}% \renewcommand{\cbstart}{\begin{colorcode}}% \renewcommand{\cbend}{\end{colorcode}}% \pagestyle{empty}\begin{document}\title{XORP SNMP Agent \\\vspace{1ex}Version 1.4}\author{ XORP Project \\ International Computer Science Institute \\ Berkeley, CA 94704, USA \\ {\it http://www.xorp.org/} \\ {\it feedback@xorp.org}}\date{March 20, 2007}\maketitle%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\section{Introduction}The SNMP standards \cite{STD0062} define the protocol used to communicatebetween SNMP managers and agents, as well as the structure of the managementinformation being accessed (MIB). This document describes how XORP runtime datais made accessible to the SNMP agent, how it is decomposed in separate MIBmodules, and how those modules are loaded/unloaded at runtime. Also, a MIBdevelopment framework is presented, which provides unified process to thosewriting new MIB modules for XORP.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\section{The SNMP agent}XORP uses the extensible SNMP agent included in the Net-SNMP package\cite{net-snmp}. Net-SNMP provides tools and libraries supporting the SimpleNetwork Management Protocol. The package is comprised of an extensible agent(\texttt{snmpd}), an SNMP library and a set of command line tools tocommunicate with SNMP agents and managers. Management information is viewed as a collection of managed objects, residingin a virtual information store, termed the Management Information Base (MIB).All managed objects in the MIB are arranged in a hierarchical or treestructure. Collections of related objects are defined in MIB modules. Thesemodules are written in the SNMP data definition language, a subset of AbstractSyntax Notation One (ASN.1). New MIB modules that extend the Internet-standardMIB are continuously being defined by various IETF working groups. In the context of this document, we'll extend the term MIB module to includethe part of the code that instantiates the objects declared in the MIBdefinition file. Thus a MIB module consists of:\begin{description} \item[MIB module definition file] This file is written in ASN.1 language, and is typically published as an RFC. \item[MIB module source code] One or more source files that implement the data access routines that allow the SNMP agent to read or modify XORP's configuration settings. \end{description} The oldest version of Net-SNMP that was tested with XORP is 5.0.6. If anolder version is detected by our \texttt{configure} script, XORP MIB moduleswill not be built.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\subsection{Dynamically loadable MIB modules}\label{sec:MIB_module_format}One of the guiding principles in XORP design is extensibility. Protocols areimplemented as independent Unix processes that may come and go. Each protocolwill have one or more associated MIB modules, so those modules should be madeavailable to the SNMP agent without requiring recompilation. Net-SNMP supportsthis strategy by allowing MIBs to be implemented as shared objects. If yoursystem supports shared libraries, Net-SNMP will be compiled with support fordynamically loadable MIB modules by default. You can test if your Net-SNMPinstallation supports that option by looking for \texttt{dlmod} in the listprinted by the command:\begin{verbatim}$ net-snmp-config --snmpd-module-list\end{verbatim}There are three methods for loading/unloading MIB modules: \begin{enumerate} \item Using the dlmod directive in snmpd.conf \item Sending SNMP set requests to the agent \item Using XORP's IPC methods (XRLs)\end{enumerate}The first option can only be used to load modules at startup. This is what theman page for snmpd.conf tells you...\begin{verbatim}DYNAMICALLY LOADABLE MODULES If the agent is built with support for the UCD-DLMOD-MIB it is capable of loading agent MIB modules dynamically at startup through the dlmod directive and during runtime through use of the UCD-DLMOD-MIB. The following directive loads the shared object module file PATH which uses the module name prefix NAME. dlmod NAME PATH\end{verbatim}To load MIBs using SNMP requests, a new row must be added toUCD-DLMOD-MIB::dlmodTable. This involves finding an unused index to the table,setting the values of dlmodName and dlmodPath for that row, and finally settingthe column dlmodStatus to 'load'. These steps are captured in the followinglines:\begin{verbatim}$ snmpwalk localhost UCD-DLMOD-MIB::dlmodTableUCD-DLMOD-MIB::dlmodName.1 = STRING: xorp_if_mib_moduleUCD-DLMOD-MIB::dlmodPath.1 = STRING: /scratch/xorp/mibs/xorp_if_mib_module.soUCD-DLMOD-MIB::dlmodError.1 = STRING:UCD-DLMOD-MIB::dlmodStatus.1 = INTEGER: loaded(1)$ snmpset localhost UCD-DLMOD-MIB::dlmodStatus.2 i createUCD-DLMOD-MIB::dlmodStatus.2 = INTEGER: create(6)$ snmpset localhost UCD-DLMOD-MIB::dlmodName.2 s "bgp4_mib_1657" \ > UCD-DLMOD-MIB::dlmodPath.2 s "/scratch/xorp/mibs/bgp4_mib_1657.so"UCD-DLMOD-MIB::dlmodName.2 = STRING: bgp4_mib_1657UCD-DLMOD-MIB::dlmodPath.2 = STRING: /scratch/xorp/mibs/bgp4_mib_1657.so$ snmpset localhost UCD-DLMOD-MIB::dlmodStatus.2 i loadUCD-DLMOD-MIB::dlmodStatus.2 = INTEGER: load(4)$ snmpwalk localhost UCD-DLMOD-MIB::dlmodTableUCD-DLMOD-MIB::dlmodName.1 = STRING: xorp_if_mib_moduleUCD-DLMOD-MIB::dlmodName.2 = STRING: bgp4_mib_1657UCD-DLMOD-MIB::dlmodPath.1 = STRING: /scratch/xorp/mibs/xorp_if_mib_module.soUCD-DLMOD-MIB::dlmodPath.2 = STRING: /scratch/xorp/mibs/bgp4_mib_1657.soUCD-DLMOD-MIB::dlmodError.1 = STRING:UCD-DLMOD-MIB::dlmodError.2 = STRING:UCD-DLMOD-MIB::dlmodStatus.1 = INTEGER: loaded(1)UCD-DLMOD-MIB::dlmodStatus.2 = INTEGER: loaded(1)\end{verbatim}So far we've seen how to load MIBs when the agent is started, and at runtimeusing SNMP requests. But XORP processes communicate to each other via XRLs,and it would be much more convenient for a process to be able to use the samemechanism to communicate with the SNMP agent. For this reason each MIB moduleshould implement an Xrl target. The module \texttt{xorp\_if\_mib\_module}implements an XRL interface that allows loading and unloading MIBs. These arethe XRLs to use for that: \begin{ttfamily}\begin{verbatim}finder://xorp_if_mib/xorp_if_mib/0.1/load_mib?mod_name:txt&abs_path:txtfinder://xorp_if_mib/xorp_if_mib/0.1/unload_mib?mib_index:u32\end{verbatim}\end{ttfamily}Dynamically loadable MIB modules written for the main SNMP agent can also beloaded by an SNMP sub-agent that communicates with the master agent via theAgentX protocol (\cite{AgentX}). This should be useful in the event that youconfigure XORP to run distributed across multiple hosts but with one master SNMP agent. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\section{Connecting Net-SNMP with XORP}We have written a special MIB module (\texttt{xorp\_if\_mib\_module}) thatcoordinates the communication between \texttt{snmpd} and XORP processes. Thismodule provides several classes that allow XORP MIB modules to be architectedas if they were each executed as independent processes (although they all runin \texttt{snmpd}'s process space). This should make MIB module design mucheasier to someone already familiar with the architecture of XORP processes. The class that does all the synchronization between XORP and Net-SNMP is SnmpEventLoop, a subclass of EventLoop. This singleton class isresponsible for registering XORP event's with \texttt{snmpd}, so that the agentcan respond to XORP activity. Once this class is instantiated by\texttt{xorp\_if\_mib\_module}, it can be used by all the other MIB modules asif it was their own EventLoop. Without it, MIB modules could not respond toXORP events, this is why this module must be loaded before any other, andshould be the last XORP MIB module to be unloaded \footnote{There is a secondreason for this requirement. Some runtime loaders will unload a dynamicallylinked library when the module that first loaded it disappears. In that case,unloading \texttt{xorp\_if\_mib\_module} will also unload\texttt{libnetsnmpxorp.so} which is needed by \emph{all} XORP modules. As youcan imagine, that causes problems...}. Typically you would use the\texttt{snmpd.conf} file to load it at start up time. The XORP interface MIB module also implements the XRL target (\cite{xorp:xrl})that allows the loading and unloading of other MIB modules.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -