ns3gym与ns3ai的安装方法

编译运行的常用命令

1,针对ns3主项目的编译命令

分两步:第一,./waf configure;第二,./waf(或者./waf build)

详见《开源网络模拟器ns3》P13

2,针对多脚本同时运行的编译命令

ns3-ai的相关笔记

安装方法

基本要求:一定要检查系统的python版本是否是python3或以上,否则无法安装ns3-ai的Python-Interface。ns3-ai适配的ns3版本为ns-3.30(务必使用ns-3.30),应先在Ubuntu系统下(以Ubuntu 16.04为例)成功安装并编译好ns-3.30后再进行下列操作步骤。

参考资料:

1,ns3-ai文献:Yin H, Liu P, Liu K, et al. ns3-ai: Fostering Artificial Intelligence Algorithms for Networking Research[C]//Proceedings of the 2020 Workshop on ns-3. 2020: 57-64.

2,ns3-ai在NS3 App Store上的网页介绍(推荐使用,结合下面的详细安装步骤即可)

ns-3 App Store - ns3-ai

3,ns3-ai在GitHub上的开源代码网页(也可成功安装)

GitHub - hust-diangroup/ns3-ai: Enable the interaction between ns-3 and popular frameworks using Python, which mean you can train and test your AI algorithms in ns-3 without changing any frameworks you are using now!

详细安装步骤:

1,将网上下载的源码(推荐使用“参考资料2”中的源码)解压后再添加到ns-3.30中的contrib目录下,并重新命名为ns3-ai

2,重新编译ns-3.30

./waf configure

./waf

3,Add Python interface

3.1,Install(Python3 is used and tested)

cd $YOUR_NS3_CODE/contrib/ns3-ai/py_interface

python setup.py install --user

步骤3.1完成后,则安装完毕

3.2,Baisc usage(此处应该是介绍Python Interface的用途,以下代码在安装步骤中不需要执行)

import py_interface

py_interface.Init(1234, 4096) # key poolSize

v = NS3BigVar(233, c_int*10)

with v as o:

for i in range(10):

o[i] = c_int(i)

print(*o)

py_interface.FreeMemory()

4,测试是否成功安装

RL-TCP Examples(ns3和ai是在两个终端窗口上运行的)

4.1,Run ns-3 example(终端窗口1):

cp -r contrib/ns3-ai/example/rl-tcp scratch/
./waf --run "rl-tcp"

4.2,Run Python code(终端窗口2):

cd contrib/ns3-ai/example/rl-tcp/
python testtcp.py

NOTE: Currently the RL test in python script is not fully enabled, coming soon.

问题:目前在4.2步骤中运行命令后无反应,问题待解决(可查阅GitHub相关issue中的问答记录)

ns3-gym的相关笔记

安装方法

基本要求:ns3-gym适配的ns3版本为ns-3.29(务必使用ns-3.29),ns3-gym官网上示意Ubuntu16.04为例进行介绍安装步骤的(不排除可兼容更高版本的Ubuntu系统)。应先在Ubuntu系统下成功安装并编译好ns-3.29后再进行下列操作步骤。

参考资料:

1,ns3-gym文献:Gawłowicz P, Zubow A. Ns-3 meets openai gym: The playground for machine learning in networking research[C]//Proceedings of the 22nd International ACM Conference on Modeling, Analysis and Simulation of Wireless and Mobile Systems. 2019: 113-120.

2,ns3-gym在NS3 App Store上的网页介绍(推荐使用,结合下面的详细安装步骤即可)

ns-3 App Store - ns3-gym: OpenAI Gym integration

3,ns3-gym在GitHub上的开源代码网页(编译时会出现ZMQ报错,可查阅GitHub上的closed issues寻找解决方法)

GitHub - tkn-tub/ns3-gym: ns3-gym - The Playground for Reinforcement Learning in Networking Research

详细安装步骤:

1,Installation from the download button

Download the source archive(推荐使用“参考资料2”中的源码) and unpack it:

tar -xzf ns3-gym-1.0.0.tar.gz

Move (and rename) the ns3-gym-1.0.0 directory to(将解压后的文件重命名为opengym,并放置到contrib目录内):

ns-3.29/contrib/opengym

注:放置到src目录内也可以安装成功

2,Install ZMQ and Protocol Buffers libs:

Note: to install protobuf-3.6 on ubuntu 16.04, run:

sudo add-apt-repository ppa:maarten-fonville/protobuf

sudo apt-get update

Then:

sudo apt-get install libzmq5 libzmq5-dev -y

sudo apt-get install libprotobuf-dev -y

sudo apt-get install protobuf-compiler -y

3,Configure and build ns-3 project:

Note: if you use Python virtual environment, please execute these commands inside it.

Note: Opengym Protocol Buffer messages (C++ and Python) are build during configure.

./waf configure --enable-examples

./waf build

(成功运行上述命令后,可以看到控制台输出的Models built列表中包含了opengym)

4,Install ns3gym Python module.

Note: Python3 is recommended.

4.1,Compile Protobuf messages manually (not required if ./waf configure was executed):

(如果第3步中使用./waf configure命令编译,未加上--enable-examples,则无需进行4.1步骤)

cd ./ns-3.29/contrib/opengym/

protoc -I=./model/ --python_out=./model/ns3gym/ns3gym ./model/messages.proto

4.2,Install ns3gym Python module:

pip3 install ./ns-3.29/contrib/opengym/model/ns3gym

(官网上使用了pip,可在不同机器上尝试pip或pip3)

5,测试是否成功安装

5.1,测试用例1

cp -r ./contrib/opengym/examples/opengym scratch/

cd ./scratch/opengym

./simple_test.py

5.2,测试用例2

# Terminal 1

cp -r contrib/ns3-gym/example/opengym scratch/

./waf --run "opengym"

# Terminal 2

cd ./scratch/opengym

./test.py --start=0

  • 1
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 12
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值