📄 node89.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>8.1 The LinkDelay Class</TITLE><META NAME="description" CONTENT="8.1 The LinkDelay Class"><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="node90.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node90.html"><LINK REL="previous" HREF="node88.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node88.html"><LINK REL="up" HREF="node88.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node88.html"><LINK REL="next" HREF="node90.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node90.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html2673" HREF="node90.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node90.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2667" HREF="node88.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node88.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2661" HREF="node88.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node88.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2669" 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="tex2html2671" 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="tex2html2674" HREF="node90.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node90.html">8.2 Commands at a</A><B> Up:</B> <A NAME="tex2html2668" HREF="node88.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node88.html">8. Delays and Links</A><B> Previous:</B> <A NAME="tex2html2662" HREF="node88.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node88.html">8. Delays and Links</A>   <B> <A NAME="tex2html2670" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html2672" 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="SECTION03510000000000000000"></A><A NAME="sec:delayclass"></A><BR>8.1 The LinkDelay Class</H1><P>The LinkDelay../ns-2/delay.cc is derived from thebase Connector../ns-2/connector.h.Its definition is in delay.cc, and is briefly excerpted below:<PRE> class LinkDelay : public Connector { public: LinkDelay(); void recv(Packet* p, Handler*); void send(Packet* p, Handler*); void handle(Event* e); double delay(); /* line latency on this link / double bandwidth(); /* bandwidth on this link / inline double txtime(Packet* p) { /* time to send pkt p on this link / hdr_cmn* hdr = (hdr_cmn*) p-\>access(off_cmn_); return (hdr-\>size() * 8. / bandwidth_); } protected: double bandwidth_; /* bandwidth of underlying link (bits/sec) / double delay_; /* line latency / int dynamic_; /* indicates whether or not link is ~ / Event inTransit_; PacketQueue* itq_; /* internal packet queue for dynamic links / Packet* nextPacket_; /* to be delivered for a dynamic link. / Event intr_; };</PRE>The []recv method../ns-2/delay.ccDelayLink::recvoverrides the baseclass Connector../ns-2/connector.ccConnector::recv version.It is defined as follows:<PRE> void LinkDelay::recv(Packet* p, Handler* h) { double txt = txtime(p); Scheduler& s = Scheduler::instance(); if (dynamic_) { Event* e = (Event*)p; e-\>time_ = s.clock() + txt + delay_; itq_-\>enque(p); schedule_next(); } else { s.schedule(target_, p, txt + delay_); } /*XXX only need one intr_ since upstream object should * block until it's handler is called * * This only holds if the link is not dynamic. If it is, then * the link itself will hold the packet, and call the upstream * object at the appropriate time. This second interrupt is * called {\tt inTransit\_}, and is invoked through \fcn[]{schedule_next} */ s.schedule(h, &intr_, txt); }</PRE>This object supports one instproc-like../ns-2/delay.ccLinkDelay::command,<TT>$object dynamic</TT>,to set its variable, <TT>dynamic_</TT>. This variable determines whether the link is dynamic or not (, proneto fail/recover at appropriate times).The internal behavior of the link in each case is different.<P>For ``non-dynamic'' links,this method operates by receiving a packet, , and scheduling twoevents.Assume these two events are called and , and thatevent is scheduled to occur before . is scheduled to occur when the upstream node attached to thisdelay element has completed sending the current packet(which takes time equal to the packet size divided by the link bandwidth). is usually associated with a <TT>Queue</TT> object, and willcause it to (possibly) become unblocked (see section <A HREF="node66.html#sec:qblock" tppabs="http://www.isi.edu/nsnam/ns/doc/node66.html#sec:qblock">7.1.1</A>). represents the packet arrival event at the downstream neighborof the delay element.Event occurs a number of seconds later than equal to thelink delay.<P>Alternately, when the link is dynamic, and receives , thenit will schedule to possibly unblock the queue at theappropriate time.However, is scheduled onlyif is the only packet currently in transit.Otherwise, there is at least one packet in transit on the link that mustbe delivered before at .Therefore, packet is held in the object's inTransit queue, <TT>itq_</TT>.When the packet just before in transit on the link is deliveredat the neighbor node, the DelayLink object will schedule an event for itself to fire at .At that appropriate time then, it's []handle method../ns-2/delay.ccLinkDelay::handlewill directly send to its target.The object's internal[]schedule_next method../ns-2/delay.hLinkDelay::schedule_next will schedule these events for packet sin transit at the appropriate time.<P><HR><!--Navigation Panel--><A NAME="tex2html2673" HREF="node90.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node90.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2667" HREF="node88.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node88.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2661" HREF="node88.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node88.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2669" 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="tex2html2671" 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="tex2html2674" HREF="node90.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node90.html">8.2 Commands at a</A><B> Up:</B> <A NAME="tex2html2668" HREF="node88.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node88.html">8. Delays and Links</A><B> Previous:</B> <A NAME="tex2html2662" HREF="node88.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node88.html">8. Delays and Links</A>   <B> <A NAME="tex2html2670" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html2672" 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 + -