5.2.0.0.2 Address and Port number management

The procedure $node id returns the node number of the node. This number is automatically incremented and assigned to each node at creation by the class Simulator method, $ns node.The class Simulator also stores an instance variable array5.1, Node_, indexed by the node id, and contains a reference to the node with that id.

The procedure $node agent port returns the handle of the agent at the specified port. If no agent at the specified port number is available, the procedure returns the null string.

The procedure alloc-port returns the next available port number. It uses an instance variable, np_, to track the next unallocated port number.

The procedures, add-route and add-routes, are used by unicast routingChapterchap:unicast to add routes to populate the classifier_ The usage syntax is $node add-route destination id TclObject. TclObject is the entry of dmux_, the port demultiplexer at the node, if the destination id is the same as this node's id, it is often the head of a link to send packets for that destination to, but could also be the the entry for other classifiers or types of classifiers.

$node add-routes destination id TclObjects is used to add multiple routes to the same destination that must be used simultaneously in round robin manner to spread the bandwidth used to reach that destination across all links equally. It is used only if the instance variable multiPath_ is set to 1, and detailed dynamic routing strategies are in effect, and requires the use of a multiPath classifier. We describe the implementation of the multiPath classifier later in this chapterSectionsec:node:classifiers; however, we defer the discussion of multipath routingChapterchap:unicast to the chapter on unicast routing.

The dual of []add-routes is []delete-routes. It takes the id, a list of TclObjects, and a reference to the simulator's nullagent. It removes the TclObjects in the list from the installed routes in the multipath classifier. If the route entry in the classifier does not point to a multipath classifier, the routine simply clears the entry from classifier_, and installs the nullagent in its place.

Detailed dynamic routing also uses two additional methods: the instance procedure []init-routing sets the instance variable multiPath_ to be equal to the class variable of the same name. It also adds a reference to the route controller object at that node in the instance variable, rtObject_. The procedure []rtObject? returns the handle for the route object at the node.

Finally, the procedure []intf-changed is invoked by the network dynamics code if a link incident on the node changes state. Additional details on how this procedure is used are discussed later in the chapter on network dynamicsChapterchap:net-dynamics.

Tom Henderson 2011-11-05