Linux TCL有什么办法可以做到这一点吗?
有没有办法进行一些程序,但不要这样做:Linux TCL有什么办法可以做到这一点吗?,linux,ftp,tcl,adhoc,proc,Linux,Ftp,Tcl,Adhoc,Proc,有没有办法进行一些程序,但不要这样做: 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.
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
一遍又一遍?
我是这样做的:
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
但它不起作用。。。在不结盟运动,没有传播。我不知道为什么。请帮忙。你认为应该有更好的方法的直觉是正确的。您需要的是一些调整:
proc wymiana {ns n_varname w1 w2 t1 t2} {
upvar 1 $n_varname node
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
### Varname is different just to make it clearer
$ns attach-agent $node($w1) $tcp
$ns attach-agent $node($w2) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
### Changes on two lines below
$ns at $t1 "$ftp start"
$ns at $t2 "$ftp stop"
}
# Create the setup from your question
wymiana $ns n 1 2 1.0 130.0
wymiana $ns n 6 15 10.0 110.0
wymiana $ns n 8 0 30.0 100.0
然而,考虑模拟和节点映射是否是真全局,以及为了清楚起见,您的过程应该采取什么样的语法也是合理的:
proc SetupFTP args {
global ns n
array set a $args
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
$ns attach-agent $n($a(-from)) $tcp
$ns attach-agent $n($a(-to)) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at $a(-start) "$ftp start"
$ns at $a(-stop) "$ftp stop"
}
SetupFTP -from 1 -to 2 -start 1.0 -stop 130.0
SetupFTP -from 6 -to 15 -start 10.0 -stop 110.0
SetupFTP -from 8 -to 0 -start 30.0 -stop 100.0
这样做完全是骗人的,你可以看到实现代码非常相似,但是当你回到代码中时,这种方法看起来会更清晰。(您也可以通过在过程中首先执行
array set a{the default mappings}
来设置默认值,您可以添加更多的错误检查。或者不添加错误检查。这取决于您。我不知道什么是合理的默认值;我想代理的类型可能适合这类事情。)你认为应该有更好的方法的直觉是正确的。您需要的是一些调整:
proc wymiana {ns n_varname w1 w2 t1 t2} {
upvar 1 $n_varname node
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
### Varname is different just to make it clearer
$ns attach-agent $node($w1) $tcp
$ns attach-agent $node($w2) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
### Changes on two lines below
$ns at $t1 "$ftp start"
$ns at $t2 "$ftp stop"
}
# Create the setup from your question
wymiana $ns n 1 2 1.0 130.0
wymiana $ns n 6 15 10.0 110.0
wymiana $ns n 8 0 30.0 100.0
然而,考虑模拟和节点映射是否是真全局,以及为了清楚起见,您的过程应该采取什么样的语法也是合理的:
proc SetupFTP args {
global ns n
array set a $args
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
$ns attach-agent $n($a(-from)) $tcp
$ns attach-agent $n($a(-to)) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at $a(-start) "$ftp start"
$ns at $a(-stop) "$ftp stop"
}
SetupFTP -from 1 -to 2 -start 1.0 -stop 130.0
SetupFTP -from 6 -to 15 -start 10.0 -stop 110.0
SetupFTP -from 8 -to 0 -start 30.0 -stop 100.0
这样做完全是骗人的,你可以看到实现代码非常相似,但是当你回到代码中时,这种方法看起来会更清晰。(您也可以通过在过程中首先执行
array set a{the default mappings}
来设置默认值,您可以添加更多的错误检查。或者不添加错误检查。这取决于您。我不知道什么是合理的默认值;我想代理的类型可能适合这类事情。)你认为应该有更好的方法的直觉是正确的。您需要的是一些调整:
proc wymiana {ns n_varname w1 w2 t1 t2} {
upvar 1 $n_varname node
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
### Varname is different just to make it clearer
$ns attach-agent $node($w1) $tcp
$ns attach-agent $node($w2) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
### Changes on two lines below
$ns at $t1 "$ftp start"
$ns at $t2 "$ftp stop"
}
# Create the setup from your question
wymiana $ns n 1 2 1.0 130.0
wymiana $ns n 6 15 10.0 110.0
wymiana $ns n 8 0 30.0 100.0
然而,考虑模拟和节点映射是否是真全局,以及为了清楚起见,您的过程应该采取什么样的语法也是合理的:
proc SetupFTP args {
global ns n
array set a $args
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
$ns attach-agent $n($a(-from)) $tcp
$ns attach-agent $n($a(-to)) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at $a(-start) "$ftp start"
$ns at $a(-stop) "$ftp stop"
}
SetupFTP -from 1 -to 2 -start 1.0 -stop 130.0
SetupFTP -from 6 -to 15 -start 10.0 -stop 110.0
SetupFTP -from 8 -to 0 -start 30.0 -stop 100.0
这样做完全是骗人的,你可以看到实现代码非常相似,但是当你回到代码中时,这种方法看起来会更清晰。(您也可以通过在过程中首先执行
array set a{the default mappings}
来设置默认值,您可以添加更多的错误检查。或者不添加错误检查。这取决于您。我不知道什么是合理的默认值;我想代理的类型可能适合这类事情。)你认为应该有更好的方法的直觉是正确的。您需要的是一些调整:
proc wymiana {ns n_varname w1 w2 t1 t2} {
upvar 1 $n_varname node
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
### Varname is different just to make it clearer
$ns attach-agent $node($w1) $tcp
$ns attach-agent $node($w2) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
### Changes on two lines below
$ns at $t1 "$ftp start"
$ns at $t2 "$ftp stop"
}
# Create the setup from your question
wymiana $ns n 1 2 1.0 130.0
wymiana $ns n 6 15 10.0 110.0
wymiana $ns n 8 0 30.0 100.0
然而,考虑模拟和节点映射是否是真全局,以及为了清楚起见,您的过程应该采取什么样的语法也是合理的:
proc SetupFTP args {
global ns n
array set a $args
set tcp [new Agent/TCP/Newreno]
set sink [new Agent/TCPSink]
$ns attach-agent $n($a(-from)) $tcp
$ns attach-agent $n($a(-to)) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at $a(-start) "$ftp start"
$ns at $a(-stop) "$ftp stop"
}
SetupFTP -from 1 -to 2 -start 1.0 -stop 130.0
SetupFTP -from 6 -to 15 -start 10.0 -stop 110.0
SetupFTP -from 8 -to 0 -start 30.0 -stop 100.0
这样做完全是骗人的,你可以看到实现代码非常相似,但是当你回到代码中时,这种方法看起来会更清晰。(您也可以通过在过程中首先执行
array set a{the default mappings}
来设置默认值,您可以添加更多的错误检查。或者不添加错误检查。这取决于您。我不知道什么是合理的默认值;我想代理的类型可能适合这类事情。)从快速扫描文档中可以看出,变量的名称几乎是任意的,普通的Tcl变量;ns2引擎只关心其中的值。这意味着你可以使用各种各样的技巧使事情变得更好!非常感谢你的帮助!从快速扫描文档中可以看出,变量的名称非常随意,是普通的Tcl变量;ns2引擎只关心其中的值。这意味着你可以使用各种各样的技巧使事情变得更好!非常感谢你的帮助!从快速扫描文档中可以看出,变量的名称非常随意,是普通的Tcl变量;ns2引擎只关心其中的值。这意味着你可以使用各种各样的技巧使事情变得更好!非常感谢你的帮助!从快速扫描文档中可以看出,变量的名称非常随意,是普通的Tcl变量;ns2引擎只关心其中的值。这意味着你可以使用各种各样的技巧使事情变得更好!非常感谢你的帮助!