仿真DTN网络,通常需要产生节点移动的网络拓扑。目前,ns3支持两种移动场景产生器(Mobility scenario generators),即ns-2 setdest和BonnMotion。本文结合实例讲解BonnMotion使用方法,即先根据相应的模型产生节点移动数据,再根据相应的平台将这些数据转化为符合目标平台的格式。
1. 安装
官网下载BonnMotion安装包,解压,进入目录运行./install即可(需要事先安装jdk,sudo apt-get install default-jdk)。官方使用指南点这里进行下载。
2. 产生移动场景数据
命令./bin/bm -hm查看可生成的场景,如下:
Available models:
Boundless construct Boundless mobility scenarios
ChainScenario links different scenarios
Column create movement scenarios according to the Column model
DisasterArea create extended catastrophe scenarios according to the Disaster Area model
GaussMarkov construct GaussMarkov mobility scenarios
ManhattanGrid construct ManhattanGrid mobility scenarios
MSLAW construct MSLAW mobility scenarios
Nomadic create movement scenarios according to the Nomadic community Mobility model
OriginalGaussMarkov construct mobility scenarios according to the original Gauss-Markov model
ProbRandomWalk construct Probabilistic Random Walk mobility scenarios
Pursue create movement scenarios according to the Pursue Mobility model
RandomDirection construct Random Direction mobility scenarios
RandomStreet construct RandomStreet mobility scenarios
RandomWalk construct RandomWalk mobility scenarios
RandomWaypoint construct RandomWaypoint mobility scenarios
RandomWaypoint3D construct RandomWaypoint (3D) mobility scenarios
RPGM create movement scenarios according to the Reference Point Group Mobility model
SLAW construct mobility scenarios according to the Self-similar Least Action Walk model
SMOOTH construct SMOOTH mobility scenarios
Static construct static scenarios with no movement at all
StaticDrift construct static scenarios with a drift
SteadyStateRandomWaypoint construct Steady State Random Waypoint mobility scenarios
TIMM construct Tactical Indoor Mobility Model mobility scenarios
本例产生RandomWaypoint移动模型,random waypoint model(方向与速度都随机选择)是随机模型的一种,节点在仿真区域(x*y)内随机选择一个方向,在最小与最大速度之间随机选择一个速度,节点移动到目的地后,在0与最大停止时间随机选择一个时间停止不动[1]。命令./bin/bm –hm RandomWaypoint查看使用方法,如下:
Scenario:
-a <attractor parameters (if applicable for model)>
-c [use circular shape (if applicable for model)]
-d <scenario duration>
-i <number of seconds to skip>
-n <number of nodes>
-x <width of simulation area>
-y <height of simulation area>
-R <random seed>
RandomSpeedBase:
-h <max. speed>
-l <min. speed>
-p <max. pause time>
RandomWaypoint:
-o <dimension: 1: x only, 2: x or y, 3: x and y>
这里,只有节点数-n是必须,其他都有默认值,运行命令./bin/bm -f test_scenario RandomWaypoint -n 100产生两个文件test_scenario.params和test_scenario.movements.gz(尽管可以用gzip -d filename.gz解压,但没必要,直接vim就可以打开,而且后续转换格式需要.gz这个文件)。test_scenario.params存放的是参数,从这里可以看到参数的默认值,如下:
model=RandomWaypoint
ignore=3600.0
randomSeed=1398701966786
x=200.0
y=200.0
duration=600.0
nn=100
circular=false
dim=3
minspeed=0.5
maxspeed=1.5
maxpause=60.0
test_scenario.movements.gz是BonnMotion规定的数据存放格式,下一步将其转换成ns3可以使用的格式。
3. 转化成ns3使用的格式
BonnMotion可以将上述产生的场景数据转化成符合不同仿真平台的数据格式(如ns2, ns3, Glomosim, The ONE,),用命令./bin/bm -ha查看所支持的转换,摘抄部分如下:
Available apps:
Cut saves a certain timeframe from one scenario into a new file
CSVFile creates a simple CSV file for processing in 3rd-party tools
Dwelltime analyses scenarios according to Bettstetter
GlomoFile creates a movement file for Glomosim (2.0.3) and Qualnet (3.5.1)
GPXImport converts GPX files to Bonnmotion format
IntervalFormat converts scenario file into interval format
LinkDump dumps informations about the links
LongestLink Longest Link Metric
NSFile creates movement files for ns-2
ScenarioConverter converts scenario types
SPPXml converts scenarios according to Horst Hellbruecks XML schema
Statistics calculates various statistics for movement scenarios
TheONEFile converts scenarios to the ONE file format
Visplot visualises node movements
WiseML converts scenario files to WiseML format
用命令./bin/bm -ha <application name>进一步查看特定应用的使用方法,尽管BonnMotion没有专门为ns3提供支持,但ns3可以通过Ns2MobilityHelper类读取ns2的移动文件(movement files)。命令./bin/bm -ha NSFile查看使用方法,如下:
./bin/bm NSFile [-b double] [-d] -f <scenario>
-b double 增加边缘(margin),默认值为10
-d 禁用模块特殊转换(如灾区disaster area),使用标准转换
-f <scenario> 上述生成的场景文件,这里不需要输入后缀名.params或.movements.gz
在本例,运行命令./bin/bm NSFile -f test_scenario,生成NSFile格式的移动文件test_scenario.ns_movements 和test_scenario.params,test_scenario.params包含一些参数,如下:
set val(x) 220.0
set val(y) 220.0
set val(nn) 100
set val(duration) 600.0
文件test_scenario.ns_movements由一系列节点移动情况组成,取第一条如下:
$node_(0) set X_ 126.37346418288988 $node_(0) set Y_ 135.94261044575848 $ns_ at 0.0 "$node_(0) setdest 96.77496900599616 177.38003952427124 1.246967019035919" $ns_ at 45.435969720538196 "$node_(0) setdest 107.85949715020739 98.22059349334985 0.7091627087954391" $ns_ at 196.16204414948334 "$node_(0) setdest 73.94845981139225 206.62194932677775 0.815787004338213" $ns_ at 393.6431734580033 "$node_(0) setdest 103.07672579116219 46.015637307213 1.2760546622517224" $ns_ at 533.0677403031077 "$node_(0) setdest 176.96853459134928 104.20848371058558 1.405231787345907"
前两行是节点的初始位置,其后的每一行描述每一次移动,抽象出来,如下:
$node set X_ \<x1\> $node set Y_ \<y1\> $ns at $time $node setdest \<x2\> \<y2\> \<speed\>
上述的语句含义是,在时间点time,节点node以速度speed从(x1, y1)移动到(x2, y2)。
4. 导入ns3
参照例子src/mobility/examples/bonnmotion-ns2-example.cc,将上述场景数据导入ns3,主要代码如下:
CommandLine cmd; cmd.Parse(argc, argv); NodeContainer nodes; nodes.Create(100); std::string traceFile = "scratch/test_scenario.ns_movements"; Ns2MobilityHelper ns2 = Ns2MobilityHelper (traceFile); ns2.Install ();
Ns2MobilityHelper类只有一个函数,所以重点在于trace file。运行命令 ./waf –run scratch/test_scenario –vis,点击仿真,观察节点的移动,如下:
让我感到纳闷的是,100个节点,为什么只扫描到99个节点?如下:
scanning topology: 100 nodes…
scan topology… 99 nodes visited (99.0%)
scanning topology: calling graphviz layout
scanning topology: all done.
不足的是,BonnMotion支持的随机模型几乎是完全随机的,即服从泊松分布,而现实的网络几乎都是服从幂律分布,如何产生服务幂律分布的网络?如果您有好的方法,希望您能跟我分享,Jelline@126.com
参考资料:
[1]维基百科词条:Random waypoint model
附:BonnMotion简介
BonnMotion is a Java software which creates and analyzes mobility scenarios and is most commonly used as a tool for the investigation of mobile ad hoc network characteristics. The scenarios can also be exported for several network simulators, such as ns-2, ns-3, Glo-MoSim/QualNet, COOJA, MiXiM, and ONE. BonnMotion is being jointly developed by the Communication Systems group at the University of Bonn, Germany, the Toilers group at the Colorado School of Mines, Golden, CO, USA, and the Distributed Systems group at the University of Osnabr ̈ck, Germany.
赞赏微信赞赏
支付宝赞赏
你好,我想请问下有没有办法更详细的设置边界条件,比如设置成x 50-100,y 50-100。还是只能坐标从零开始。
您好,我也有个问题想请教一下。我安装了bonnmotion软件后,使用时无法执行./bin/bm –hm RandomWaypoint 出现Starting –hm …Error: Error in BM Unknown Module –hm是什么原因造成的呢?
是不是bm有新版本了,你重新查看下文档。
您好,我想请问下,ONE仿真器可以导入使用VanetMobiSim2生成的trace数据文件吗?
您好,您对把BonnMotion产生的数据导入ONE里面了解吗?
不是,我直接用的是外部数据集,如infocom06, MIT Reality。这个是当初用来导入ns3的。
你好!我想请问下如果使用外部数据集但还想使用到节点的位置信息,这可以吗?比如在外部数据的基础上模拟出位置移动。
应该是可以的,因为外部数据集包含了位置信息,但我没做过,我现在主要用ONE仿真器。
您好,我想请问下,ONE仿真器可以导入使用VanetMobiSim2生成的trace数据文件吗?
我最近想研究下Bubble Rap 、Simbet等社会属性相关的路由协议,但是没有找到NS3下的源代码,只找到了ONE下的Bubble Rap 源代码(也是看了您的文章)有点想转ONE ,不过,由于研究的是适用于车联网下的路由协议,需要导入真实场景文件。不知道ONE能否满足我的要求,顺便问一下,新接触ONE 难吗?毕竟之前都是用NS3,有点忐忑,您作为过来人,能给我一点建议吗? 先行感谢!
没用过VanetMobiSim2,不知道其格式,我想答案是肯定的,必要时写个脚本转换下格式,详情见sparkandshine.net/the-one-use-notes-import-datasets-without-location
既然你之前一直都是用ns3,谨慎转向ONE,毕竟ONE并没有那么强大,看你需求了。
十分感谢,顺便请问下,您有适用于NS3的Simbet、Bubble Rap协议的源代码吗? 我只找到了您发的ONE仿真器里的Bubble Rap协议,也没找着Simbet源代码。
Sorry. I don’t have.
请问一下能不能介绍一下bonnmotion产生灾难移动模型的命令设置呀,举个例子也行非常感谢了。