Ns3中在大规模拓扑仿真中,为加速仿真速度,可以利用MPI工具,实现多进程联合仿真。
- linux系统下安装openmpi.
参考链接# ubuntu下安装openMPI - 成功运行ns-3中的文件
命令1:
打开文件,加入ns-3的路径:sudo gedit /etc/profile
最后此文件的最后两行为:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/jing/m_allFile/project/sourceInsight/ns3SourceFile/ns-allinone-3.25/ns-3.25
第一行与第二行用户根据自己电脑的安装环境进行配置
第一行的路径为ubuntu系统安装openmpi的路径;
第二行为ns-3的安装路径。
命令2:
source /etc/profile
更新源
命令3:
sudo /sbin/ldconfig -v
然后,就可以运行ns-3的simple-distributed.cc文件了:
命令:
mpirun -np 2 ./waf --run scratch/simple-distributed
结果:
At time 1.02264s packet sink received 512 bytes from 10.1.1.1 port 49153 total Rx 512 bytes
At time 1.0235s packet sink received 512 bytes from 10.1.2.1 port 49153 total Rx 512 bytes
At time 1.02437s packet sink received 512 bytes from 10.1.3.1 port 49153 total Rx 512 bytes
At time 1.02524s packet sink received 512 bytes from 10.1.4.1 port 49153 total Rx 512 bytes
参考链接
UBUNTU安装OPENMPI && NS-3 MPI