5.6 Commands at a glance
Following is a list of common node commands used in simulation scripts:
$ns_ node [hier_addr]
Command to create and return a node instance. If <hier_addr> is given,
assign the node address to be <hier_addr>. Note that the latter MUST
only be used when hierarchical addressing is enabled via either
[]set-address-format hierarchical or
[]node-config -addressType hierarchical.
$ns_ node-config -config-parameter optional-val
This command is used to configure nodes. The different config-parameters
are addressingType, different type of the network stack components,
whether tracing will be turned on or not, mobileIP flag is truned or not,
energy model is being used or not etc. An option -reset maybe used to set
the node configuration to its default state. The default setting of
node-config, i.e if no values are specified, creates a simple node (base
class Node) with flat addressing/routing. For the syntax details see
Section
5.3.
$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 packets 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 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.
$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.
There are other node commands that supports hierarchical
routing, detailed dynamic routing, equal cost multipath
routing, manual routing, and energy model for mobile nodes. These
and other methods described earlier can be found in
~ns/tcl/lib/ns-node.tcl and ~ns/tcl/lib/ns-mobilenode.tcl.
Tom Henderson
2011-11-05