NS2工具(cbrgen,setdest,threshold,nam)

转载】 Jerry's Study : NS2中的小工具    2009年09月09日 星期三 19:48

一.  cbrgen(~ns/indep-utils/cmu-scen-gen)

cbrgen用来生成传输负载,可以产生TCP流或者CBR流。
使用方法如下:
ns cbrgen.tcl [-type cbr|tcp] [-nn nodes] [-seed seed] [-mc connections] [-rate rate]

-type tcp流或cbr流              -nn 节点数  
-mc 节点间的最大连接数            -rate  每个连接间的流的负载数
-seed  指定随机数种子

二.setdest(~ns/indep-utils/cmu-scen-gen/setdest/)

用来随机生成无线网所需的节点运动场景,使用前需make。
使用方法如下:
./setdest   -v <1> -n <nodes> -p <pause time> -M <max speed> -t <simulation time> -x <max X> -y <max Y>
./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>

其中,speed type为uniform/normal,pause type为constant/uniform
以上两个工具产生的文件均可采用source命令加入到tcl文件中,注意产生的文件用到了诸如node_数组变量和god_变量,需要在tcl脚本中预先建立。

三.threshold工具(~ns/indep-utils/propagation)

用来在无线网络中,计算在某种传播模型下,如何设定接收功率阈值来控制无线传输的范围。
先编译得到可执行文件:g++ threshold.cc -o threshold
命令如下:threshold -m <propagation-model> [other-options] distance
common parameters: -Pt <transmit-power> -fr <frequency> -Gt <transmit-antenna-gain> -Gr <receive-antenna-gain> -L <system-loss>
for two-ray ground model: -ht <transmit-antenna-height> -hr <receive-antenna-height>
for shadowing model: -pl <path-loss-exponent> -std <shadowing-deviation> -d0 <reference-distance> -r <receiving-rate>

四.nam(Network Animater)

nam的功能是根据网络模拟软件或真实环境里的特定格式的trace输出文件来运行动画,例如,trace文件常常来自NS模拟器或者Tcpdump软件的输出。
NS中控制nam动画显示的命令如下:
1.节点
$node color [color] ;#设定节点的颜色
$node shape [shape] ;#设定节点的形状
$node label [label] ;#设定节点的名称
$node label-color [lcolor] ;#设定节点显示名称的颜色
$node label-at [ldirection] ;#设定节点名称的显示位置
$node add-mark [name] [color] [shape] ;#增加注释
$node delete-mark [name]              ;#删除注释

2.链路和队列
$ns duplex-link <attribute> <value>
attribute:orient、color、queuePos、label

3.Agent
使用下面的命令就可以使想要显示的Agent以AgentName出现在节点附件的方框内:
$ns add-agent-trace 
$Agent AgentName

猜你喜欢

转载自blog.csdn.net/xiao_sheng_jun/article/details/79660382