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

📄 node66.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>7.1.1 Queue blocking</TITLE><META NAME="description" CONTENT="7.1.1 Queue blocking"><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="node67.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node67.html"><LINK REL="previous" HREF="node65.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node65.html"><LINK REL="up" HREF="node65.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node65.html"><LINK REL="next" HREF="node67.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node67.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html2336"  HREF="node67.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node67.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2330"  HREF="node65.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node65.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2324"  HREF="node65.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node65.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2332"  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="tex2html2334"  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="tex2html2337"  HREF="node67.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node67.html">7.1.2 PacketQueue Class</A><B> Up:</B> <A NAME="tex2html2331"  HREF="node65.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node65.html">7.1 The C++ Queue</A><B> Previous:</B> <A NAME="tex2html2325"  HREF="node65.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node65.html">7.1 The C++ Queue</A> &nbsp <B>  <A NAME="tex2html2333"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html2335"  HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <BR><BR><!--End of Navigation Panel--><H2><A NAME="SECTION03411000000000000000"></A><A NAME="sec:qblock"></A><BR>7.1.1 Queue blocking</H2><P>A queue may be either blocked or unblocked at any given time.Generally, a queue is blocked when a packet is in transit between itand its downstream neighbor (most of the time if the queue is occupied).A blocked queue will remain blocked as long as it downstream link isbusy and the queue has at least one packet to send.A queue becomes unblocked only when its <TT>resume</TT> function isinvoked (by means of a downstream neighbor scheduling it viaa callback), usually when no packets are queued.The callback is implemented by using the following class andmethods:<PRE>        class QueueHandler : public Handler {        public:                inline QueueHandler(Queue&amp; q) : queue_(q) {}                void handle(Event*); /* calls queue_.resume() */         private:                Queue&amp; queue_;        };        void QueueHandler::handle(Event*)        {                queue_.resume();        }        Queue::Queue() : drop_(0), blocked_(0), qh_(*this)        {                Tcl&amp; tcl = Tcl::instance();                bind("limit_", &amp;qlim_);        }        void Queue::recv(Packet* p, Handler*)        {                enque(p);                if (!blocked_) {                        /*                         * We're not block.  Get a packet and send it on.                         * We perform an extra check because the queue                         * might drop the packet even if it was                         * previously empty!  (e.g., RED can do this.)                         */                        p = deque();                        if (p != 0) {                                blocked_ = 1;                                target_-\&gt;recv(p, &amp;qh_);                        }                }        }        void Queue::resume()        {                Packet* p = deque();                if (p != 0)                        target_-\&gt;recv(p, &amp;qh_);                else {                        if (unblock_on_resume_)                                blocked_ = 0;                        else                                blocked_ = 1;                }        }</PRE>The handler management here is somewhat subtle.When a new <TT>Queue</TT> object is created,it includes a <TT>QueueHandler</TT> object (<TT>qh_</TT>)which is initialized to contain a reference to the new <TT>Queue</TT> object(<TT>Queue&amp; QueueHandler::queue_</TT>).This is performed by the <TT>Queue</TT> constructor using the expression<TT>qh_(*this)</TT>.When a Queue receives a packet it calls the subclass(i.e. queueing discipline-specific) version ofthe <TT>enque</TT> function with the packet.If the queue is not blocked, it is allowed to send a packet andcalls the specific <TT>deque</TT> function which determines whichpacket to send, blocks the queue (because a packet is now in transit), andsends the packet to the queue's downstream neighbor.Note that any future packets received from upstream neighborswill arrive to a blocked queue.When a downstream neighbor wishes to cause the queue to become unblockedit schedules the QueueHandler's <TT>handle</TT> function bypassing <TT>&amp;qh_</TT> to the simulator scheduler.The <TT>handle</TT> function invokes <TT>resume</TT>, whichwill send the next-scheduled packet downstream (and leave the queue blocked),or unblock the queue when no packet is ready to be sent.This process is made more clear by also referring to the[]LinkDelay::recv methodSectionsec:delayclass.<P><HR><!--Navigation Panel--><A NAME="tex2html2336"  HREF="node67.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node67.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2330"  HREF="node65.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node65.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2324"  HREF="node65.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node65.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2332"  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="tex2html2334"  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="tex2html2337"  HREF="node67.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node67.html">7.1.2 PacketQueue Class</A><B> Up:</B> <A NAME="tex2html2331"  HREF="node65.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node65.html">7.1 The C++ Queue</A><B> Previous:</B> <A NAME="tex2html2325"  HREF="node65.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node65.html">7.1 The C++ Queue</A> &nbsp <B>  <A NAME="tex2html2333"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html2335"  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 + -