next up previous contents index
Next: 6. Links: Simple Links Up: 5. Nodes and Packet Previous: 5.3.5 Replicator

5.4 Commands at a glance

Following is a list of common node commands used in simulation scripts:

$ns_ node
Command to create a simple node. This returns a handle to the node instance created.

$ns_ node hierarchical address
Command to create a node with hierarchical addressing/routing. This too returns a handle to the hier-node instance.

$ns_ node-config -option value
This command is a part of the new Node APIs and sets up configuration for a given node type. Note that this command has to be called before creation of the nodes. The default value (i.e if node-config is not called) sets up configuration for a simple node with flat addressing/routing. The details on different <options> and their available <values> that can be used to configure a node can be found in chapter titled "Restructuring ns node and new Node APIs" in ns Notes and Documentation.

$node id
Returns the id number of the node.

$node node-addr
Returns the address of the node. In case of flat addressing, the node address is same as its node-id. In case of hierarchical addressing, the node address in the form of a string (viz. "1.4.3") is returned.

$node reset
Resets all agent attached to this node.

$node agent port_num
Returns the handle of the agent at the specified port. If no agent is found at the given port, a null string is returned.

$node entry
Returns the entry point for the node. This is first object that handles packet receiving at this node.

$node attach agent optional:port_num
Attaches the <agent> to this node. Incase no specific port number is passed, the node allocates a port number and binds the agent to this port. Thus once the agent is attached, it receives packets destined for this host (node) and port.

$node detach agent null_agent
This is the dual of "attach" described above. It detaches the agent from this node and installs a null-agent to the port this agent was attached. This is done to handle transit packets that may be destined to the detached agent. These on-the-fly pkts are then sinked at the null-agent.

$node neighbors
This returns the list of neighbors for the node.

$node add-neighbor neighbor_node
This is a command to add neighbor_node to the list of neighbors maintained by the node.

Following is a list of internal node methods:

$node enable-mcast
This is an internal procedure used by Class Simulator while creating a node and is used to install additional multicast classifiers within the node that converts an unicast node into a multicast one.

$node add-route destination_id target
This is used in unicast routing to populate the classifier. The target is a Tcl object, which may be the entry of dmux_ (port demultiplexer in the node) incase the destination_id is same as this node-id. Otherwise it is usually the head of the link for that destination. It could also be the entry for other classifiers.

$node alloc-port null_agent
This returns the next available port number. Uses instance variable np_ to track the next unallocated port number.

$node incr-rtgtable-size
The instance variable rtsize_ is used to keep track of size of routing-table in each node. This command is used to increase the routing-table size every time an routing-entry is added to the classifiers.

$node getNode
Returns the instance of self (the node).

$node attachInterfaces ifaces
Attaches the node to each of the <ifaces>.

$node addInterface iface
Adds the <iface> to the list of interfaces for the node.

$node createInterface num
Creates a new network interface and labels it with <num>.

$node getInterfaces
Returns the list of interfaces for the node.

There are other node commands that supports hierarchical routing, PIM, IntTCP, detailed dynamic routing, equal cost multipath routing, PGM router, manual routing and power model for mobilenodes. These and other methods described earlier can be found in /tcl/lib/ns-node.tcl.

next up previous contents index
Next: 6. Links: Simple Links Up: 5. Nodes and Packet Previous: 5.3.5 Replicator