1.首先去http://www.isi.edu/nsnam/ns/ns-build.html下载ns-allinone-2.35.tar.gz
2. 拷贝到用户目录下 如 /home/mingyong/
3. 更新一下系统
sudo apt-get update #更新源列表
sudo apt-get upgrade #更新已安装的包
4. 安装几个依赖文件
sudo apt-get install build-essential
sudo apt-get install tcl8.5 tcl8.5-dev tk8.5 tk8.5-dev
sudo apt-get install libxmu-dev libxmu-headers
5. 解压
tar -xvzf ns-allinone-2.35.tar.gz
mv ns-allinone-2.35 ns #将文件夹ns-allinone-2.35改为ns,方便以后操作
6. 安装
cd ns
sudo ./install
补充 :安装包好像有一点问题,导致安装失败
In file included from linkstate/ls.cc:67:0:
linkstate/ls.h: In instantiation of ‘void LsMap::eraseAll() [with Key = int; T = LsIdSeq]’:
linkstate/ls.cc:396:28: required from here
linkstate/ls.h:137:20: error: ‘erase’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of
instantiation [-fpermissive]
linkstate/ls.h:137:20: note: declarations in dependent base ‘std::map, std::allocator > >’ are not found by unqualified lookup
linkstate/ls.h:137:20: note: use ‘this->erase’ instead
make: *** [linkstate/ls.o] Error 1
Ns make failed!
解决方法:
将 ns/ns-2.35/linkstate/ls.h中的137行void eraseAll() { erase(baseMap::begin(), baseMap::end()); }改为 void eraseAll() { this->erase(baseMap::begin(),
baseMap::end()); }
然后重新执行 sudo ./install
几分钟后出现下图,表明安装好了
7. 设置环境变量
sudo gedit ./bashrc
在文件尾加入:
export PATH="$PATH:/home/mingyong/ns/bin:/home/mingyong/ns/tcl8.5.10/unix:/home/mingyong/ns/tk8.5.10/unix"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/mingyong/ns/otcl-1.14:/home/mingyong/ns/lib"
export TCL_LIBRARY="$TCL_LIBRARY:/home/mingyong/ns/tcl8.5.10/library"
8 新开启一个终端,输入ns,出现如下图表面安装成功,也可以进入 ns/ns-2.35, 输入./validate进行验证