有没有办法做一些程序,不要这样做:
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
$ns attach-agent $n(0) $tcp
$ns attach-agent $n(1) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 1.0 "$ftp start"
$ns at 130.0 "$ftp stop"
##################################################################
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
$ns attach-agent $n(6) $tcp
$ns attach-agent $n(15) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 "$ftp start"
$ns at 110.0 "$ftp stop"
##################################################################
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
$ns attach-agent $n(8) $tcp
$ns attach-agent $n(0) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 30.0 "$ftp start"
$ns at 100.0 "$ftp stop"
一遍又一遍?我做这样的事情:
proc wymiana {ns n_varname w1 w2 t1 t2} {
upvar 1 $n_varname n
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
$ns attach-agent $n($w1) $tcp
$ns attach-agent $n($w2) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at t1 "$ftp start"
$ns at t2 "$ftp stop"
}
wymiana $ns n 1 2 1.0 100.0
但它不起作用......在NAM中没有传输。我不知道为什么。请帮忙。