[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] regarding creating a topology
I suggest that you double check your for loop inside for loop syntax.
set numNode 5
for {set i 0} {$i < $numNode} {incr i} {
set n($i) [$ns node]
}
for {set i 0} {$i < $numNode} {incr i} {
for {set j [expr $i+1]} {$j < $numNode} {incr j} {
$ns duplex-link $n($i) $n($j) 1Mb 10ms SFQ
}
}
On Tue, 21 Aug 2001, Raj M Verma wrote:
>
> Hello ns-users, I'm asking a stupid question as I'm new to this ns and Tcl.
> For creating a topology where every node is connected to each and every
> other node I'm trying to use for-loop inside a for-loop in Tcl. But it's not
> accepting that. Finally I cud achieve the topology in this way.
>
> for {set i 0} {$i < 5} {incr i} {
> set n($i) [$ns node]
> }
>
> for {set i 0} {$i < 4} {incr i} {
> $ns duplex-link $n(0) $n([expr ($i +1)]) 1Mb 10ms SFQ
> }
> for {set i 1} {$i < 4} {incr i} {
> $ns duplex-link $n(1) $n([expr ($i +1)]) 1Mb 10ms SFQ
> }
> for {set i 2} {$i < 4} {incr i} {
> $ns duplex-link $n(2) $n([expr ($i +1)]) 1Mb 10ms SFQ
> }
> for {set i 3} {$i < 4} {incr i} {
> $ns duplex-link $n(3) $n([expr ($i +1)]) 1Mb 10ms SFQ
> }
>
> In this way I've to use for-loop (n - 1) times for n nodes. I hope there
> shud be a better way of doing this but I'm not able to achieve it. cud any
> one pls help me.
>
> regards,
> Raj V Mudunuri.
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>