📄 node269.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>23.3 The C++ Trace Class</TITLE><META NAME="description" CONTENT="23.3 The C++ Trace 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="node270.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node270.html"><LINK REL="previous" HREF="node268.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node268.html"><LINK REL="up" HREF="node265.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node265.html"><LINK REL="next" HREF="node270.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node270.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html5429" HREF="node270.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node270.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html5423" HREF="node265.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node265.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html5417" HREF="node268.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node268.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html5425" 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="tex2html5427" 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="tex2html5430" HREF="node270.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node270.html">23.4 Trace File Format</A><B> Up:</B> <A NAME="tex2html5424" HREF="node265.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node265.html">23. Trace and Monitoring</A><B> Previous:</B> <A NAME="tex2html5418" HREF="node268.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node268.html">23.2 Library support and</A>   <B> <A NAME="tex2html5426" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html5428" 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="SECTION04330000000000000000"></A><A NAME="sec:tracemoncplus"></A><BR>23.3 The C++ Trace Class</H1><P>Underlying C++ objects are created in support of the interface specifiedin Section <A HREF="node269.html#sec:tracemoncplus" tppabs="http://www.isi.edu/nsnam/ns/doc/node269.html#sec:tracemoncplus">23.3</A> and are linked into the network topologyas network elements.The single C++ <TT>Trace</TT> class is used to implement the OTclclasses <TT>Trace/Hop</TT>, <TT>Trace/Enque</TT>, <TT>Trace/Deque</TT>,and <TT>Trace/Drop</TT>.The <TT>type<BR>_</TT> field is used to differentiate among thevarious types oftraces any particular <TT>Trace</TT> object might implement.Currently, this field may contain one of the following symbolic characters:<B>+</B> for enque, <B>-</B> for deque, <B>h</B> for hop, and<B>d</B> for drop.The overall class is defined as follows in trace.cc:<PRE> class Trace : public Connector { protected: int type_; nsaddr_t src_; nsaddr_t dst_; Tcl_Channel channel_; int callback_; char wrk_[256]; void format(int tt, int s, int d, Packet* p); void annotate(const char* s); int show_tcphdr_; // bool flags; backward compat public: Trace(int type); ~Trace(); int command(int argc, const char*const* argv); void recv(Packet* p, Handler*); void dump(); inline char* buffer() { return (wrk_); } };</PRE>The <TT>src<BR>_</TT>, and <TT>dst<BR>_</TT> internal state is usedto label trace output and is independent of the corresponding fieldnames in packet headers.The main []recv method is defined as follows:<PRE> void Trace::recv(Packet* p, Handler* h) { format(type_, src_, dst_, p); dump(); /* hack: if trace object not attached to anything free packet */ if (target_ == 0) Packet::free(p); else send(p, h); /* \fcn[]{Connector::send} */ }</PRE>The function merely formats a trace entry using the source, destination,and particular trace type character.The <TT>dump</TT> function writes the formatted entry out to theI/O handle associated with <TT>channel<BR>_</TT>.The <TT>format</TT> function, in effect, dictates the trace file format.<P><HR><!--Navigation Panel--><A NAME="tex2html5429" HREF="node270.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node270.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html5423" HREF="node265.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node265.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html5417" HREF="node268.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node268.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html5425" 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="tex2html5427" 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="tex2html5430" HREF="node270.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node270.html">23.4 Trace File Format</A><B> Up:</B> <A NAME="tex2html5424" HREF="node265.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node265.html">23. Trace and Monitoring</A><B> Previous:</B> <A NAME="tex2html5418" HREF="node268.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node268.html">23.2 Library support and</A>   <B> <A NAME="tex2html5426" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html5428" 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 + -