⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node268.html

📁 相关搜索: ns2仿真结果分析 all-awk ns2 ns2 无限网络中awk文件 ... [2.tcl.rar] - 在ns2平台上实现对AODV协议的模拟
💻 HTML
字号:
<html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><!--Converted with jLaTeX2HTML 2002 (1.62) JA patch-1.4patched version by:  Kenshi Muto, Debian Project.LaTeX2HTML 2002 (1.62),original version by:  Nikos Drakos, CBLU, University of Leeds* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan* with significant contributions from:  Jens Lippmann, Marek Rouchal, Martin Wilck and others --><HTML><HEAD><TITLE>23.2 Library support and examples</TITLE><META NAME="description" CONTENT="23.2 Library support and examples"><META NAME="keywords" CONTENT="everything"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"><META NAME="Generator" CONTENT="jLaTeX2HTML v2002 JA patch-1.4"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><LINK REL="STYLESHEET" HREF="everything.css" tppabs="http://www.isi.edu/nsnam/ns/doc/everything.css"><LINK REL="next" HREF="node269.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node269.html"><LINK REL="previous" HREF="node266.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node266.html"><LINK REL="up" HREF="node265.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node265.html"><LINK REL="next" HREF="node269.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node269.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html5415"  HREF="node269.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node269.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html5409"  HREF="node265.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node265.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html5403"  HREF="node267.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node267.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html5411"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="file:/usr/share/latex2html/icons/contents.png"></A> <A NAME="tex2html5413"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html"><IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="file:/usr/share/latex2html/icons/index.png"></A> <BR><B> Next:</B> <A NAME="tex2html5416"  HREF="node269.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node269.html">23.3 The C++ Trace</A><B> Up:</B> <A NAME="tex2html5410"  HREF="node265.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node265.html">23. Trace and Monitoring</A><B> Previous:</B> <A NAME="tex2html5404"  HREF="node267.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node267.html">23.1.1 OTcl Helper Functions</A> &nbsp <B>  <A NAME="tex2html5412"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html5414"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <BR><BR><!--End of Navigation Panel--><H1><A NAME="SECTION04320000000000000000"></A><A NAME="sec:libexam"></A><BR>23.2 Library support and examples</H1><P>The <TT>Simulator</TT> procedures described above require the <TT>trace</TT>and <TT>init-monitor</TT> methods associated with the OTcl <TT>Link</TT> class.Several subclasses of link are defined, the most common of whichis called <TT>SimpleLink</TT>.  Thus, the <TT>trace</TT> and <TT>init-monitor</TT>methods are actually part of the <TT>SimpleLink</TT> class rather thanthe <TT>Link</TT> base class.The <TT>trace</TT> function is defined as follows (in <TT>ns-link.tcl</TT>):<PRE>## Build trace objects for this link and# update the object linkage#SimpleLink instproc trace { ns f } {        $self instvar enqT_ deqT_ drpT_ queue_ link_ head_ fromNode_ toNode_        $self instvar drophead_        set enqT_ [$ns create-trace Enque $f $fromNode_ $toNode_]        set deqT_ [$ns create-trace Deque $f $fromNode_ $toNode_]        set drpT_ [$ns create-trace Drop $f $fromNode_ $toNode_]        $drpT_ target [$drophead_ target]        $drophead_ target $drpT_        $queue_ drop-target $drpT_        $deqT_ target [$queue_ target]        $queue_ target $deqT_        if { [$head_ info class] == "networkinterface" } {            $enqT_ target [$head_ target]            $head_ target $enqT_            # puts "head is i/f"        } else {            $enqT_ target $head_            set head_ $enqT_            # puts "head is not i/f"        }}</PRE>This function establishes <TT>Enque</TT>, <TT>Deque</TT>, and <TT>Drop</TT>traces in the simulator <TT>$ns</TT> and directs theiroutput to I/O handle <TT>$f</TT>.The function assumes a queue has been associated with the link.It operates by first creating three new trace objectsand inserting the <TT>Enque</TT> object before the queue, the<TT>Deque</TT> object after the queue, and the <TT>Drop</TT> objectbetween the queue and its previous drop target.Note that all trace output is directed to the same I/O handle.<P>This function performs one other  additional tasks.It checks to see if a link contains a network interface,and if so, leaves it as the first object in the chain of objectsin the link, but otherwise inserts the <TT>Enque</TT> object asthe first one.<P>The following functions, <TT>init-monitor</TT> and<TT>attach-monitor</TT>, are used to create a set ofobjects used to monitor queue sizes of a queue associatedwith a link.They are defined as follows:<PRE>        SimpleLink instproc attach-monitors { insnoop outsnoop dropsnoop qmon } {                $self instvar queue_ head_ snoopIn_ snoopOut_ snoopDrop_                $self instvar drophead_ qMonitor_                set snoopIn_ $insnoop                set snoopOut_ $outsnoop                set snoopDrop_ $dropsnoop                $snoopIn_ target $head_                set head_ $snoopIn_                $snoopOut_ target [$queue_ target]                $queue_ target $snoopOut_                $snoopDrop_ target [$drophead_ target]                $drophead_ target $snoopDrop_                $snoopIn_ set-monitor $qmon                $snoopOut_ set-monitor $qmon                $snoopDrop_ set-monitor $qmon                set qMonitor_ $qmon        }        #        # Insert objects that allow us to monitor the queue size        # of this link.  Return the name of the object that        # can be queried to determine the average queue size.        #        SimpleLink instproc init-monitor { ns qtrace sampleInterval} {                $self instvar qMonitor_ ns_ qtrace_ sampleInterval_                set ns_ $ns                set qtrace_ $qtrace                set sampleInterval_ $sampleInterval                set qMonitor_ [new QueueMonitor]                $self attach-monitors [new SnoopQueue/In] \bs                        [new SnoopQueue/Out] [new SnoopQueue/Drop] $qMonitor_                set bytesInt_ [new Integrator]                $qMonitor_ set-bytes-integrator $bytesInt_                set pktsInt_ [new Integrator]                $qMonitor_ set-pkts-integrator $pktsInt_                return $qMonitor_        }</PRE>These functions establish queue monitoring on the <TT>SimpleLink</TT> objectin the simulator <TT>ns</TT>.Queue monitoring is implemented by constructing three <TT>SnoopQueue</TT>objects and one <TT>QueueMonitor</TT> object.The <TT>SnoopQueue</TT> objects are linked in around a <TT>Queue</TT> in a waysimilar to <TT>Trace</TT> objects.The <TT>SnoopQueue/In(Out)</TT> object monitors packet arrivals(departures)and reports them to an associated <TT>QueueMonitor</TT> agent.In addition, a <TT>SnoopQueue/Out</TT> object is also used to accumulatepacket drop statistics to an associated <TT>QueueMonitor</TT> object.For <TT>init-monitor</TT> the same <TT>QueueMonitor</TT> object is usedin all cases.The C++ definitions of the <TT>SnoopQueue</TT> and <TT>QueueMonitor</TT>classes are described below.<P><HR><!--Navigation Panel--><A NAME="tex2html5415"  HREF="node269.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node269.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html5409"  HREF="node265.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node265.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html5403"  HREF="node267.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node267.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html5411"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="file:/usr/share/latex2html/icons/contents.png"></A> <A NAME="tex2html5413"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html"><IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="file:/usr/share/latex2html/icons/index.png"></A> <BR><B> Next:</B> <A NAME="tex2html5416"  HREF="node269.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node269.html">23.3 The C++ Trace</A><B> Up:</B> <A NAME="tex2html5410"  HREF="node265.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node265.html">23. Trace and Monitoring</A><B> Previous:</B> <A NAME="tex2html5404"  HREF="node267.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node267.html">23.1.1 OTcl Helper Functions</A> &nbsp <B>  <A NAME="tex2html5412"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html5414"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <!--End of Navigation Panel--><ADDRESS>2003-09-23</ADDRESS></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -