12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<strong>ns</strong>addr_t dst = h->dst();co<strong>ns</strong>t hashnode* p = lookup(src, dst);if (p == 0) {/** Didn’t find an entry.* Call tcl exactly once to i<strong>ns</strong>tall one.* If tcl doesn’t come through then fail.*/Tcl::i<strong>ns</strong>tance().evalf("%s new-group %u %u", name(), src, dst);p = lookup(src, dst);if (p == 0)return (-1);}return (p->slot);<strong>The</strong> class MCastClassifiermplements a chained hash table <strong>and</strong> applies a hash function on both the packet source<strong>and</strong> destin<strong>at</strong>ion addresses. <strong>The</strong> hash function retur<strong>ns</strong> the slot number to index the slot_ table in the underlying object. Ahash miss implies packet delivery to a previously-unknown group; OTcl is called to h<strong>and</strong>le the situ<strong>at</strong>ion. <strong>The</strong> OTcl code isexpected to i<strong>ns</strong>ert an appropri<strong>at</strong>e entry into the hash table.5.4.3 MultiP<strong>at</strong>h ClassifierThis object is devised to support equal cost multip<strong>at</strong>h forwarding, where the node has multiple equal cost routes to the samedestin<strong>at</strong>ion, <strong>and</strong> would like to use all of them simultaneously. This object does not look <strong>at</strong> any field in the packet. Withevery succeeding packet, it simply retur<strong>ns</strong> the next filled slot in round robin fashion. <strong>The</strong> definitio<strong>ns</strong> for this classifier are in~<strong>ns</strong>/classifier-mp<strong>at</strong>h.cc, <strong>and</strong> are shown below:class MultiP<strong>at</strong>hForwarder : public Classifier {public:MultiP<strong>at</strong>hForwarder() : <strong>ns</strong>_(0), Classifier() {}virtual int classify(Packet* co<strong>ns</strong>t) {int cl;int fail = <strong>ns</strong>_;do {cl = <strong>ns</strong>_++;<strong>ns</strong>_ %= (maxslot_ + 1);} while (slot_[cl] == 0 && <strong>ns</strong>_ != fail);return cl;}priv<strong>at</strong>e:int <strong>ns</strong>_; /* next slot to be used. Probably a misnomer? */};5.4.4 Hash ClassifierThis object is used to classify a packet as a member of a particular flow. As their name indic<strong>at</strong>es, hash classifiers use ahash table internally to assign packets to flows. <strong>The</strong>se objects are used where flow-level inform<strong>at</strong>ion is required (e.g. in55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!