关于ns2的问题set pt 0.2818set l 1.0set lambda 1.0set pi 3.1415926set gt 1.0set gr 1.0proc record {} {global filepr pt l lambda gt gr pi nodeset ns [Simulator instance] set time 1.0;# record 0.5 secondset m_x [$node(1) set X_]set m_y [$node(1) se
来源:学生作业帮助网 编辑:六六作业网 时间:2025/01/13 07:18:47
关于ns2的问题set pt 0.2818set l 1.0set lambda 1.0set pi 3.1415926set gt 1.0set gr 1.0proc record {} {global filepr pt l lambda gt gr pi nodeset ns [Simulator instance] set time 1.0;# record 0.5 secondset m_x [$node(1) set X_]set m_y [$node(1) se
关于ns2的问题
set pt 0.2818
set l 1.0
set lambda 1.0
set pi 3.1415926
set gt 1.0
set gr 1.0
proc record {} {
global filepr pt l lambda gt gr pi node
set ns [Simulator instance]
set time 1.0;# record 0.5 second
set m_x [$node(1) set X_]
set m_y [$node(1) set Y_]
set n_x [$node(0) set X_]
set n_y [$node(0) set Y_]
set d [expr (sqrt(pow(($m_x - $n_x),2)+ pow(($m_y-$n_y),2)))]
set m [expr (1 /(4 * $pi * $d))]
set pr [expr ($pt * $gr * $gt * $m * $m / 1)]
#set d [expr ($d+10)]
# set xp [$n1 set X_]
set now [$ns now]
puts $filepr "$d\t$pr"
$ns at [expr $now + $time] "record"
}
$ns at 1.0 "record"
outpr.tr里如下
500.0 7.1380776311276484e-09
500.0 7.1380776311276484e-09
500.0 7.1380776311276484e-09
500.0 7.1380776311276484e-09
538.17178261213587 6.1614003554609057e-09
538.17178261213587 6.1614003554609057e-09
538.17178261213587 6.1614003554609057e
为什么outpr.tr里时间变化了,距离跟信号强度没变化呢?
500.0 7.1380776311276484e-09分别是outpr.tr里记录的距离跟信号强度
关于ns2的问题set pt 0.2818set l 1.0set lambda 1.0set pi 3.1415926set gt 1.0set gr 1.0proc record {} {global filepr pt l lambda gt gr pi nodeset ns [Simulator instance] set time 1.0;# record 0.5 secondset m_x [$node(1) set X_]set m_y [$node(1) se
set m [expr (1 /(4 * $pi * $d))]
set pr [expr ($pt * $gr * $gt * $m * $m / 1)]
#set d [expr ($d+10)]
# set xp [$n1 set X_]
set now [$ns now]
puts $filepr "$d\t$pr"
$ns at [expr $now + $time] "record"
}
$ns at 1.0 "record"