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

文章目录

一、ns2安装

1、更新系统源

bash 复制代码
sudo apt-get update
sudo apt-get upgrade

2、准备工作

bash 复制代码
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、安装

bash 复制代码
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

bash 复制代码
linkstate/ls.h:137:20: note: use 'this->erase' instead
make: *** [linkstate/ls.o] Error 1
Ns make failed!

解决:

bash 复制代码
137行:
void eraseAll() { erase(baseMap::begin(), baseMap::end()); } 
-> 
void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }

② 问题2

bash 复制代码
mdart/mdart_adp.cc:108:21: error: reference to 'hash' is ambiguous

解决:

bash 复制代码
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

bash 复制代码
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、环境配置

bash 复制代码
vim ~/.bashrc
source ~/.bashrc

加入一下配置:

bash 复制代码
export NS_HOME=/usr/local/ns2
export TK_HOME=$NS_HOME/tk8.5.10
export TCl_HOME=$NS_HOME/tcl8.5.10

输入 ns,进入成功:

二、nam安装

1、安装

bash 复制代码
cd /usr/local/ns2/nam-1.15
./configure
make
sudo make install

2、问题

bash 复制代码
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.

解决:

bash 复制代码
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

三、实例

bash 复制代码
cd /usr/local/ns2/ns-2.35/tcl/ex
ns simple.tcl
相关推荐
黎阳之光3 小时前
黎阳之光核工厂202应急管控平台|全域实景孪生,筑牢核安全最后一道防线
大数据·人工智能·算法·安全·数字孪生
roman_日积跬步-终至千里4 小时前
【系统架构设计师-综合题-知识点(1)】系统工程与信息技术基础
大数据
Elastic 中国社区官方博客4 小时前
Elasticsearch:快速近似 ES|QL - 第二部分
大数据·数据库·sql·elasticsearch·搜索引擎·全文检索
Cisyam^5 小时前
Bright Data Web Scraping 指南:用 MCP + Dify 自动采集 TikTok 与 LinkedIn数据
大数据·前端·人工智能
captain_AIouo5 小时前
Captain AI功能全景解析——从选品到物流的智能闭环
大数据·人工智能·经验分享·aigc
xunmaiai 8885 小时前
揭秘OZON高性价比选品:如何甄别真正靠谱的合作公司?
大数据·人工智能·python
xlq223226 小时前
43.线程同步
大数据·linux
只说证事6 小时前
CDA数据分析师适合在校生吗?什么时候准备更划算
大数据
DBA大董6 小时前
TDengine3.x 数据文件详解
大数据·linux·时序数据库·dba·tdengine
csgo打的菜又爱玩6 小时前
5.HeartbeatServices启动解析.md
大数据·flink·源代码管理