11.9 Commands at a glance
Following are the agent related commands used in simulation scripts:
ns_ attach-agent node agent
This command attaches the <agent> to the <node>. We assume here that the
<agent> has already been created. An agent is typically created by
set agent [new Agent/AgentType]
where Agent/AgentType defines the class definiton of the specified agent
type.
$agent port
This returns the port number to which the agent is attached.
$agent dst-port
This returns the port number of the destination.
When any connection is setup between 2 nodes, each agent stores the
destination port in its instance variable called dst_port_.
$agent attach-app s_type
This commands attaches an application of type s_type to the agent.
A handle to the application object is returned. Also note that the application
type must be defined as a packet type in packet.h.
$agent attach-source s_type
This used to be the procedure to attach source of type s_type to
the agent. But this is obsolete now. Use attach-app (described above)
instead.
$agent attach-tbf tbf
Attaches a token bucket filter (tbf) to the agent.
$ns_ connect src dst
Sets up a connection between the src and dst agents.
$ns_ create-connection srctype src dsttype dst pktclass
This sets up a complete connection between two agents. First creates a source
of type <srctype> and binds it to <src>. Then creates a destination of type
<dsttype> and binds it to <dst>. Finally connects the src and dst agents and
returns a handle to the source agent.
$ns_ create-connection-list srctype src dsttype dst pktclass
This command is exactly similar to create-connection described above. But
instead of returning only the source-agent, this returns a list of source and
destination agents.
Internal procedures:
$ns_ simplex-connect src dst
This is an internal method that actually sets up an unidirectional connection
between the <src> agent and <dst> agent. It simply sets the destination address
and destination port of the <src> as <dst>'s agent-address and agent-port.
The "connect" described above calls this method twice to set up a bi-directional
connection between the src and dst.
$agent set args
This is an internal procedure used to inform users of the backward compatibility
issues resulting from the upgrade to 32-bit addressing space currently used
in ns.
$agent attach-trace file
This attaches the <file> to the agent to allow nam-tracing of the agent
events.
In addition to the agent related procedures described here, there are additional
methods that support different type of agents like Agent/Null, Agent/TCP,
Agent/CBR, Agent/TORA, Agent/mcast etc. These additional methods along
with the procedures described here can be found in ns/tcl/lib/(ns-agent.tcl,
ns-lib.tcl, ns-mip.tcl, ns-mobilenode.tcl, ns-namsupp.tcl, ns-queue.tcl,
ns-route.tcl, ns-sat.tcl, ns-source.tcl). They are also described in the
previous section.
Tom Henderson
2014-12-17