[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] code
Lori Flynn <lori@cse.ucsc.edu> writes:
> The code I'm using (referring to the attach-agent and connect post I just
> made) is the following:
>
> from the beginning of the script:
>
> for {set ctr_ 0} {$ctr_ < 10} {incr ctr_ 1} {
> set agentNew_($ctr_) [new Agent/newAgent]
So, in what context do you have this array here, agentNew_?
Maybe you want to do
$ns set agentNew_($ctr_) [new Agent/newAgent]
since you use it later in a Simulator context.
> $ns attach-agent $n($ctr_) $agentNew_($ctr_)
> }
>
> Then, later in the simulation, if the new type of packet needs to be sent
> from a node, the node does the following:
> set thisNode [ $Node id ]
> set thisNewAgent [ $ns get-new-agent $thisNode ]
>
>
> ****However, I get an error when I call the get-new-agent function, the
> Simulator class is unable to locate the $agentNew_($nodeID).****
>
>
> The get-new-agent function is defined below:
> Simulator instproc get-new-agent { nodeID } {
> $self instvar agentNew_
> $self set thisAgent $agentNew_($nodeID)
> puts "thisAgent is $thisAgent"
> return $thisAgent
> }
>
>
>
> Thanks again for any tips!
> -Lori
- References:
- [ns] code
- From: Lori Flynn <lori@cse.ucsc.edu>