关于ns2的问题
setpt0.2818setl1.0setlambda1.0setpi3.1415926setgt1.0setgr1.0procrecord{}{globalfilepr...
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里记录的距离跟信号强度
完整程序在http://blog.chinaunix.net/u/21684/showart_1092109.html上 展开
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里记录的距离跟信号强度
完整程序在http://blog.chinaunix.net/u/21684/showart_1092109.html上 展开
2个回答
2010-05-21
展开全部
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"
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"
展开全部
set tcp1 [new Agent/TCP/Newreno]
$tcp1 set class_ 1
$tcp1 set fid_ 1
set sink1 [new Agent/TCPSink]
$ns attach-agent $node(0) $tcp1
$ns attach-agent $node(1) $sink1
$ns connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns at 1.0 "$ftp1 start"
$tcp1 set class_ 1
$tcp1 set fid_ 1
set sink1 [new Agent/TCPSink]
$ns attach-agent $node(0) $tcp1
$ns attach-agent $node(1) $sink1
$ns connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns at 1.0 "$ftp1 start"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询