📄 node138.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>13.1 Implementation</TITLE><META NAME="description" CONTENT="13.1 Implementation"><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="node139.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node139.html"><LINK REL="previous" HREF="node137.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node137.html"><LINK REL="up" HREF="node137.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node137.html"><LINK REL="next" HREF="node139.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node139.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html3404" HREF="node139.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node139.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html3398" HREF="node137.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node137.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html3392" HREF="node137.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node137.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html3400" 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="tex2html3402" 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="tex2html3405" HREF="node139.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node139.html">13.2 Configuration</A><B> Up:</B> <A NAME="tex2html3399" HREF="node137.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node137.html">13. Error Model</A><B> Previous:</B> <A NAME="tex2html3393" HREF="node137.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node137.html">13. Error Model</A>   <B> <A NAME="tex2html3401" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html3403" 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="SECTION031010000000000000000">13.1 Implementation</A></H1><P>The procedures and functions described in this section can be found inerrmodel.{cc, h}.<P>Error model simulates link-level errors or loss by either marking thepacket's error flag or dumping the packet to a drop target. Insimulations, errors can be generated from a simple model such as thepacket error rate, or from more complicated statistical and empirical models.To support a wide variety of models, the unit of error can be specifiedin term of packet, bits, or time-based.<P>The <TT>ErrorModel</TT> class is derived from the <TT>Connector</TT> baseclass. As the result, it inherits some methods for hooking up objectssuch as <TT>target</TT> and <TT>drop-target</TT>. If the drop targetexists, it will received corrupted packets from <TT>ErrorModel</TT>.Otherwise, <TT>ErrorModel</TT> just marks the <TT>error_</TT> flag of thepacket's common header, thereby, allowing agents to handle the loss.The <TT>ErrorModel</TT> also defines additional Tcl method <TT>unit</TT> tospecify the unit of error and <TT>ranvar</TT> to specify the randomvariable for generating errors. If not specified, the unit of errorwill be in packets, and the random variable will be uniform distributedfrom 0 to 1. Below is a simple example of creating an error model withthe packet error rate of 1 percent (0.01):<PRE> # create a loss_module and set its packet error rate to 1 percent set loss_module [new ErrorModel] \$loss_module set rate_ 0.01 # optional: set the unit and random variable \$loss_module unit pkt # error unit: packets (the default); \$loss_module ranvar [new RandomVariable/Uniform] # set target for dropped packets \$loss_module drop-target [new Agent/Null]</PRE><P>In C++, the <TT>ErrorModel</TT> contains both the mechanism and policy fordropping packets. The packet dropping mechanism is handled by the<TT>recv</TT> method, and packet corrupting policy is handled by the<TT>corrupt</TT> method.<PRE> enum ErrorUnit { EU_PKT=0, EU_BIT, EU_TIME }; class ErrorModel : public Connector { public: ErrorModel(); void recv(Packet*, Handler*); virtual int corrupt(Packet*); inline double rate() { return rate_; } protected: int command(int argc, const char*const* argv); ErrorUnit eu_; /* error unit in pkt, bit, or time / RandomVariable* ranvar_; double rate_; };</PRE>The <TT>ErrorModel</TT> only implements a simple policy based on a singleerror rate, either in packets of bits. More sophisticated droppingpolicy can be implemented in C++ by deriving from <TT>ErrorModel</TT> andredefining its <TT>corrupt</TT> method.<P><HR><!--Navigation Panel--><A NAME="tex2html3404" HREF="node139.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node139.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html3398" HREF="node137.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node137.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html3392" HREF="node137.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node137.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html3400" 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="tex2html3402" 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="tex2html3405" HREF="node139.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node139.html">13.2 Configuration</A><B> Up:</B> <A NAME="tex2html3399" HREF="node137.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node137.html">13. Error Model</A><B> Previous:</B> <A NAME="tex2html3393" HREF="node137.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node137.html">13. Error Model</A>   <B> <A NAME="tex2html3401" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html3403" 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 + -