📄 c-sub_agents4.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> SNMP Distributed Agents </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a></a><a href="c-sub_agents.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-sub_agents3.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-sub_agents5.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="85630">7.4 Messages Passed between Master Agents and Subagents </a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="88669"> </a>When <b class="task">tSnmpd</b> spawns <b class="task">tMonQue</b>, it assigns <b><i>snmpQueMonitor</i></b><b>( )</b> to manage the <b class="task">tMonQue </b>task. This function waits on the message queue that subagents use to send messages to the master agent. The <b><i>snmpQueMonitor</i></b><b>( )</b> function interprets messages on its queue using an <b class="symbol_UC">SA_MESSAGE_T</b> structure, which is defined in <b class="file">ipcLib.h</b> as: </p><dl class="margin"><dd><pre class="Code2"><b><a name="88670">typedef struct SA_MESSAGE_S { int msgType; MSG_Q_ID saId; EBUFFER_T mesg; } SA_MESSAGE_T;</a></b></pre></dl><dd><p class="Body"><a name="88676"> </a>A switch internal to <b><i>snmpQueMonitor</i></b><b>( )</b> handles the message according to the value of the <b class="symbol_lc">msgType</b> member.</p><dd><p class="Body"><a name="88677"> </a>If the message type is <b class="symbol_UC">CALL_QUERY_HANDLER</b>, the message is a response to a query from the master agent. The buffer referenced in the <b class="symbol_lc">mesg</b> is then transferred to the local message queue monitored by <b class="task">tSnmpd</b>, which is waiting for a query response from a subagent.</p><dd><p class="Body"><a name="88678"> </a>If the message type is <b class="symbol_UC">IPC_AYT</b>, the message is an "are you there" message, which is forwarded to the local message queue monitored by <b class="task">tSnmpd</b>, which is waiting for a response to its "are you there" query against the subagent.</p><dd><p class="Body"><a name="88679"> </a>If the message type is <b class="symbol_UC">CALL_REG_HANDLER</b>, the message is either a registration request or a deregistration request. To respond to such requests, <b><i>snmpQueMonitor</i></b><b>( )</b> passes the buffer in <b class="symbol_lc">mesg</b> to <b><i>snmpMasterHandlerWR</i></b><b>( )</b>. </p></dl></dl><dl class="margin"><dd><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><a name="88773"><br></a><img border="0" alt="*" src="icons/note.gif"> </td><td><div class="Note"><hr><b class="symbol_UC">NOTE: </b>Because <b><i>snmpQueMonitor</i></b><b>( )</b>is defined in <b class="file">masterIoLib.c</b> as <b class="symbol_UC">LOCAL</b>, no reference entry is produced for this function. However, <b><i>snmpQueMonitor</i></b><b>( )</b>is fully described in the reference entry for <b class="routine"><i class="routine">snmpMonitorSpawn</i></b><b>( )</b>. In addition, the source for <b class="file">masterIoLib.c</b> is shipped, so you are free to study or even modify the source for <b class="routine"><i class="routine">snmpMonitorSpawn</i></b><b>( )</b><b><i> </i></b>as needed. <hr></div></td></tr></table></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="88796">Serial versus Asynchronous Communication with Subagents </a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="88801"> </a>The requests that a master agent receives from the SNMP manager typically require information on several MIB variables. If those variables are managed by different subagents, the master agent must query each subagent. In the shipped version of WindNet SNMP, these requests are handled serially. That is, each subagent is queried in turn. For example, if the master agent needed to query three subagents to handle a request from the SNMP master, the master agent would query a subagent and wait for a response before it went on to query the next subagent. </p><dd><p class="Body"><a name="88811"> </a>However, if each subagent resides on its own target with its own processor, you might want to take advantage of the possibility for parallel processing. That is, you would want the master agent to send queries to each subagent without waiting for responses between requests. This lets the subagents work in parallel. </p><dd><p class="Body"><a name="88820"> </a>To implement this asynchronous interrogation of subagents, you must modify <b><i>snmpQueMonitor</i></b><b>( )</b>to call <b><i>snmpMasterHandlerAsync</i></b><b>( )</b> instead of <b><i>snmpMasterHandlerWR</i></b><b>( )</b>. For more information, see the reference entry for <b><i>snmpMasterHandlerAsync</i></b><b>( )</b>. </p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="88974">Changing the IPC Mechanism </a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="88962"> </a>The asynchronous interaction with subagents with the master agent is an advantage only if the master agent and its subagents reside on different targets. However, the shipped version of WindNet SNMP uses message queues as the IPC that connects the master agent with its subagents. Because message queues rely on a shared memory space, it is not possible to use message queues as the IPC between a master agent and a subagent that execute on different targets. </p><dd><p class="Body"><a name="88986"> </a>Fortunately, it is relatively easy to replace the underlying technology of the IPC mechanism. For example, it is possible to replace message queues with socket connections. To help make this replacement easier, all the functions that implement the IPC mechanism have been isolated to the <b class="library">masterIoLib</b> and <b class="library">saIoLib</b>. These libraries are shipped as source code that you are free to modify according to your needs. For more information on how you can modify these libraries to use a different IPC mechanism, see the reference entries for <b class="library">masterIoLib</b> and <b class="library">saIoLib</b>.</p></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a></a><a href="c-sub_agents.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-sub_agents3.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-sub_agents5.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc. conversion tool: Quadralay WebWorks Publisher 4.0.11 template: CSS Template, Jan 1998 - Jefro --->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -