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

📄 node124.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>11.1.2 Example: Tcp retransmission timer</TITLE><META NAME="description" CONTENT="11.1.2 Example: Tcp retransmission timer"><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="previous" HREF="node123.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node123.html"><LINK REL="up" HREF="node122.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node122.html"><LINK REL="next" HREF="node125.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node125.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html3197"  HREF="node125.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node125.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html3191"  HREF="node122.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node122.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html3187"  HREF="node123.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node123.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html3193"  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="tex2html3195"  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="tex2html3198"  HREF="node125.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node125.html">11.2 OTcl Timer class</A><B> Up:</B> <A NAME="tex2html3192"  HREF="node122.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node122.html">11.1 C++ abstract base</A><B> Previous:</B> <A NAME="tex2html3188"  HREF="node123.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node123.html">11.1.1 Definition of a</A> &nbsp <B>  <A NAME="tex2html3194"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html3196"  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="SECTION03812000000000000000"></A><A NAME="sec:timerexample"></A><BR>11.1.2 Example: Tcp retransmission timer</H2><P>TCP is an example of an agent which requires timers.  There are three timersdefined in the basic Tahoe TCP agent defined in <TT>tcp.cc</TT>:<PRE>        rtx_timer_;      /*  Retransmission timer /        delsnd_timer_;   /*  Delays sending of packets by a small random amount of time, /                        /* to avoid phase effects /        burstsnd_timer_;   /* Helps TCP to stagger the transmission of a large window /                                /* into several smaller bursts /</PRE>In tcp.h, three classes are derived from the base classTimerHandlertcp.h:<PRE>        class RtxTimer : public TimerHandler {        public:            RtxTimer(TcpAgent *a) : TimerHandler() { a_ = a; }        protected:                               virtual void expire(Event *e);            TcpAgent *a_;        };                      class DelSndTimer : public TimerHandler {        public:            DelSndTimer(TcpAgent *a) : TimerHandler() { a_ = a; }        protected:            virtual void expire(Event *e);            TcpAgent *a_;        };                  class BurstSndTimer : public TimerHandler {        public:             BurstSndTimer(TcpAgent *a) : TimerHandler() { a_ = a; }        protected:            virtual void expire(Event *e);             TcpAgent *a_;        };</PRE>Inthe constructor for TcpAgent../ns-2/tcp.ccTcpAgent::TcpAgentin <TT>tcp.cc</TT>,each of these timersis initialized with the <TT>this</TT> pointer,which is assigned to the pointer <TT>a_</TT>.<PRE>        TcpAgent::TcpAgent() : Agent(PT_TCP), rtt_active_(0), rtt_seq_(-1),             \ldots            rtx_timer_(this), delsnd_timer_(this), burstsnd_timer_(this)        {            \ldots        }</PRE>In the following, we will focus only on the retransmission timer.  Varioushelper methods may be defined to schedule timer events; ,<PRE>        /*         *Set retransmit timer using current rtt estimate.  By calling \fcn[]{resched}         *it does not matter whether the timer was already running.         */        void TcpAgent::set_rtx_timer()        {            rtx_timer_.resched(rtt_timeout());        }        /*         * Set new retransmission timer if not all outstanding         * data has been acked.  Otherwise, if a timer is still         * outstanding, cancel it.         */        void TcpAgent::newtimer(Packet* pkt)        {            hdr_tcp *tcph = (hdr_tcp*)pkt-\&gt;access(off_tcp_);            if (t_seqno_ \&gt; tcph-\&gt;seqno())                set_rtx_timer();            else if (rtx_timer_.status() == TIMER_PENDING)                rtx_timer_.cancel();        }</PRE>In the above code, the []set_rtx_timer method reschedules the retransmission timer by calling []rtx_timer_.resched.  Note that ifit is unclear whether or not the timer is already running, calling[]resched eliminates the need to explicitly cancel the timer.  Inthe second function, examples are given of the use of the []statusand cancel methods.<P>Finally, the expire method for class <TT>RtxTimer</TT> must be defined.  In this case, expire calls the timeout methodfor <TT>TcpAgent</TT>.  This is possible because []timeout is a public member function; if it were not, then <TT>RtxTimer</TT> would havehad to have been declared a friend class of <TT>TcpAgent</TT>.<PRE>void TcpAgent::timeout(int tno){                         /* retransmit timer */    if (tno == TCP_TIMER_RTX) {        if (highest_ack_ == maxseq_ &amp;&amp; !slow_start_restart_) {            /*             * TCP option:             * If no outstanding data, then don't do anything.             */            return;          };        recover_ = maxseq_;        recover_cause_ = 2;        closecwnd(0);        reset_rtx_timer(0,1);        send_much(0, TCP_REASON_TIMEOUT, maxburst_);     } else {        /*          * delayed-send timer, with random overhead         * to avoid phase effects           */             send_much(1, TCP_REASON_TIMEOUT, maxburst_);    }           }                       void RtxTimer::expire(Event *e) {    a_-\&gt;timeout(TCP_TIMER_RTX);}</PRE><P>The various TCP agents contain additional examples of timers.<P><HR><!--Navigation Panel--><A NAME="tex2html3197"  HREF="node125.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node125.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html3191"  HREF="node122.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node122.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html3187"  HREF="node123.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node123.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html3193"  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="tex2html3195"  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="tex2html3198"  HREF="node125.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node125.html">11.2 OTcl Timer class</A><B> Up:</B> <A NAME="tex2html3192"  HREF="node122.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node122.html">11.1 C++ abstract base</A><B> Previous:</B> <A NAME="tex2html3188"  HREF="node123.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node123.html">11.1.1 Definition of a</A> &nbsp <B>  <A NAME="tex2html3194"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html3196"  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 + -