rtrmgr.tex
来自「BCAST Implementation for NS2」· TEX 代码 · 共 668 行 · 第 1/2 页
TEX
668 行
\documentclass[11pt]{article}\usepackage{graphicx}\usepackage{times}\textwidth 6.5in\topmargin 0.0in\textheight 8.5in\headheight 0in\headsep 0in\oddsidemargin 0in\title{XORP Router Manager Process (rtrmgr) \\\vspace{1ex}Version 0.5}\author{ XORP Project \\ International Computer Science Institute \\ Berkeley, CA 94704, USA \\ {\it feedback@xorp.org}}\date{November 6, 2003}%\twocolumn\begin{document}\maketitle \section{Introduction}This document provides a high-level technical overview of the RouterManager (rtrmgr) code structure, intended to aid anyone needing tounderstand or modify the software. It is not a user manual.The XORP software base consists of a number of routing protocols (BGP,OSPF, PIM-SM, etc), a Routing Information Base (RIB) process, aForwarding Engine Abstraction (FEA) process, and a forwarding path.Other management, monitoring or application processes may alsosupplement this set. Figure \ref{overview} illustrates theseprocesses and their principle communication channels.\begin{figure}[htb]\centerline{\includegraphics[width=0.6\textwidth]{figs/processes3}}\vspace{.05in}\caption{\label{overview}Overview of XORP processes}\end{figure}For research purposes, these processes may be started manually or fromscripts, so long as the dependencies between then are satisfied. Butwhen using XORP in a more operational environment, the network managertypically does not wish to see the software structure, but ratherwould like to interact with the router {\it as a whole}. Minimally, thisconsists of a configuration file for router startup, and a commandline interface to interact with the router during operation. Thertrmgr process provides this unified view of the router.The rtrmgr is normally the only process explicitly started at routerstartup. The rtrmgr process includes a built-in XRL finder, so noexternal finder process is required. The following sequence ofactions then occurs:\begin{enumerate}\item The rtrmgr reads all the template files in the router's templatedirectory. Typically there is one template file per XORP process thatmight be needed. A template file describes the functionality that isprovided by the corresponding process in terms of all of theconfiguration parameters that may be set. It also describes thedependencies that need to be satisfied before the process can bestarted. After reading the template files, the rtrmgr knows all theconfiguration parameters currently supportable on this router, and itstores this information in its \textit{template tree}.\itemThe rtrmgr next reads the contents of the XRL directory to discoverall the XRLs that are supported by the processes on this router.These XRLs are then checked against the XRLs in the template tree. Asit is normal for the XRLs in the XRL directory to be used to generatestub code in the XORP processes, this forms the definitive version ofa particular XRL. Checking against this version detects if a templatefile has somehow become out of sync with the router's codebase. Doingthis check at startup prevents subtle run time errors later. Thertrmgr will exit if a mismatch is discovered.\item The rtrmgr then reads the router configuration file. All theconfiguration options in the config file must correspond toconfigurable functionality as described by the template files. As itreads the config file, the rtrmgr stores the intended configuration inits \textit{configuration tree}. At this point, the nodes in theconfiguration tree are annotated as \textit{not existing} - that isthis part of the configuration has not yet been communicated to theprocess that will implement the functionality.\itemThe rtrmgr next traverses the configuration tree to discover the listof processes that need to be started to provide the requiredfunctionality. Typically not all the available software on the routerwill be needed for a specific configuration.\itemThe rtrmgr traverses the template tree again to discover an order forstarting the required processes that satisfies all their dependencies.\itemThe rtrmgr starts the first process in the list of processes to bestarted.\itemIf no error occurs, the rtrmgr traverses the configuration tree tobuild the list of XRLs that need to be called to configure the processjust started. These XRLs are then called, one after another, with thesuccessful completion of one XRL triggering the calling of the next.Some processes may require calling a transaction start XRL beforeconfiguration, and a transaction complete XRL after configuration -the rtrmgr can do this if required.\itemIf no error occurred during configuration, the next process is started,and configured, and so forth, until all the required processes arestarted and configured.\item At this point, the router is up and running. The rtrmgr will nowallow connections from the xorpsh process to allow interactiveoperation.\end{enumerate}\newpage\section{Template Files}The router manager reads a directory of template files to discover theconfiguration options that the router supports. A fragment of such aconfiguration file might look like:\begin{verbatim}protocols { ospf { router-id: ipv4; mospf: toggle = false; flood_rate: int; area @: ipv4 { stub: toggle = false; interface @: text { disable: toggle = false; hello-interval: uint = 30; dead-interval: uint = 95; } } }}\end{verbatim}This defines a subset of the configuration options for OSPF. Theconfiguration options form a tree, with three types of nodes:\begin{itemize}\item Structural nodes such as {\tt protocol} and {\tt ospf} that existmerely to provide scope.\item Named interior nodes such as ``{\tt area @}'' and ``{\tt interface @}'',where there can be multiple instances of the node. Here indicatesthat a name is required; in the case of ``area @'' the fragment abovespecifies that the name must be an IPv4 address.\item Leaf nodes such as {\tt flood\_rate} and{\tt hello-interval}. These nodes are also typed, and may optionallyspecify a default value. In the example above, {\tt hello-interval} isof type {\tt uint} (unsigned 32 bit integer), and takes the default value of30.\end{itemize}Thus the template tree created from this template file would looklike:\begin{figure}[htb]\centerline{\includegraphics[width=0.7\textwidth]{figs/template}}\vspace{.05in}%\caption{\label{overview}Overview of XORP processes}\end{figure}The same node may occur multiple times in the template file. Thismight happen because the node can take more than one type (forexample, it might have an IPv4 or an IPv6 address), or it might happenbecause the second definition adds information to the existingdefinition.In addition to specifying the configurable options, the template fileshould also specify what the rtrmgr should do when an option ismodified. These commands annotating the template file begin with a``{\tt \%}''. Thus the template file above might also contain thefollowing annotated version of the template tree:\begin{verbatim}protocols ospf { %modinfo: provides ospf; %modinfo: depends rib; %modinfo: path "ospfd/xorp/ospfd"; router-id { %set: xrl "ospf/ospf/0.1/set_router_id?id:u32=$(@)"; %get: xrl "ospf/ospf/0.1/get_router_id->id:u32"; } area @ { %create: xrl "ospf/ospf/0.1/add_or_configure_area? area_id:u32=$(area.@)&is_stub:bool=$(@.stub)"; %delete: xrl "ospf/ospf/0.1/delete_area?area_id:u32=$(area.@)"; }}\end{verbatim}The first three annotations apply to the ``protocols ospf'' node, andspecify the ``\%modinfo'' command, which provides information aboutthe module providing this functionality. In this case they specifythat this functionality is provided by the module called {\tt ospf},that this module depends on the module called {\tt rib}, and that thesoftware in {\tt ospfd/xorp/ospfd} is the software to run toprovide this module.The ``{\tt protocols ospf router-id}'' node carries annotations to setthe value of the router ID in the ospf process, and to get the valueback. The set command is:\begin{verbatim} %set: xrl "ospf/ospf/0.1/set_router_id?id:u32=$(@)";\end{verbatim}This specifies that to set this value, the rtrmgr must call thespecified XRL. In this case it specifies a variable expansion of thevariable {\tt \$(@)}. All variables take the form {\tt \$(}...{\tt)}. The variable {\tt \$(@)} means the value of thecurrent node, so if the router ID node in the configuration tree hadthe value 1.2.3.4, then the XRL to call would be:\begin{verbatim} ospf/ospf/0.1/set_router_id?id:u32=1.2.3.4\end{verbatim}The {\tt \%set} command only applies to leaf nodes. Internal nodes would typically use the {\tt \%create} command tocreate a new instance of the node, as shown with the ``{\tt protocols ospfarea @}'' node. In the example above, the {\tt \%create} commandinvolves two variable expansions: {\tt \$(area.@)} and {\tt\$(@.stub)}. The form {\tt \$(area.@)} means ``this area'', and soin this case it is directly equivalent to {\tt \$(@)} meaning ``this node''.The variable {\tt \$(@.stub)} means the value of the leaf node called{\tt stub} that is a child node of ``this node''.Thus the template tree specifies the following information:\begin{itemize}\item The nodes of the tree specify all the configuration optionspossible on the router.\item Some of the nodes are annotated with information to indicatewhich software to run to provide the functionality rooted at thatnode, and to indicate which other modules this software depends onbeing running.\item Most of the nodes are annotated with commands to be run when thevalue of the node changes in the configuration tree, when a newinstance of the node is created or an instance of the node is deletedin the configuration tree, or to get the current value of a node fromthe running processes providing the functionality.\end{itemize}\subsection{Template Tree Node Types}The following types are currently supported for template tree nodes:\begin{description}\item{\tt uint}\\Unsigned 32 bit integer\item{\tt int}\\Signed 32 bit integer\item{\tt bool}\\Boolean - valid values are {\tt true} and {\tt false}.\item{\tt toggle}\\Similar to boolean, but requires a default value. Display of theconfig tree node is suppressed if the value is the default.\item{\tt ipv4}\\An IPv4 address in dotted decimal format.\item{\tt ipv4\_prefix}\\ An IPv4 address and prefix length in theconventional format. E.g.: {\tt 1.2.3.4/24}.\item{\tt ipv6}\\An IPv6 address in the canonical colon-separated human-readable format.\item{\tt ipv6\_prefix}\\An IPv6 address and prefix in the conventional format. E.g.: {\ttfe80::1/64}\item{\tt macaddr}\\An MAC address in the conventional colon-separated hex format. E.g.:{\tt 00:c0:4f:68:8c:58}\end{description}It is likely that additional types will be added in the future, asthey are found to be needed.\subsection{Template Tree Commands}This section provides a complete listing of all the template treecommands that the rtrmgr supports.\subsubsection{The {\tt \%modinfo} Command.}The sub-commands to the {\tt \%modinfo} command are:\begin{description}\item {{\tt \%modinfo: provides }{\it ModuleName}} \\The {\tt provides} subcommand takes one additionalparameter, which gives the name of the module providing thefunctionality rooted at this node. \item {{\tt \%modinfo: depends }{\it list of modules}} \\The {\tt depends} subcommand takes at least one additionalparameter, giving a list of the other modules that mustbe running and configured before this module may be started.\item {{\tt \%modinfo: path }{\it ProgramPath}} \\The {\tt path} subcommand takes one additional parameter giving the pathname of the software to be runto provide this functionality. The pathname may be absolute orrelative to the root of the XORP tree. The ordering in computing the root ofthe tree is: (a) the shell environment XORP\_ROOT (if exists); (b) the parentdirectory the rtrmgr is run from (only if it contains theetc/templates and the xrl/targets directories); (c) the XORP\_ROOT value asdefined in config.h (currently this is the installation directory, anddefaults to ``/usr/local/xorp'').\item {{\tt \%modinfo: startcommit }{\it XRL}} \\The {\tt startcommit} subcommand takes one additionalparameter, and gives the XRL to call before performingany change to the configuration of the module.\item {{\tt \%modinfo: endcommit }{\it XRL}} \\The {\tt endcommit} subcommand takes one additionalparameter, and gives the XRL to call to complete anychange to the configuration of the module. startcommit andendcommit are optional. They provide a way to make batch changes to amodule configuration as an atomic operation.\item {{\tt \%modinfo: statusmethod }{\it method}} \\The {\ttstatusmethod} subcommand indicates the mechanism to be used todiscover the status of the module. The only method current supportedis {\tt xrl} which indicates usage of the common interface {\ttget\_status} XRL.\item {{\tt \%modinfo: shutdownmethod }{\it method}} \\The {\ttshutdownmethod} subcommand indicates the mechanism to be used togracefully shutdown the module. The only method current supportedis {\tt xrl} which indicates usage of the common interface {\ttshutdown} XRL. If the process does not then transition to {\ttPROC\_SHUTDOWN} state, the rtrmgr will then kill the process.\end{description}\subsubsection{The {\tt \%create} Command.}{\tt \%create} is used to create a new instance of an interior node inthe configuration tree. \begin{itemize}\item The first parameter indicates the form ofaction to take to perform this action - typically it is {\tt xrl}which indicates an XRL should be called. \item If the action is {\tt xrl}, then the second parameter gives the XRL tocall to create the new configuration tree instance of this templatetree node.\end{itemize}\subsubsection{The {\tt \%activate} Command.}{\tt \%activate} is used to activate a new instance of an interiornode in the configuration tree. It is typically paired with {\tt\%create} - the {\tt \%create} command is executed before the relevantconfiguration of the node's children has been performed, whereas {\tt\%activate} is executed after the node's children have beenconfigured. A particular interior node might have either {\tt\%create}, {\tt \%activate} or both.\begin{itemize}\item The first parameter indicates the form of action to take to performthis action - typically it is {\tt xrl} which indicates an XRL shouldbe called.\item If the action is {\tt xrl}, then the second parameter gives the XRL tocall to activate the new configuration tree instance of this templatetree node\end{itemize}For example, if the template tree held the following:\begin{tabbing}\tt addr\=\tt ess \=\tt@: ipv4 \{\\ \>\tt\%create: xrl {\it XRL1}\\
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?