⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node47.html

📁 相关搜索: ns2仿真结果分析 all-awk ns2 ns2 无限网络中awk文件 ... [2.tcl.rar] - 在ns2平台上实现对AODV协议的模拟
💻 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 The Classifier</TITLE><META NAME="description" CONTENT="5.4 The Classifier"><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="node53.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node53.html"><LINK REL="previous" HREF="node46.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node46.html"><LINK REL="up" HREF="node39.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node39.html"><LINK REL="next" HREF="node48.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node48.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html2040"  HREF="node48.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node48.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2034"  HREF="node39.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node39.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2028"  HREF="node46.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node46.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2036"  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="tex2html2038"  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="tex2html2041"  HREF="node48.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node48.html">5.4.1 Address Classifiers</A><B> Up:</B> <A NAME="tex2html2035"  HREF="node39.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node39.html">5. Nodes and Packet</A><B> Previous:</B> <A NAME="tex2html2029"  HREF="node46.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node46.html">5.3 Node Configuration Interface</A> &nbsp <B>  <A NAME="tex2html2037"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html2039"  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="SECTION03240000000000000000"></A><A NAME="sec:node:classifiers"></A><BR>5.4 The Classifier</H1><P>The function of a node when it receives a packet is to examinethe packet's fields, usually its destination address, andon occasion, its source address.It should then map the values to an outgoing interface objectthat is the next downstream recipient of this packet.<P>In , this task is performed by a simple <I>classifier</I> object.Multiple classifier objects,each looking at a specific portion of the packetforward the packet through the node.A node in  uses many different types of classifiers for different purposes.This section describes some of the more common, or simpler,classifier objects in .<P>We begin with a description of the base class in this section.The next subsections describethe address classifierSectionsec:node:addr-classifier,the multicast classifierSectionsec:node:mcast-classifier,the multipath classifierSectionsec:node:mpath-classifier, the hash classifierSectionsec:node:hash-classifier, andfinally, the replicatorSectionsec:node:replicator.<P>A classifier provides a way to match a packet against somelogical criteria and retrieve a reference to another simulationobject based on the match results.Each classifier contains a table of simulation objects indexedby <EM>slot number</EM>.The job of a classifier is to determine the slot number associatedwith a received packet and forward that packet to theobject referenced by that particular slot.The C++ Classifier../ns-2/classifier.h(defined in classifier.h)provides a base class from which other classifiers are derived.<PRE>        class Classifier : public NsObject {        public:                ~Classifier();                void recv(Packet*, Handler* h = 0);         protected:                Classifier();                void install(int slot, NsObject*);                void clear(int slot);                virtual int command(int argc, const char*const* argv);                virtual int classify(Packet *const) = 0;                void alloc(int);                NsObject** slot_;       /* table that maps slot number to a NsObject /                int nslot_;                int maxslot_;        };</PRE>The []classify method is pure virtual, indicating theclass <TT>Classifier</TT> is to be used only as a base class.The []alloc method dynamically allocates enough spacein the table to hold the specified number of slots.The []install and []clear methodsadd or remove objects from the table.The []recv method and the OTcl interface are implementedas follows in classifier.cc:<PRE>        /*         *objects only ever see "packet" events, which come either         *from an incoming link or a local agent (i.e., packet source).         */        void Classifier::recv(Packet* p, Handler*)        {                NsObject* node;                int cl = classify(p);                if (cl \&lt; 0 || cl \&gt;= nslot_ || (node = slot_[cl]) == 0) {                        Tcl::instance().evalf("%s no-slot %d", name(), cl);                        Packet::free(p);                        return;                }                node-\&gt;recv(p);        }        int Classifier::command(int argc, const char*const* argv)        {                Tcl&amp; tcl = Tcl::instance();                if (argc == 3) {                        /*                         * $classifier clear $slot                         */                        if (strcmp(argv[1], "clear") == 0) {                                int slot = atoi(argv[2]);                                clear(slot);                                return (TCL_OK);                        }                        /*                         * $classifier installNext $node                         */                        if (strcmp(argv[1], "installNext") == 0) {                                int slot = maxslot_ + 1;                                NsObject* node = (NsObject*)TclObject::lookup(argv[2]);                                install(slot, node);                                tcl.resultf("%u", slot);                                return TCL_OK;                        }                        if (strcmp(argv[1], "slot") == 0) {                                int slot = atoi(argv[2]);                                if ((slot \&gt;= 0) || (slot \&lt; nslot_)) {                                        tcl.resultf("%s", slot_[slot]-\&gt;name());                                        return TCL_OK;                                }                                tcl.resultf("Classifier: no object at slot %d", slot);                                return (TCL_ERROR);                        }                } else if (argc == 4) {                        /*                         * $classifier install $slot $node                         */                        if (strcmp(argv[1], "install") == 0) {                                int slot = atoi(argv[2]);                                NsObject* node = (NsObject*)TclObject::lookup(argv[3]);                                install(slot, node);                                return (TCL_OK);                        }                }                return (NsObject::command(argc, argv));        }</PRE> When a classifier []recv's a packet,it hands it to the []classify method.This is defined differently in each type of classifierderived from the base class.The usual format is for the []classify method todetermine and return a slot index into the table of slots.If the index is valid, and points to a valid TclObject,the classifier will hand the packet to that object using that object's []recv method.If the index is not valid, the classifier will invokethe instance procedure []no-slot to attempt to populate the table correctly.However, in the base class []Classifier::no-slot printsand error message and terminates execution.<P>The []command method../ns-2/classifier.ccClassifier::commandprovides the following instproc-likes to the interpreter:<UL><LI>[slot]clear clears the entry in a particular slot.</LI><LI>[object]installNext installs the object        in the next available slot, and returns the slot number.<P>Note that this instproc-like is         overloaded by an instance procedure of the same name../ns-2/ns-lib.tclClassifier::installNext        that stores a reference to the object stored.        This then helps quick query of the objects        installed in the classifier from OTcl.</LI><LI>[index]slot returns the object stored in the specified slot.</LI><LI>[index, object]install installs the specified        object at the slot index.<P>Note that this instproc-like too is         overloaded by an instance procedure of the same name../ns-2/ns-lib.tclClassifier::install        that stores a reference to the object stored.        This is also to quickly query of the objects        installed in the classifier from OTcl.</LI></UL><P><BR><HR><!--Table of Child-Links--><A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A><UL><LI><A NAME="tex2html2042"  HREF="node48.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node48.html">5.4.1 Address Classifiers</A><LI><A NAME="tex2html2043"  HREF="node49.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node49.html">5.4.2 Multicast Classifiers</A><LI><A NAME="tex2html2044"  HREF="node50.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node50.html">5.4.3 MultiPath Classifier</A><LI><A NAME="tex2html2045"  HREF="node51.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node51.html">5.4.4 Hash Classifier</A><LI><A NAME="tex2html2046"  HREF="node52.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node52.html">5.4.5 Replicator</A></UL><!--End of Table of Child-Links--><HR><!--Navigation Panel--><A NAME="tex2html2040"  HREF="node48.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node48.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2034"  HREF="node39.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node39.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html2028"  HREF="node46.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node46.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2036"  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="tex2html2038"  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="tex2html2041"  HREF="node48.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node48.html">5.4.1 Address Classifiers</A><B> Up:</B> <A NAME="tex2html2035"  HREF="node39.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node39.html">5. Nodes and Packet</A><B> Previous:</B> <A NAME="tex2html2029"  HREF="node46.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node46.html">5.3 Node Configuration Interface</A> &nbsp <B>  <A NAME="tex2html2037"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html2039"  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 + -