关于ns2的aodv的疑问,想不通,求解

卦星 2013-05-29 03:24:59
最近学习ns2,进行网络仿真,昨天突然发现一个问题,怎么都想不通;不知道是不是我awk文件写不对还是怎么了?分析方法不对?求解
aodv是最小跳数协议
求解throughput,通信速率
采用aodv仿真3个点的实验的时候

三点的结果
start_time: 2.051540,end_time: 100.097301
cbr s:4089,r:4072,r/s Ratio:0.995843,F:4088
time=98.045760,through_put=43192.892658
后来添加2个点发现

5点的结果(理论上添加两个点是没有任何作用的)仍然选择最小跳数链路
start_time: 2.042403,end_time: 100.093324
cbr s:4093,r:4076,r/s Ratio:0.995847,F:4084
time=98.050921,through_put=43233.046143
后来又添加了一个点

发现再次上升了,不明白原因
6个点的结果
start_time: 2.057622,end_time: 100.068675
cbr s:4092,r:4075,r/s Ratio:0.995846,F:4085
time=98.011052,through_put=43240.021435
awk分析文件
BEGIN{
sendline = 0;
recvline = 0;
fowardline = 0;
package_t =0;
init=0;
time_start=0;
}
{
if($7=="tcp" && $1=="s" && $4 == "AGT" && $8>=1000){
sendline++;
}
if(($1=="f") && $8>=1000){
fowardline++;
}
if($8>=1000 && $1=="r" && $4 == "AGT") {
if(init ==0){
time_start=$2;
init=1;
}
recvline++;
time_end[recvline]=$2;
}
}
END{
printf("start_time: %6f,end_time: %6f\n",time_start,time_end[recvline]);
printf("cbr s:%d,r:%d,r/s Ratio:%4f,F:%d\n",sendline,recvline,recvline/sendline,fowardline);
time=time_end[recvline]-time_start;
package_t=recvline*1040;
through_put=package_t/time;
printf("time=%4f,through_put=%4f\n",time,through_put)
}

3点tcl文件代码,后面类似添加节点
set val(chan)	Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(ifqlen) 50
set val(nn) 3
set val(rp) AODV
set val(x) 800
set val(y) 600

puts "\n"
puts "Simulation of a simple wireless have two nodes\n"
puts "Starting simulation...\n"

set ns_ [new Simulator]

$ns_ color 1 Blue
$ns_ color 2 Red
set tracefd [open node_3_f.tr w]
$ns_ trace-all $tracefd
set namtracefd [open node_3_f.nam w]
$ns_ namtrace-all-wireless $namtracefd $val(x) $val(y)

set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)

$ns_ node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace OFF \

for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0
}

$node_(0) set X_ 300
$node_(0) set Y_ 300
$node_(0) set Z_ 0
$node_(1) set X_ 462
$node_(1) set Y_ 417
$node_(1) set Z_ 0
$node_(2) set X_ 623
$node_(2) set Y_ 300
$node_(2) set Z_ 0

#$ns_ at 10.0 "$node_(0) setdest 800.0 200.0 0.0"
#$ns_ at 10.0 "$node_(1) setdest 200.0 200.0 0.0"
#$ns_ at 10.0 "$node_(2) setdest 200.0 200.0 0.0"

set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp
$ns_ attach-agent $node_(2) $sink
$ns_ connect $tcp $sink
$tcp set fid_ 1
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 2.0 "$ftp start"

for {set i 0} {$i < $val(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 20
}

for {set i 0} {$i < $val(nn)} {incr i} {
$ns_ at 100 "$node_($i) reset"
}

proc stop {} {
global ns_ tracefd namtracefd
$ns_ flush-trace
close $tracefd
close $namtracefd
exec nam node_3_f.nam &
exit 0
}
$ns_ at 100.1 "stop"
$ns_ at 100.2 "puts \"NS EXITING...\";$ns_ halt"

puts "Starting Simulation...."

$ns_ run
...全文
344 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
蓝面书生 2013-09-06
  • 打赏
  • 举报
回复
我也是学ns,做毕业设计的,很多问题啊,求指导,我qq728351657

1,316

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧