[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] NS Automation Query
On Thursday 23 August 2001 10:41, jjc1@mail.staffs.ac.uk wrote:
> does anyone know how to automate the process of
> attaching a UDP agent to a number of nodes.
Use another loop?
Here is some code to attach an agent to both source and destination.
Assumes source nodes are held in a Tcl array named sourceNode and
destination nodes are held in a Tcl array named destNode. Also
assumes that source agents will be held in an array named source and
destination agents will be held in an array named dest.
proc createFlowAgent {SourceType DestType number} {
global ns sourceNode destNode
global source dest
# create Transmission agents.
set source($number) [new $SourceType]
set dest($number) [new $DestType]
# attach agents to their respective node
$ns attach-agent $sourceNode($number) $source($number)
$ns attach-agent $destNode($number) $dest($number)
# attach agents to each other.
$ns connect $source($number) $dest($number)
}
You can run this code, specifying the name of the agent as an
argument. For example, to add a New Reno agent to the source node
and a TCP Sink as the agent on the destination:
createFlowAgent "Agent/TCP/Newreno" "Agent/TCPSink" $flow_id
This is useful within a loop (looping over every flow ID you use).
--
Brian Lee Bowers | RADIANT Team (Summer Intern)
bowersb@lanl.gov | Los Alamos National Laboratory