博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助
隐藏
yexin218.cublog.cn
NS2场景测试与分析tr文件
一、场景测试
1、生成随机场景
setdest
<original 1999 CMU version (version 1)>
 setdest        -v <1> -n <nodes> -p <pause time> -M <max speed>
                -t <simulation time> -x <max X> -y <max Y>
OR
<modified 2003 U.Michigan version (version 2)>
 setdest        -v <2> -n <nodes> -s <speed type> -m <min speed> -M <max speed>  -t <simulation time> -P <pause type> -p <pause time> -x <max X> -y <max Y>
默认版本为第一版。
例:setdest -n 50 -p 0 -M 40 -t 400 -x 1200 -y 1200 >scene-50n-0p-40M-400t-1200-1200
在tcl中载入场景:
source "scene-50n-0p-40M-400t-1200-1200"
 
2、生成随机数据流
ns cbrgen.tcl
usage: cbrgen.tcl [-type cbr|tcp] [-nn nodes] [-seed seed] [-mc connections] [-rate rate]
例: ns cbrgen.tcl -type cbr -nn 50-seed 1 -mc 30 -rate 1.0 >cbr-50n-30c-1p
在tcl中载入数据流:
source "cbr-50n-30c-1p"
 
3、多次测试
撰写批处理文件(shell代码)。例:
i=1
while (test $i -lt 20)
do
   #生成运动场景
   setdest -n 50 -p 0 -M 40 -t 400 -x 1200 -y 1200 >scene-50n-0p-40M-400t-1200-1200
  #生成数据流场景
   ns cbrgen.tcl -type cbr -nn 50-seed 1 -mc 30 -rate 1.0 >cbr-50n-30c-1p
  ns mflood-scence.tcl ;#一次NS运行
  analysis-result mflood-scene.tr ;#分析、统计运行结果,这里只是示例,表示有这个步骤
done
 
二、tr文件分析
1、吞吐量分析
先撰写awk脚本,再用Gawk工具运行。
如:gawk -f getRatio.awk mflood.tr
 
2、画图分析
利用Gawk工具将awk脚本的结果输入到指定文件中,再利用gnuplot来画图。
如:
a、gawk -v src=1 -v dest=2 -v outfile=1-2.data -f getRatio.awk mflood.tr
b、gnuplot 1-2.plot
1-2.plot的内容如下:
set term png medium xFFFFFF
set output "1-2.png"
set ylabel "Transmission Speed(KB/s)"
set xlabel "Time(s)"
set key left top
set time "mflood analysis"
plot "1-2.data" title "1->2" with linespoints
 
3、编写shell批处理脚本,查看多个数据流的传输情况
 
4、使用nam查看运行过程

 原文地址 http://blog.sina.com.cn/s/blog_546c6f02010002q6.html
 TAG NS2
发表于: 2008-07-09,修改于: 2008-07-09 18:53,已浏览254次,有评论0条 推荐 投诉

给我留言
版权所有 ChinaUnix.net 页面生成时间:5.71349