📄 node49.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.2 Multicast Classifiers</TITLE><META NAME="description" CONTENT="5.4.2 Multicast Classifiers"><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="node50.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node50.html"><LINK REL="previous" HREF="node48.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node48.html"><LINK REL="up" HREF="node47.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node47.html"><LINK REL="next" HREF="node50.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node50.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html2073" HREF="node50.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node50.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2067" 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="tex2html2061" HREF="node48.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node48.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2069" 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="tex2html2071" 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="tex2html2074" HREF="node50.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node50.html">5.4.3 MultiPath Classifier</A><B> Up:</B> <A NAME="tex2html2068" HREF="node47.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node47.html">5.4 The Classifier</A><B> Previous:</B> <A NAME="tex2html2062" HREF="node48.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node48.html">5.4.1 Address Classifiers</A>   <B> <A NAME="tex2html2070" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html2072" 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="SECTION03242000000000000000"></A><A NAME="sec:node:mcast-classifier"></A><BR>5.4.2 Multicast Classifiers</H2><P>The multicast classifier classifies packetsaccording to both source and destination (group) addresses.It maintains a (chained hash) table mapping source/group pairs to slot numbers.When a packet arrives containing a source/group unknown to the classifier,it invokes an Otcl procedure []Node::new-groupto add an entry to its table.This OTcl procedure may use the method <TT>set-hash</TT> to addnew (source, group, slot) 3-tuples to the classifier's table.The multicast classifier is defined in classifier-mcast.ccas follows:<PRE> static class MCastClassifierClass : public TclClass { public: MCastClassifierClass() : TclClass("Classifier/Multicast") {} TclObject* create(int argc, const char*const* argv) { return (new MCastClassifier()); } } class_mcast_classifier; class MCastClassifier : public Classifier { public: MCastClassifier(); ~MCastClassifier(); protected: int command(int argc, const char*const* argv); int classify(Packet *const p); int findslot(); void set_hash(nsaddr_t src, nsaddr_t dst, int slot); int hash(nsaddr_t src, nsaddr_t dst) const { u_int32_t s = src ^ dst; s ^= s \>\> 16; s ^= s \>\> 8; return (s & 0xff); } struct hashnode { int slot; nsaddr_t src; nsaddr_t dst; hashnode* next; }; hashnode* ht_[256]; const hashnode* lookup(nsaddr_t src, nsaddr_t dst) const; }; int MCastClassifier::classify(Packet *const pkt) { IPHeader *h = IPHeader::access(pkt-\>bits()); nsaddr_t src = h-\>src() \>\> 8; /*XXX*/ nsaddr_t dst = h-\>dst(); const hashnode* p = lookup(src, dst); if (p == 0) { /* * Didn't find an entry. * Call tcl exactly once to install one. * If tcl doesn't come through then fail. */ Tcl::instance().evalf("%s new-group %u %u", name(), src, dst); p = lookup(src, dst); if (p == 0) return (-1); } return (p-\>slot); }</PRE>The MCastClassifier implements a chained hash tableand applies a hash function on both the packet source anddestination addresses.The hash function returns the slot numberto index the <TT>slot_</TT> table in the underlying object.A hash miss implies packet delivery to a previously-unknown group;OTcl is called to handle the situation.The OTcl code is expected to insert an appropriate entry into the hash table.<P><HR><!--Navigation Panel--><A NAME="tex2html2073" HREF="node50.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node50.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html2067" 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="tex2html2061" HREF="node48.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node48.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html2069" 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="tex2html2071" 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="tex2html2074" HREF="node50.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node50.html">5.4.3 MultiPath Classifier</A><B> Up:</B> <A NAME="tex2html2068" HREF="node47.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node47.html">5.4 The Classifier</A><B> Previous:</B> <A NAME="tex2html2062" HREF="node48.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node48.html">5.4.1 Address Classifiers</A>   <B> <A NAME="tex2html2070" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html2072" 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 + -