环境
Ubuntu 18.04 (VMware)
安装流程
步骤一、安装gcc编译器及make
sudo apt-get install gcc-4.8 g++-4.8
sudo apt-get install build-essential
(注安装最新版g++会出现一些代码错误。Bing到参考[1],使用4.8版本不会有任何报错)
步骤二、安装依赖
sudo apt-get install tcl8.5 tcl8.5-dev tk8.5 tk8.5-dev #for tcl and tk
sudo apt-get install libxmu-dev libxmu-headers #for nam
步骤三、解压并编译文件
解压存放在/opt/目录下
tar xvf ns-allinone-2.35.tar.gz
cd ns-allinone-2.35/
export CC=gcc-4.8 CXX=g++-4.8 && ./install
步骤四、编写terminal环境下的变量参数
sudo gedit ~/.bashrc
参考[2]复制粘贴
#LD_LIBRARY_PATH
OTCL_LIB=/opt/ns-allinone-2.35/otcl-1.14/
NS2_LIB=/opt/ns-allinone-2.35/lib/
USR_Local_LIB=/usr/local/lib/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$USR_Local_LIB
#TCL_LIBRARY
TCL_LIB=/opt/ns-allinone-2.35/tcl8.5.10/library/
USR_LIB=/usr/lib/
export TCL_LIBRARY=$TCL_LIBRARY:$TCL_LIB:$USR_LIB
#PATH
XGRAPH=/opt/ns-allinone-2.35/xgraph-12.2/:/opt/ns-allinone-2.35/bin:/opt/ns-allinone-2.35/tcl8.5.10/unix:/opt/ns-allinone-2.35/tk8.5.10/unix
NS=/opt/ns-allinone-2.35/ns-2.35/
NAM=/opt/ns-allinone-2.35/nam-1.15/
export PATH=$PATH:$NS:$NAM:$XGRAPH
sudo source ~/.bashrc
步骤五、运行样例
ns /opt/ns-allinone-2.35/ns-2.35/tcl/ex/simple.tcl