📄 node68.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.2 Example: Drop Tail</TITLE><META NAME="description" CONTENT="7.2 Example: Drop Tail"><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="node69.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node69.html"><LINK REL="previous" HREF="node65.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node65.html"><LINK REL="up" HREF="node64.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node64.html"><LINK REL="next" HREF="node69.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node69.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html2362" HREF="node69.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node69.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2356" HREF="node64.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node64.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2350" HREF="node67.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node67.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2358" 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="tex2html2360" 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="tex2html2363" HREF="node69.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node69.html">7.3 Different types of</A><B> Up:</B> <A NAME="tex2html2357" HREF="node64.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node64.html">7. Queue Management and</A><B> Previous:</B> <A NAME="tex2html2351" HREF="node67.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node67.html">7.1.2 PacketQueue Class</A>   <B> <A NAME="tex2html2359" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html2361" 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="SECTION03420000000000000000"></A><A NAME="sec:droptail"></A><BR>7.2 Example: Drop Tail</H1><P>The following example illustrates the implementation of the<TT>Queue/DropTail</TT> object,which implements FIFO scheduling anddrop-on-overflow buffer management typical of most present-dayInternet routers.The following definitions declare the class and its OTcl linkage:<PRE> /* * A bounded, drop-tail queue */ class DropTail : public Queue { protected: void enque(Packet*); Packet* deque(); PacketQueue q_; };</PRE>The base class <TT>Queue</TT>,from which <TT>DropTail</TT> is derived, provides mostof the needed functionality.The drop-tail queue maintains exactly one FIFO queue, implementedby including an object of the <TT>PacketQueue</TT> class.Drop-tail implements its own versions of <TT>enque</TT> and <TT>deque</TT>as follows:<PRE> /* * drop-tail */ void DropTail::enque(Packet* p) { q_.enque(p); if (q_.length() \>= qlim_) { q_.remove(p); drop(p); } } Packet* DropTail::deque() { return (q_.deque()); }</PRE>Here, the <TT>enque</TT> function first stores the packet in theinternal packet queue (which has no size restrictions), and thenchecks the size of the packet queue versus <TT>qlim_</TT>.Drop-on-overflow is implemented by dropping the packet most recentlyadded to the packet queue if the limit is reached or exceeded.<I>Note:</I> in the implementation of <TT>enque</TT> above, setting <TT>qlim_</TT> to <TT>n</TT> actually means a queue size of <TT>n-1</TT>.Simple FIFO scheduling is implemented in the <TT>deque</TT> functionby always returning the first packet in the packet queue.<P><HR><!--Navigation Panel--><A NAME="tex2html2362" HREF="node69.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node69.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2356" HREF="node64.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node64.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2350" HREF="node67.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node67.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2358" 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="tex2html2360" 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="tex2html2363" HREF="node69.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node69.html">7.3 Different types of</A><B> Up:</B> <A NAME="tex2html2357" HREF="node64.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node64.html">7. Queue Management and</A><B> Previous:</B> <A NAME="tex2html2351" HREF="node67.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node67.html">7.1.2 PacketQueue Class</A>   <B> <A NAME="tex2html2359" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html2361" 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 + -