整个过程分为两步:
1. linux系统下安装openmpi.可以参考下面两篇文章:
http://blog.csdn.net/jacketinsysu/article/details/44840611
http://www.linuxidc.com/Linux/2015-04/116448.htm
我根据这两篇文章操作之后,运行mpirun -np 4 hello_c可以成功;但是,重新打开终端后,再次运行,就会出现如下错误
mpirun: error while loading shared libraries: libopen-rte.so.20: cannot open shared object file: No such file or directory
经过尝试,可以用如下方法解决:
用命令更新文件 /sbin/ldconfig -v ,否则问题依旧。
2. 成功运行ns-3中的simple-distributed.cc文件
命令1:
sudo gedit /etc/profile
打开文件,加入ns-3的路径:
最后此文件的最后两行为:
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
结束---