1. 程式人生 > >ubuntu安裝openmpi && ns-3 mpi

ubuntu安裝openmpi && ns-3 mpi

ket linux系統 1.4.1 http conf allinone 打開文件 erro sin

最近在做ns-3的網絡仿真,但是當網絡拓撲比較大或者速率很高時,仿真效率很低。

了解到ns-3的mpi模塊可以提高仿真效率,就開始學習使用。

整個過程分為兩步:

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

結束---

ubuntu安裝openmpi && ns-3 mpi