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.

<strong>The</strong> Node i<strong>ns</strong>tance variable, entry_, stores the reference this element. For unicast nodes, this is the address classifierth<strong>at</strong> looks <strong>at</strong> the higher bits of the destin<strong>at</strong>ion address. <strong>The</strong> i<strong>ns</strong>tance variable, classifier_ contai<strong>ns</strong> the referenceto this classifier. However, for multicast nodes, the entry point is the switch_ which looks <strong>at</strong> the first bit to decidewhether it should forward the packet to the unicast classifier, or the multicast classifier as appropri<strong>at</strong>e.2. $node reset will reset all agents <strong>at</strong> the node.Address <strong>and</strong> Port number management <strong>The</strong> procedure $node id retur<strong>ns</strong> the node number of the node. This numberis autom<strong>at</strong>ically incremented <strong>and</strong> assigned to each node <strong>at</strong> cre<strong>at</strong>ion by the class Simul<strong>at</strong>or method, $<strong>ns</strong> node.<strong>The</strong> classSimul<strong>at</strong>or also stores an i<strong>ns</strong>tance variable array 1 , Node_, indexed by the node id, <strong>and</strong> contai<strong>ns</strong> a reference to the node withth<strong>at</strong> id.<strong>The</strong> procedure $node agent 〈port〉 retur<strong>ns</strong> the h<strong>and</strong>le of the agent <strong>at</strong> the specified port. If no agent <strong>at</strong> the specified portnumber is available, the procedure retur<strong>ns</strong> the null string.<strong>The</strong> procedure alloc-port retur<strong>ns</strong> the next available port number. It uses an i<strong>ns</strong>tance variable, np_, to track the nextunalloc<strong>at</strong>ed port number.<strong>The</strong> procedures, add-route <strong>and</strong> add-routes, are used by unicast routing (Chapter 29) to add routes to popul<strong>at</strong>e theclassifier_ <strong>The</strong> usage syntax is $node add-route 〈destin<strong>at</strong>ion id〉 〈TclObject〉. TclObject is theentry of dmux_, the port demultiplexer <strong>at</strong> the node, if the destin<strong>at</strong>ion id is the same as this node’s id, it is often the head of alink to send packets for th<strong>at</strong> destin<strong>at</strong>ion to, but could also be the the entry for other classifiers or types of classifiers.$node add-routes 〈destin<strong>at</strong>ion id〉 〈TclObjects〉 is used to add multiple routes to the same destin<strong>at</strong>ion th<strong>at</strong>must be used simultaneously in round robin manner to spread the b<strong>and</strong>width used to reach th<strong>at</strong> destin<strong>at</strong>ion across all linksequally. It is used only if the i<strong>ns</strong>tance variable multiP<strong>at</strong>h_ is set to 1, <strong>and</strong> detailed dynamic routing str<strong>at</strong>egies are in effect,<strong>and</strong> requires the use of a multiP<strong>at</strong>h classifier. We describe the implement<strong>at</strong>ion of the multiP<strong>at</strong>h classifier l<strong>at</strong>er in this chapter(Section 5.4); however, we defer the discussion of multip<strong>at</strong>h routing (Chapter 29) to the chapter on unicast routing.<strong>The</strong> dual of add-routes{} is delete-routes{}. It takes the id, a list of TclObjects, <strong>and</strong> a reference to the simul<strong>at</strong>or’snullagent. It removes the TclObjects in the list from the i<strong>ns</strong>talled routes in the multip<strong>at</strong>h classifier. If the route entryin the classifier does not point to a multip<strong>at</strong>h classifier, the routine simply clears the entry from classifier_, <strong>and</strong> i<strong>ns</strong>tallsthe nullagent in its place.Detailed dynamic routing also uses two additional methods: the i<strong>ns</strong>tance procedure init-routing{} sets the i<strong>ns</strong>tancevariable multiP<strong>at</strong>h_ to be equal to the class variable of the same name. It also adds a reference to the route controllerobject <strong>at</strong> th<strong>at</strong> node in the i<strong>ns</strong>tance variable, rtObject_. <strong>The</strong> procedure rtObject?{} retur<strong>ns</strong> the h<strong>and</strong>le for the routeobject <strong>at</strong> the node.Finally, the procedure intf-changed{} is invoked by the network dynamics code if a link incident on the node changesst<strong>at</strong>e. Additional details on how this procedure is used are discussed l<strong>at</strong>er in the chapter on network dynamics (Chapter 31).Agent management Given an 〈agent〉, the procedure <strong>at</strong>tach{} will add the agent to its list of agents_, assign a portnumber the agent <strong>and</strong> set its source address, set the target of the agent to be its (i.e., the node’s) entry{}, <strong>and</strong> add a pointerto the port demultiplexer <strong>at</strong> the node (dmux_) to the agent <strong>at</strong> the corresponding slot in the dmux_ classifier.Conversely, detach{}will remove the agent from agents_, <strong>and</strong> point the agent’s target, <strong>and</strong> the entry in the node dmux_to nullagent.1 i.e., an i<strong>ns</strong>tance variable of a class th<strong>at</strong> is also an array variable48

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

Saved successfully!

Ooh no, something went wrong!