next up previous contents index
Next: 23.4.2 Interface to Network Up: 23.4.1 The classes Previous: 23.4.1.0.4 Agent/rtProto../ns-2/route-proto.tcl

23.4.1.0.5 Other Extensions to the Simulator, Node, Link, and Classifier

--
We have discussed the methods []rtproto and []cost in the class Simulator earlierSectionsec:API. The one other method used internally is []get-routelogic../ns-2/route-proto.tclSimulator::get-routelogic; this procedure returns the instance of routelogic in the simulation.

The method is used by the class Simulator, and unicast and multicast routing.

--
The class Node contains these additional instance procedures to support dynamic unicast routing: []init-routing../ns-2/route-proto.tclNode::init-routing, []add-routes../ns-2/route-proto.tclNode::add-routes, []delete-routes../ns-2/route-proto.tclNode::delete-routes, and []rtObject?../ns-2/route-proto.tclNode::rtObject?.

The instance procedure []init-routing is invoked by the rtObject at the node. It stores a pointer to the rtObject, in its instance variable rtObject_, for later manipulation or retrieval. It also checks its class variable to see if it should use multiPath routing, and sets up an instance variable to that effect. If multiPath routing could be used, the instance variable array routes_ stores a count of the number of paths installed for each destination. This is the only array in unicast routing that is indexed by the node id, rather than the node handle.

The instance procedure []rtObject? returns the rtObject handle for that node.

The instance procedure []add-routes takes a node id, and a list of links. It will add the list of links as the routes to reach the destination identified by the node id. The realization of multiPath routing is done by using a separate Classifier/multiPath. For any given destination id d, if this node has multiple paths to d, then the main classifier points to this multipath classifier instead of the link to reach the destination. Each of the multiple paths identified by the interfaces being used is installed in the multipath classifier. The multipath classifier will use each of the links installed in it for succeeding packets forwarded to it.

The instance procedure []delete-routes takes a node id, a list of interfaces, and a nullAgent. It removes each of the interfaces in the list from the installed list of interfaces. If the entry did not previously use a multipath classifier, then it must have had only one route, and the route entry is set to point to the nullAgent specified.

Q: WHY DOES IT NOT POINT TO NULLAGENT IF THE ENTRIES IN THE MPATHCLASSIFIER GOES TO ZERO?

--
The main extension to the class Link for unicast routing is to support the notion of link costs. The instance variable cost_ contains the cost of the unidirectional link. The instance procedures []cost../ns-2/route-proto.tclLink::cost and []cost?../ns-2/route-proto.tclLink::cost? set and get the cost on the link.

Note that []cost takes the cost as argument. It is preferable to use the simulator method to set the cost variable, similar to the simulator instance procedures to set the queue or delay on a link.

--
The Classifier../ns-2/ns-lib.tcl contains three new procedures, two of which overloads an existing instproc-like, and the other two provide new functionality.

The instance procedure []install../ns-2/route-proto.tclClassifier::install overloads the existing instproc-like of the same name. The procedure stores the entry being installed in the instance variable array, elements_, and then invokes the instproc-like.

The instance procedure []installNext../ns-2/route-proto.tclClassifier::installNext also overloads the existing instproc-like of the same name. This instproc-like simply installs the entry into the next available slot.

The instance procedure []adjacents../ns-2/route-proto.tclClassifier::adjacents returns a list of key, value pairs of all elements installed in the classifier.


next up previous contents index
Next: 23.4.2 Interface to Network Up: 23.4.1 The classes Previous: 23.4.1.0.4 Agent/rtProto../ns-2/route-proto.tcl

2000-08-24