📄 node52.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>5.4.5 Replicator</TITLE><META NAME="description" CONTENT="5.4.5 Replicator"><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="node51.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node51.html"><LINK REL="up" HREF="node47.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node47.html"><LINK REL="next" HREF="node53.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node53.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html2113" HREF="node53.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node53.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2107" HREF="node47.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node47.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2103" HREF="node51.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node51.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2109" 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="tex2html2111" 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="tex2html2114" HREF="node53.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node53.html">5.5 Routing Module and</A><B> Up:</B> <A NAME="tex2html2108" HREF="node47.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node47.html">5.4 The Classifier</A><B> Previous:</B> <A NAME="tex2html2104" HREF="node51.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node51.html">5.4.4 Hash Classifier</A>   <B> <A NAME="tex2html2110" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html2112" 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="SECTION03245000000000000000"></A><A NAME="sec:node:replicator"></A><BR>5.4.5 Replicator</H2><P>The replicator is different from the other classifierswe have described earlier,in that it does not use the classify function.Rather, it simply uses the classifier as a table of slots;it overloads the []recv method to produce copiesof a packet, that are delivered to all objects referenced in the table.<P>To support multicast packet forwarding, a classifier receiving amulticast packet from source destined for group computes a hash function givinga ``slot number'' in the classifier's object table.In multicast delivery, the packet must be copied once foreach link leading to nodes subscribed to minus one.Production of additional copies of the packet is performedby a <TT>Replicator</TT> class, defined in <TT>replicator.cc</TT>:<PRE> /* * A replicator is not really a packet classifier but * we simply find convenience in leveraging its slot table. * (this object used to implement fan-out on a multicast * router as well as broadcast LANs) */ class Replicator : public Classifier { public: Replicator(); void recv(Packet*, Handler* h = 0); virtual int classify(Packet* const) {}; protected: int ignore_; }; void Replicator::recv(Packet* p, Handler*) { IPHeader *iph = IPHeader::access(p-\>bits()); if (maxslot_ \< 0) { if (!ignore_) Tcl::instance().evalf("%s drop %u %u", name(), iph-\>src(), iph-\>dst()); Packet::free(p); return; } for (int i = 0; i \< maxslot_; ++i) { NsObject* o = slot_[i]; if (o != 0) o-\>recv(p-\>copy()); } /* we know that maxslot is non-null */ slot_[maxslot_]-\>recv(p); }</PRE>As we can see from the code,this class does not really classify packets.Rather, it replicates a packet, one for each entry in its table,and delivers the copies to each of the nodes listed in the table.The last entry in the table gets the ``original'' packet.Since the []classify method is pure virtual in the base class,the replicator defines an empty []classify method.<P><HR><!--Navigation Panel--><A NAME="tex2html2113" HREF="node53.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node53.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2107" HREF="node47.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node47.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2103" HREF="node51.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node51.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2109" 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="tex2html2111" 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="tex2html2114" HREF="node53.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node53.html">5.5 Routing Module and</A><B> Up:</B> <A NAME="tex2html2108" HREF="node47.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node47.html">5.4 The Classifier</A><B> Previous:</B> <A NAME="tex2html2104" HREF="node51.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node51.html">5.4.4 Hash Classifier</A>   <B> <A NAME="tex2html2110" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html2112" 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 + -