NS2安装及入门实例——(ns2.35 / Ubuntu20.04)

一、ns2安装

1、更新系统源

sudo apt-get update
sudo apt-get upgrade

2、准备工作

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

3、下载安装包

官网下载地址:http://www.isi.edu/nsnam/ns/

点击 allinone

在这里插入图片描述

点击 current release 2.35

在这里插入图片描述

安装 ns-allinone-2.35.tar.gz

4、安装

sudo tar -zxvf ~/下载/ns-allinone-2.35.tar.gz -C /usr/local/
cd /usr/local
sudo mv ./ns-allinone-2.35 ./ns2
sudo chown -R hadoop:hadoop ./ns2
cd ns2
./install

5、问题

① 问题1

linkstate/ls.h:137:20: note: use ‘this->erase’ instead
make: *** [linkstate/ls.o] Error 1
Ns make failed!

解决:

137行:
void eraseAll() { erase(baseMap::begin(), baseMap::end()); } 
-> 
void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }

② 问题2

mdart/mdart_adp.cc:108:21: error: reference to ‘hash’ is ambiguous

在这里插入图片描述
解决:

sudo vim ns-2.35/mdart/mdart_function.h
230行:hash -> hash_o
sudo vim ns-2.35/mdart/mdart_adp.cc
108行:hash -> hash_o
396行:hash -> hash_o

③ 问题3

In file included from common/tkAppInit.cc:57:0:
./bitmap/play.xbm:5:74: error: narrowing conversion of ‘252’ from ‘int’ to ‘char’ inside

解决:全部加上 (char)
在这里插入图片描述

6、安装成功

在这里插入图片描述

7、环境配置

vim ~/.bashrc
source ~/.bashrc

加入一下配置:

export NS_HOME=/usr/local/ns2
export TK_HOME=$NS_HOME/tk8.5.10
export TCl_HOME=$NS_HOME/tcl8.5.10

export PATH=$PATH:$NS_HOME/bin:$TK_HOME/unix:$TCL_HOME/unix
export LD_LIBRARY_PATH=$NS_HOME/otcl-1.14:$NS_HOME/lib
export TCL_LIBRARY=$TCL_HOME/library

输入 ns,进入成功:
在这里插入图片描述

二、nam安装

1、安装

cd /usr/local/ns2/nam-1.15
./configure
make
sudo make install

2、问题

configure: error: Installation of tcl seems incomplete or can't be found automatically.
Please correct the problem by telling configure where tcl is
using the argument --with-tcl=/path/to/package
(perhaps after installing it),
or the package is not required, disable it with --with-tcl=no.

解决:

sudo ./configure --with-tcl=/home/文件目 录/ns/tcl8.5.10 --with-tcl-ver=8.5.10 --with-tk=/home/文件目录/ns/tk8.5.10 --with-tk-ver=8.5.10

三、实例

cd /usr/local/ns2/ns-2.35/tcl/ex
ns simple.tcl

在这里插入图片描述

  • 1
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

WE-ubytt

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值