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.

class RouteLogic This class defines two methods to configure unicast routing, <strong>and</strong> one method to query it for routeinform<strong>at</strong>ion. It also defines an i<strong>ns</strong>tance procedure th<strong>at</strong> is applicable when the topology is dynamic. We discuss this lastprocedure in conjunction with the interface to network dynamics.• <strong>The</strong> i<strong>ns</strong>tance procedure register{} is invoked by Simul<strong>at</strong>or::rtproto{}. It takes the protocol <strong>and</strong> a list ofnodes as arguments, <strong>and</strong> co<strong>ns</strong>tructs an i<strong>ns</strong>tance variable, rtprotos_, as an array; the array index is the name of theprotocol, <strong>and</strong> the value is the list of nodes th<strong>at</strong> will run this protocol.• <strong>The</strong> configure{} reads the rtprotos_ i<strong>ns</strong>tance variable, <strong>and</strong> for each element in the array, invokes route protocolmethods to perform the appropri<strong>at</strong>e initializ<strong>at</strong>io<strong>ns</strong>. It is invoked by the simul<strong>at</strong>or run procedure.For each protocol 〈rt-proto〉 indexed in the rtprotos_ array, this routine invokes Agent/rtProto/〈rt-proto〉init-all rtprotos_(〈rt-proto〉).If there are no elements in rtprotos_, the routine invokes St<strong>at</strong>ic routing, as Agent/rtProto/St<strong>at</strong>ic init-all.• <strong>The</strong> i<strong>ns</strong>tance procedure lookup{} takes two node numbers, nodeId 1 <strong>and</strong> nodeId 2 , as argument; it retur<strong>ns</strong> the id ofthe neighbor node th<strong>at</strong> nodeId 1 uses to reach nodeId 2 .<strong>The</strong> procedure is used by the st<strong>at</strong>ic route comput<strong>at</strong>ion procedure to query the computed routes <strong>and</strong> popul<strong>at</strong>e the routes<strong>at</strong> each of the nodes. It is also used by the multicast routing protocols to perform the appropri<strong>at</strong>e RPF check.Note th<strong>at</strong> this procedure overloads an i<strong>ns</strong>tproc-like of the same name. <strong>The</strong> procedure queries the appropri<strong>at</strong>e rtObjectentities if they exist (which they will if dynamic routing str<strong>at</strong>egies are used in the simul<strong>at</strong>ion); otherwise, the procedureinvokes the i<strong>ns</strong>tproc-like to obtain the relevant inform<strong>at</strong>ion.class rtObject is used in simul<strong>at</strong>io<strong>ns</strong> th<strong>at</strong> use dynamic routing. Each node has a rtObject associ<strong>at</strong>ed with it, th<strong>at</strong> actsas a co-ordin<strong>at</strong>or for the different routing protocols th<strong>at</strong> oper<strong>at</strong>e <strong>at</strong> a node. At any node, the rtObject <strong>at</strong> th<strong>at</strong> node tracks eachof the protocols oper<strong>at</strong>ing <strong>at</strong> th<strong>at</strong> node; it computes <strong>and</strong> i<strong>ns</strong>talls the nest route to each destin<strong>at</strong>ion available via each of theprotocols. In the event th<strong>at</strong> the routing tables change, or the topology changes, the rtObject will alert the protocols to take theappropri<strong>at</strong>e action.<strong>The</strong> class defines the procedure init-all{}; this procedure takes a list of nodes as arguments, <strong>and</strong> cre<strong>at</strong>es a rtObject <strong>at</strong>each of the nodes in its argument list. It subsequently invokes its compute-routes.<strong>The</strong> assumption is th<strong>at</strong> the co<strong>ns</strong>tructor for each of the new objects will i<strong>ns</strong>tanti<strong>at</strong>e the “Direct” route protocol <strong>at</strong> eachof these nodes. This route protocol is respo<strong>ns</strong>ible for computing the routes to immedi<strong>at</strong>ely adjacent neighbors. Whencompute-routes{} is run by the init-all{} procedure, these direct routes are i<strong>ns</strong>talled in the node by the appropri<strong>at</strong>eroute object.<strong>The</strong> other i<strong>ns</strong>tance procedures in this class are:• init{} <strong>The</strong> co<strong>ns</strong>tructor sets up pointers from itself to the node, in its i<strong>ns</strong>tance variable node_, <strong>and</strong> from the node toitself, through the Node i<strong>ns</strong>tance procedure init-routing{} <strong>and</strong> the Node i<strong>ns</strong>tance variable rtObject_. It theninitializes an array of nextHop_, rtpref_, metric_, rtVia_. <strong>The</strong> index of each of these arrays is the h<strong>and</strong>le ofthe destin<strong>at</strong>ion node.<strong>The</strong> nextHop_ contai<strong>ns</strong> the link th<strong>at</strong> will be used to reach the particular destin<strong>at</strong>ion; rtpref_ <strong>and</strong> metric_ are thepreference <strong>and</strong> metric for the route i<strong>ns</strong>talled in the node; rtVia_ is the name of the agent whose route is i<strong>ns</strong>talled inthe node.<strong>The</strong> co<strong>ns</strong>tructor also cre<strong>at</strong>es the i<strong>ns</strong>tance of the Direct route protocol, <strong>and</strong> invokes compute-routes{} for th<strong>at</strong>protocol.• add-proto{} cre<strong>at</strong>es an i<strong>ns</strong>tance of the protocol, stores a reference to it in its array of protocols, rtProtos_. <strong>The</strong>index of the array is the name of the protocol. It also <strong>at</strong>taches the protocol object to the node, <strong>and</strong> retur<strong>ns</strong> the h<strong>and</strong>le ofthe protocol object.254

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

Saved successfully!

Ooh no, something went wrong!