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>The</strong> class imposes no direct semantic meaning on a packet’s destin<strong>at</strong>ion address field. R<strong>at</strong>her, it retur<strong>ns</strong> some number of bitsfrom the packet’s dst_ field as the slot number used in the Classifier::recv() method. <strong>The</strong> mask_ <strong>and</strong> shift_values are set through OTcl.5.4.2 Multicast Classifiers<strong>The</strong> multicast classifier classifies packets according to both source <strong>and</strong> destin<strong>at</strong>ion (group) addresses. It maintai<strong>ns</strong> a (chainedhash) table mapping source/group pairs to slot numbers. When a packet arrives containing a source/group unknown to theclassifier, it invokes an Otcl procedure Node::new-group{} to add an entry to its table. This OTcl procedure may use themethod set-hash to add new (source, group, slot) 3-tuples to the classifier’s table. <strong>The</strong> multicast classifier is defined in~<strong>ns</strong>/classifier-mcast.cc as follows:st<strong>at</strong>ic class MCastClassifierClass : public TclClass {public:MCastClassifierClass() : TclClass("Classifier/Multicast") {}TclObject* cre<strong>at</strong>e(int argc, co<strong>ns</strong>t char*co<strong>ns</strong>t* argv) {return (new MCastClassifier());}} class_mcast_classifier;class MCastClassifier : public Classifier {public:MCastClassifier();~MCastClassifier();protected:int comm<strong>and</strong>(int argc, co<strong>ns</strong>t char*co<strong>ns</strong>t* argv);int classify(Packet *co<strong>ns</strong>t p);int findslot();void set_hash(<strong>ns</strong>addr_t src, <strong>ns</strong>addr_t dst, int slot);int hash(<strong>ns</strong>addr_t src, <strong>ns</strong>addr_t dst) co<strong>ns</strong>t {u_int32_t s = src ^ dst;s ^= s >> 16;s ^= s >> 8;return (s & 0xff);}struct hashnode {int slot;<strong>ns</strong>addr_t src;<strong>ns</strong>addr_t dst;hashnode* next;};hashnode* ht_[256];co<strong>ns</strong>t hashnode* lookup(<strong>ns</strong>addr_t src, <strong>ns</strong>addr_t dst) co<strong>ns</strong>t;};int MCastClassifier::classify(Packet *co<strong>ns</strong>t pkt){IPHeader *h = IPHeader::access(pkt->bits());<strong>ns</strong>addr_t src = h->src() >> 8; /*XXX*/54

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

Saved successfully!

Ooh no, something went wrong!