On 7/14/06, sorin pasa <[EMAIL PROTECTED]> wrote: > I'm trying to create "n" FTP connections from n computers to n > computers (in pairs), connected through a node. I want to start a connection > at second 0, and then close it after a second and in the same time open > another. I don't know why, but the connections won't start. > Please help. ....I'm attaching the code here: > > for {set i 1} {$i <= $clienti_num} {incr i} { > set tcp [new Agent/TCP] > set sink [new Agent/TCPSink] > $ns attach-agent $sfile($i) $tcp > $ns attach-agent $peer($i) $sink > $ns connect $tcp $sink > $tcp set fid_ $i > $tcp set window_ 20 > $tcp set packetSize_ 100 > > set ftp($i) [new Application/FTP] > $ftp($i) attach-agent $tcp > $ftp($i) set type_ FTP > } > > for {set i 1} {$i <= $clienti_num} {incr i} { > $ns at $i-1 "$ftp start" > $ns at $i "$ftp($i) stop" > }
Tcl doesn't do arithmetic evaluation by default. To get what you mean (i.e. a transfer starting 1 second before $i), you need to write "[expr {$i -1}]" in place of "$i-1". If you declare "global ftp" at the top of your first for loop, that may help on the possible scoping issue (I'm not sure how Tcl determines variable scope). Phil Miller