[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] silly problem
in inner loop you hsould use incr j, otherwise it'll exhause your memory
> for {set i 1} {$i < $N} {incr i} {
> for {set j 1} {$i < $N} {incr i} {
> set tcp($i:$j) [new Agent/TCP]
> set exp($i:$j) [new Application/Traffic/Exponential]
> set sink($i:$j) [new Agent/TCPSink]
> }
> }
>
> # Attach the agents and connect the stuff
>
> for {set i 1} {$i < $N} {incr i} {
> for {set j 1} {$i < $N} {incr i} {
> $ns attach-agent $n($i) $tcp($i:$j)
> $ns attach-agent $n($j) $sink($i:$j)
> $ns connect $tcp($i:$j) $sink($i:$j)
> $exp($i:$j) attach-agent $tcp($i:$j)
> }
> }
>
>
> #Schedule events for the traffic agents
> for {set i 1} {$i < $N} {incr i} {
> for {set j 1} {$i < $N} {incr i} {
> $ns at 0.0 "$exp($i:$j) start"
> }
> }
>
>
>
> #Call the finish procedure after 5 seconds of simulation time
> $ns at 5.0 "finish"
>
> #Run the simulation
> $ns run
>
>
>