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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

RoutingModulesRtModule/Baseroutingadd-routedelete-routeBaseHierNoderoutingadd-routedelete-routeRouteComput<strong>at</strong>iontra<strong>ns</strong>port<strong>at</strong>tachdetachMcasttra<strong>ns</strong>port<strong>at</strong>tachdetachUserSimul<strong>at</strong>ionManagementregisterunregisterMPLS......Classifieri<strong>ns</strong>ert-entryi<strong>ns</strong>tall-entryi<strong>ns</strong>tall-demuxFigure 5.3: Interaction among node, routing module, <strong>and</strong> routing. <strong>The</strong> dashed line shows the details of one routing module.are interested in learning about the new routes. This is not a requirement, however, because it is possible th<strong>at</strong> some routecomput<strong>at</strong>ion is specific to one particular routing module, for i<strong>ns</strong>tance, label i<strong>ns</strong>tall<strong>at</strong>ion in the MPLS module.A routing module contai<strong>ns</strong> three major functionalities:1. A routing module initializes its connection to a node through register{}, <strong>and</strong> tears the connection down viaunregister{}. Usually, in register{} a routing module (1) tells the node whether it interests in knowing routeupd<strong>at</strong>es <strong>and</strong> tra<strong>ns</strong>port agent <strong>at</strong>tachments, <strong>and</strong> (2) cre<strong>at</strong>es its classifiers <strong>and</strong> i<strong>ns</strong>tall them in the node (details describedin the next subsection). In unregister{} a routing module does the exact opposite: it deletes its classifiers <strong>and</strong>removes its hooks on routing upd<strong>at</strong>e in the node.2. If a routing module is interested in knowing routing upd<strong>at</strong>es, the node will inform the module viaRtModule::add-route{dst, target} <strong>and</strong> RtModule::delete-route{dst, nullagent}.3. If a routing module is interested in learning about tra<strong>ns</strong>port agent <strong>at</strong>tachment <strong>and</strong> detachment in a node, the node willinform the module viaRtModule::<strong>at</strong>tach{agent, port} <strong>and</strong> RtModule::detach{agent, nullagent}.<strong>The</strong>re are two steps to write your own routing module:1. You need to declare the C++ part of your routing module (see ~<strong>ns</strong>/rtmodule.{cc,h}). For many modules this onlymea<strong>ns</strong> to declare a virtual method name() which retur<strong>ns</strong> a string descriptor of the module. However, you are freeto implement as much functionality as you like in C++; if necessary you may l<strong>at</strong>er move functionality from OTcl intoC++ for better performance.2. You need to look <strong>at</strong> the above interfaces implemented in the base routing module (see ~<strong>ns</strong>/tcl/lib/<strong>ns</strong>-rtmodule.tcl) <strong>and</strong>decide which one you’ll inherit, which one you’ll override, <strong>and</strong> put them in OTcl interfaces of your own module.<strong>The</strong>re are several derived routing module examples in ~<strong>ns</strong>/tcl/lib/<strong>ns</strong>-rtmodule.tcl, which may serve as templ<strong>at</strong>es for yourmodules.Currently, there are six routing modules implemented in <strong>ns</strong>:59

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

Saved successfully!

Ooh no, something went wrong!