1.更新数据源
1.切换更新源
#sudo gedit /etc/apt/sources.list
删除并改写为
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
2.
sudo apt-get update #更新源列表
sudo apt-get upgrade #更新已经安装的包
sudo apt-get dist-upgrade #更新软件,升级系统
2.安装
sudo apt-get install build-essential autoconf automake
sudo apt-get install tcl8.5-dev tk8.5-dev
sudo apt-get install perl xgraph libxt-dev libxmu-dev libx11-dev libxmu-dev
3.下载ns2.35
ns2.35网盘下载地址 https://pan.baidu.com/s/18HkGZvfcIEkJAW9nLfzh0Q
提取码:2rej
下载后置于 /home/用户名/Documents目录下,并解压
cd /home/用户名/Documents
tar xvfz ns-allinone-2.35.tar.gz
cd ns-allinone-2.35
cd ns-2.35/linkstate/ls.h
找到第137行 void eraseAll() { erase(baseMap::begin(), baseMap::end()); }
改为:void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }
保存退出
cd /home/用户名/Documents/ns-allinone-2.35
./install
等待出现下图
4. 配置环境变量
-
打开新的terminal终端
-
sudo gedit ~/.bashrc
-
在终端加上下面一段话,将其中的"toor"更换为自己的用户名,可通过终端命令 users 查看
# LD_LIBRARY_PATH OTCL_LIB=/home/toor/Documents/ns-allinone-2.35/otcl-1.14/ NS2_LIB=/home/toor/Documents/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=/home/toor/Documents/ns-allinone-2.35/tcl8.5.10/library/ USR_LIB=/usr/lib/ export TCL_LIBRARY=$TCL_LIBRARY:$TCL_LIB:$USR_LIB #PATH XGPATH=/home/toor/Documents/ns-allinone-2.35/xgraph-12.2/:/home/toor /Documents/ns-allinone-2.35/bin/:/home/toor/Documents/ns-allinone-2.35/tcl8.5.10/unix/:/home/toor/Documents/ns-allinone-2.35/tk8.5.10/unix NS=/home/toor/Documents/ns-allinone-2.35/ns-2.35/ NAM=/home/toor/Documents/ns-allinone-2.35/nam-1.15/ export PATH=$PATH:$XGRAPH:$NS:$NAM
-
保存退出后, 执行 source ~/.bashrc
5.激活ns2
1. cd /home/用户名/Documents/ns-allinone-2.35/ns-2.35/
2. ./validate
6.验证
关闭终端,重启终端,输入ns,出现%,说明ns2安装成功
**注意:**环境变量配错的话,会提示“程序“ns”尚未安装。 此时请不要使用以下命令安装:
sudo apt-get install ns2
应该继续在步骤4中修改环境变量!
先重新打开一个新的终端:
cd /home/用户名/Documents/ns-allinone-2.35/ns-2.35/tcl/ex/
ns simple.tcl
倘若弹出动画演示框,则证明ns完全安装正确。