这几天要安装ns3,网上的教程好多错误,故将其分享。(我是在虚拟机上面安装的)
首先准备工作:
apt-get install gcc g++ python
apt-get install gcc g++ python python-dev
apt-get install mercurial python-setuptools git
apt-get install qt5-defaul
apt-get install python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev ipython
apt-get install openmpi-bin openmpi-common openmpi-doc libopenmpi-dev
apt-get install autoconf cvs bzr unrar
apt-get install gdb valgrind
apt-get install uncrustify
apt-get install doxygen graphviz imagemagick
apt-get install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils texlive-lang-portuguese dvipng
apt-get install python-sphinx dia
此处:Sphinx version >= 1.12 required for ns-3.15. To check your version, type "sphinx-build". To fetch this package alone, outside of the Ubuntu package system, try "sudo easy_install -U Sphinx".
apt-get install gsl-bin libgsl2 libgsl-dev
apt-get install flex bison libfl-dev
apt-get install tcpdump
apt-get install sqlite sqlite3 libsqlite3-dev
apt-get install libxml2 libxml2-dev
apt-get install cmake libc6-dev libc6-dev-i386 libclang-dev
pip install cxxfilt(此处可能会报没有安装python-pip,这时候可以按照建议安装pip功能)
apt-get install libgtk2.0-0 libgtk2.0-dev
apt-get install vtun lxc
apt-get install libboost-signals-dev libboost-filesystem-de
准备工作结束,开始使用Mercurial:
注意: 查看安装的hg版本:hg --version,没有就要安装mercurial.我的系统上有故没有安装
之后操作:
> cd
> mkdir repos
> cd repos
> hg clone http://code.nsnam.org/ns-3-allinone
> cd (回到主目录)
> mkdir tarballs (创建子目录)
> cd tarballs
> wget http://www.nsnam.org/release/ns-allinone-3.25.tar.bz2
> tar xvf ns-allinone-3.25.tar.bz2
随后在终端进入解压缩文件夹ns-allinone-3.25,并执行sudo ./build.py,此处时间较长(会出现'build' finished successfully)
这时候在进入ns-3.25//而非ns-allinone-3.25
输入以下三个语句:
sudo ./waf clean
sudo ./waf -d debug --enable-example --enable-tests configure
sudo ./waf
完成之后输入:sudo ./test.py –c core 会出现一串PASS...
运行小例程:sudo ./waf --run hello-simulator
会打印"hello simulator":
说明ns3安装完成。后面没有弄,等弄了在更新。
注意:安装会有两个错误:
1.无法获得锁 /var/lib/dpkg/lock - open (11: 资源暂时不可用)
E: 无法锁定管理目录(/var/lib/dpkg/),是否有其他进程正占用它?”
解决方法:
sudo rm /var/cache/apt/archives/locksudo rm /var/lib/dpkg/lock
2.dpkg 被中断,您必须手工运行 sudo dpkg –configure -a解决此问题。
输入以下指令即可解决问题:
sudo rm /var/lib/dpkg/updates/*
sudo dpkg --configure -a