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

📄 nodes.tex

📁 柯老师网站上找到的
💻 TEX
📖 第 1 页 / 共 3 页
字号:
{\sf NodeMask} values, respectively.  These values are retrievedfrom the {\tt AddrParams} object when the hash classifier isinstantiated.  The hash classifier will fail to operate properly ifthe {\tt AddrParams} structure is not initialized.The following constructors are used for the various hash classifiers:\begin{program}        Classifier/Hash/SrcDest        Classifier/Hash/Dest        Classifier/Hash/Fid        Classifier/Hash/SrcDestFid\end{program}The hash classifier receives packets, classifies them accordingto their flow criteria, and retrieves the classifier {\em slot}indicating the next node that should receive the packet.In several circumstances with hash classifiers, most packets shouldbe associated with a single slot, while only a few flows shouldbe directed elsewhere. The hash classifier includes a \code{default_} instance variableindicating which slot is to be used for packets that do not matchany of the per-flow criteria.The \code{default_} may be set optionally.The methods for a hash classifier are as follows:\begin{program}        $hashcl set-hash buck src dst fid slot        $hashcl lookup buck src dst fid        $hashcl del-hash src dst fid        $hashcl resize nbuck\end{program}The \fcn[]{set-hash} method inserts a new entry into the hashtable within the hash classifier.The {\tt buck} argument specifies the hash table bucket numberto use for the insertion of this entry.When the bucket number is not known, {\tt buck} may be specifiedas {\tt auto}. The {\tt src, dst} and {\tt fid} arguments specify the IP source,destination, and flow IDs to be matched for flow classification.Fields not used by a particular classifier (e.g. specifying {\tt src}flor a flow-id classifier) is ignored.The {\tt slot} argument indicates the index into the underlyingslot table in the base {\tt Classifier} object from whichthe hash classifier is derived.The {\tt lookup} function returns the name of the objectassociated with the given {\tt buck/src/dst/fid} tuple.The {\tt buck} argument may be {\tt auto}, as for {\tt set-hash}.The {\tt del-hash} function removes the specified entry fromthe hash table.Currently, this is done by simply marking the entry as inactive,so it is possible to populate the hash table with unused entries.The {\tt resize} function resizes the hash table to includethe number of buckets specified by the argument {\tt nbuck}.Provided no default is defined, a hash classifier willperform a call into OTcl when itreceives a packet which matches no flow criteria.The call takes the following form:\begin{program}        \$obj unknown-flow src dst flowid buck\end{program} Thus, when a packet matching no flow criteria is received,the method {\tt unknown-flow} of the instantiated hash classifierobject is invoked with the source, destination, and flow idfields from the packet.In addition, the {\tt buck} field indicates the hash bucketwhich should contain this flow if it were inserted using{\tt set-hash}.  This arrangement avoids another hashlookup when performing insertions into the classifier when thebucket is already known.\subsection{Replicator}\label{sec:node:replicator}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 $n$ slots;it overloads the \fcn[]{recv} method to produce $n$ copiesof a packet, that are delivered to all $n$ objects referenced in the table.To support multicast packet forwarding, a classifier receiving amulticast packet from source $S$destined for group $G$ computes a hash function $h(S,G)$ givinga ``slot number'' in the classifier's object table.%Thus, the maximum size of the table is $O(|S|\times|G|)$.In multicast delivery, the packet must be copied once foreach link leading to nodes subscribed to $G$ minus one.Production of additional copies of the packet is performedby a \code{Replicator} class, defined in \code{replicator.cc}:\begin{program}        /*         * {\cf A replicator is not really a packet classifier but}         * {\cf we simply find convenience in leveraging its slot table.}         * {\cf (this object used to implement fan-out on a multicast}         * {\cf 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());                \}                /* {\cf we know that maxslot is non-null} */                slot_[maxslot_]->recv(p);        \}\end{program}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 \fcn[]{classify} method is pure virtual in the base class,the replicator defines an empty \fcn[]{classify} method.\clearpage\section{Commands at a glance}\label{sec:nodescommand}\begin{flushleft}Following is a list of common node commands used in simulation scripts:\code{$ns_ node}\\Command to create a simple node. This returns a handle to the node instancecreated.\code{$ns_ node <hierarchical address>}\\Command to create a node with hierarchical addressing/routing. This too returnsa handle to the hier-node instance.\code{$ns_ node-config <-option> <value>}\\This command is a part of the new Node APIs and sets up configuration for agiven node type. Note that this command has to be called before creation ofthe nodes. The default value (i.e if node-config is not called) sets upconfiguration for a simple node with flat addressing/routing. The detailson different <options> and their available <values> that can be used toconfigure a node can be found in chapter titled "Restructuring ns nodeand new Node APIs" in ns Notes and Documentation. \code{$node id}\\Returns the id number of the node.\code{$node node-addr}\\Returns the address of the node. In case of flat addressing, the node addressis same as its node-id. In case of hierarchical addressing, the node addressin the form of a string (viz. "1.4.3") is returned.\code{$node reset}\\Resets all agent attached to this node.\code{$node agent <port_num>}\\Returns the handle of the agent at the specified port. If no agent is foundat the given port, a null string is returned.\code{$node entry}\\Returns the entry point for the node. This is first object that handles packetreceiving at this node.\code{$node attach <agent> <optional:port_num>}\\Attaches the <agent> to this node. Incase no specific port number is passed,the node allocates a port number and binds the agent to this port. Thus oncethe agent is attached, it receives packets destined for this host (node) and port.\code{$node detach <agent> <null_agent>}\\This is the dual of "attach" described above. It detaches the agent from this nodeand installs a null-agent to the port this agent was attached. This is done tohandle transit packets that may be destined to the detached agent. These on-the-flypkts are then sinked  at the null-agent.\code{$node neighbors}\\This returns the list of neighbors for the node.\code{$node add-neighbor <neighbor_node>}\\This is a command to add \code{<neighbor_node>} to the list of neighbors maintained by the node.Following is a list of internal node methods:\code{$node enable-mcast}\\This is an internal procedure used by Class Simulator while creating a node and is used to install additional multicast classifiers within the nodethat converts an unicast node into a multicast one.\code{$node add-route <destination_id> <target>}\\This is used in unicast routing to populate the classifier. The target is aTcl object, which may be the entry of \code{dmux_} (port demultiplexer inthe node) incase the \code{<destination_id>} is same as this node-id.Otherwise it is usually the head of the link for that destination. Itcould also be the entry for other classifiers.\code{$node alloc-port <null_agent>}\\This returns the next available port number. Uses instance variable\code{np_} to track the next unallocated port number.\code{$node incr-rtgtable-size}\\The instance variable \code{rtsize_} is used to keep track of size ofrouting-table in each node. This command is used to increase therouting-table size every time an routing-entry is added to theclassifiers.\code{$node getNode}\\Returns the instance of self (the node).\code{$node attachInterfaces <ifaces>}\\Attaches the node to each of the <ifaces>.\code{$node addInterface <iface>}\\Adds the <iface> to the list of interfaces for the node.\code{$node createInterface <num>}\\Creates a new network interface and labels it with <num>.\code{$node getInterfaces}\\Returns the list of interfaces for the node.There are other node commands that supports hierarchicalrouting, PIM, IntTCP, detailed dynamic routing, equal cost multipathrouting, PGM router, manual routing and power model for mobilenodes. Theseand other methods described earlier can be found in \ns/tcl/lib/ns-node.tcl.\end{flushleft}\endinput

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -