📄 node109.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>10.5.2 Starting the Agent</TITLE><META NAME="description" CONTENT="10.5.2 Starting the Agent"><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="node110.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node110.html"><LINK REL="previous" HREF="node108.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node108.html"><LINK REL="up" HREF="node107.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node107.html"><LINK REL="next" HREF="node110.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node110.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html2984" HREF="node110.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node110.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2978" HREF="node107.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node107.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2972" HREF="node108.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node108.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2980" 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="tex2html2982" 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="tex2html2985" HREF="node110.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node110.html">10.5.3 Processing Input at</A><B> Up:</B> <A NAME="tex2html2979" HREF="node107.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node107.html">10.5 Examples: Tcp, TCP</A><B> Previous:</B> <A NAME="tex2html2973" HREF="node108.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node108.html">10.5.1 Creating the Agent</A>   <B> <A NAME="tex2html2981" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html2983" 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="SECTION03752000000000000000"></A><A NAME="sec:starttcp"></A><BR>10.5.2 Starting the Agent</H2><P>The <TT>TcpAgent</TT> agent is started in the example when itsFTP source receives the <TT>start</TT> directive at time 1.2.The <TT>start</TT> operation is an instance procedure defined on theclass Application/FTPSectionsec:simapps.It is defined in tcl/lib/ns-source.tcl as follows:<PRE> Application/FTP instproc start {} { [$self agent] send -1 }</PRE>In this case, <TT>agent</TT> refers to our simple TCP agent and<TT>send -1</TT> is analogous to sending an arbitrarily large file.<P>The call to <TT>send</TT> eventually results in the simple TCP sendergenerating packets.The following function <TT>output</TT> performs this:<PRE> void TcpAgent::output(int seqno, int reason) { Packet* p = allocpkt(); hdr_tcp *tcph = (hdr_tcp*)p-\>access(off_tcp_); double now = Scheduler::instance().clock(); tcph-\>seqno() = seqno; tcph-\>ts() = now; tcph-\>reason() = reason; Connector::send(p, 0); \ldots if (!(rtx_timer_.status() == TIMER_PENDING)) /* No timer pending. Schedule one. */ set_rtx_timer(); }</PRE>Here we see an illustration of the use of the []Agent::allocpkt method.This output routine first allocates a new packet(with its common and IP headers already filled in), but then must fillin the appropriate TCP-layer header fields.To find the TCP header in a packet (assuming it has been enabledSectionsec:packethdrmgr)the <TT>off_tcp_</TT> must be properly initialized,as illustrated in the constructor.The packet []access method returns a pointer to the TCP header,its sequence number and time stamp fields are filled in,and the []send method of the class Connector is calledto send the packet downstream one hop.Note that the C++ <TT>::</TT> scoping operator is used here to avoidcalling []TcpSimpleAgent::send (which is also defined).The check for a pending timer uses the timer method []status whichis defined in the base class TimerHandler.It is used here to set a retransmission timer if one is not already set(a TCP sender only sets one timer per window of packets on each connection).<P><HR><!--Navigation Panel--><A NAME="tex2html2984" HREF="node110.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node110.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2978" HREF="node107.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node107.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2972" HREF="node108.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node108.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2980" 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="tex2html2982" 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="tex2html2985" HREF="node110.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node110.html">10.5.3 Processing Input at</A><B> Up:</B> <A NAME="tex2html2979" HREF="node107.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node107.html">10.5 Examples: Tcp, TCP</A><B> Previous:</B> <A NAME="tex2html2973" HREF="node108.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node108.html">10.5.1 Creating the Agent</A>   <B> <A NAME="tex2html2981" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html2983" 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 + -