centos7环境下ns3 安装过程
(1)安装ns3依赖环境
login as: root
root@192.168.46.148's password:
Last login: Sat Feb 2 14:02:55 2019
[root@lsrlinux ~]# yum install gcc-c++ python
[root@lsrlinux ~]# yum install python-devel
[root@lsrlinux ~]# yum install mercurial
[root@lsrlinux ~]# yum install doxygen graphviz ImageMagick
[root@lsrlinux ~]# yum install python-sphinx dia texlive texlive-latex
[root@lsrlinux ~]# yum install openmpi openmpi-devel
[root@lsrlinux ~]# yum install tcpdump wireshark
[root@lsrlinux ~]# yum install sqlite sqlite-devel
[root@lsrlinux ~]# yum install libxml2 libxml2-devel
[root@lsrlinux ns-allinone-3.29]# yun install uncrustify
[root@lsrlinux ~]# yum install boost-devel
[root@lsrlinux ~]# yum install graphviz graphviz-devel python-setuptools-devel ipython
[root@lsrlinux ~]# sudo easy_install pygraphviz
——————————————————————————————————————————————————————————————————————————————
——————————————————————————————————————————————————————————————————————————————
Then obtain the RPM for pygoocanvas andpygoocanvas-devel from here: http://li.nux.ro/download/nux/dextop/el6/x86_64/
在上面网址下载pygoocanvas-0.14.1-3.el6.nux.x86_64.rpm和pygoocanvas-devel-0.14.1-3.el6.nux.x86_64.rpm,放入/root/packages文件夹中,用rpm进行安装时要在包前加上文件路径。
[root@lsrlinux ~]# rpm -ivh /root/packages/pygoocanvas-0.14.1-3.el6.nux.x86_64.rpm --nodeps --force
[root@lsrlinux ~]# rpm -ivh /root/packages/pygoocanvas-devel-0.14.1-3.el6.nux.x86_64.rpm --nodeps --force
————————————————————————————————————————————————————————————————————————————————————
————————————————————————————————————————————————————————————————————————————————————
[root@lsrlinux ~]# yum install git
[root@lsrlinux ~]# yum install gsl gsl-devel
[root@lsrlinux ~]# yum install gdb valgrind
(2)步骤 下载ns3
从https://www.nsnam.org/releases/ns-3-29/download/下载最新版本ns3,放在/root/tarballs目录下。
[root@lsrlinux ~]# mkdir tarballs
[root@lsrlinux ~]# cd tarballs
[root@lsrlinux tarballs]# pwd
/root/tarballs
[root@lsrlinux tarballs]# ls
ns-allinone-3.29.tar.bz2
解压、进入ns-allinone-3.29:
[root@lsrlinux tarballs]# tar jxvf ns-allinone-3.29
[root@lsrlinux tarballs]# cd ns-allinone-3.29/
[root@lsrlinux ns-allinone-3.29]# ./build.py 出错
centos7,gcc版本太低要求4.9以上,解决方法如第三步所示:
ns-3 is supported and currently tested on the following primary platforms:
- Linux (x86 and x86_64): gcc/g++ versions 4.9 and above
(3)升级gcc
Centos7升级gcc版本方法之一使用scl软件集
Centos7 gcc版本默认4.8.3,Red Hat 为了软件的稳定和版本支持,yum 上版本也是4.8.3,所以无法使用yum进行软件更新,所以使用scl。
scl软件集(Software Collections),是为了给 RHEL/CentOS 用户提供一种以方便、安全地安装和使用应用程序和运行时环境的多个(而且可能是更新的)版本的方式,同时避免把系统搞乱。
//安装SCL源
[root@lsrlinux tarballs]# yum install centos-release-scl scl-utils-build
//2.列出scl有哪些源可以用
[root@lsrlinux tarballs]# yum list all --enablerepo='centos-sclo-rh'
//3.安装5.3版本的gcc、gcc-c++、gdb
[root@lsrlinux tarballs]# yum install devtoolset-4-gcc.x86_64 devtoolset-4-gcc-c++.x86_64 devtoolset-4-gcc-gdb-plugin.x86_64
//4.查看从 SCL 中安装的包的列表:
[root@lsrlinux tarballs]# scl --list 或 scl -l
//5.切换版本
//切换前查看gcc版本
[root@lsrlinux lsr]# gcc -v
线程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
//切换版本
[root@lsrlinux lsr]# scl enable devtoolset-4 bash
//进入新的bash环境,该环境中使用新的gcc版本。
[root@lsrlinux lsr]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-4/root/usr/libexec/gcc/x86_64-redhat-linux/5.3.1/lto-wrapper
gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC)
//6.使用exit 退出当前scl版本的bash环境
[root@lsrlinux lsr]# exit
exit
//再次查看gcc版本,已经回到系统自带的gcc版本
[root@lsrlinux lsr]# gcc -v
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
(4)重新构建安装:
[root@lsrlinux ns-allinone-3.29]# scl enable devtoolset-4 bash
[root@lsrlinux ns-allinone-3.29]# ./build.py
//最终结果如下:
'build' finished successfully (17m23.215s)
Modules built:
antenna aodv applications
bridge buildings config-store
core csma csma-layout
dsdv dsr energy
fd-net-device flow-monitor internet
internet-apps lr-wpan lte
mesh mobility mpi
netanim (no Python) network nix-vector-routing
olsr point-to-point point-to-point-layout
propagation sixlowpan spectrum
stats tap-bridge test (no Python)
topology-read traffic-control uan
virtual-net-device wave wifi
wimax
Modules not built (see ns-3 tutorial for explanation):
brite click openflow
visualizer
Leaving directory `./ns-3.29'
进入ns-3.29:
[root@lsrlinux ns-allinone-3.29]# cd ns-3.29/
使用waf编译安装,使用test.py测试,运行脚本测试:
[root@lsrlinux ns-3.29]# ./test.py
*** Note: ns-3 tests are currently disabled. Enable them by adding
*** "--enable-tests" to ./waf configure or modifying your .ns3rc file.
*** Note: ns-3 examples are currently disabled. Enable them by adding
*** "--enable-examples" to ./waf configure or modifying your .ns3rc file.
[root@lsrlinux ns-3.29]# ./waf distclean
'distclean' finished successfully (0.335s)
[root@lsrlinux ns-3.29]# ./waf --build-profile=debug --enable-examples --enable-tests configure
[root@lsrlinux ns-3.29]# ./waf
//测试所有的脚本,大概要30分钟左右
[root@localhost ns-3.21]# ./test.py -c core
//运行第一个例子。
[root@localhost ns-3.21]# ./waf --run hello-simulator
(5)配置 eclipse
默认启动的eclipse使用的是系统自带的gcc编译器,版本较低。
如何解决:
可以使用scl的方式来启动,启动方式为:
启动原理为,利用scl建立一个虚拟的环境。类似于anaconda可以虚拟多个python环境一样。
[root@lsrlinux ~]# scl enable devtoolset-4 eclipse
更详细的 SCL 指南,参考官方的快速入门指南
比如想要启动一个gcc版本为更高的环境,可以使用:
//查看scl虚拟环境中已经安装的软件
[root@lsrlinux ns-3.29]# scl --list
devtoolset-4
//启动带有该虚拟环境的bash
[root@lsrlinux ns-3.29]# scl enable devtoolset-4 bash
当该bash退出后,又恢复了原来的系统环境。
网友评论