【网络仿真】 ns3-gym 安装 & 介绍

1 Introduction

OpenAI Gym is a toolkit for reinforcement learning (RL) widely used in research. The network simulator ns–3 is the de-facto standard for academic and industry studies in the areas of networking protocols and communication technologies. ns3-gym is a framework that integrates both OpenAI Gym and ns-3 in order to encourage usage of RL in networking research.

ns3-gym即结合ns-3和OpenAI Gym开发的系统框架。主要是为二者设计了一个接口,通过接口可以传递states和actions,通信使用ZMQ套接字实现。用于基于强化学习的网络研究(RL in networking (RLN) research)[1]

在这里插入图片描述

2 Installation

首先,确保已安好ns3-2.29。
(Ubuntu尽量使用18.04,之前使用20.XX版本死活安不上)
安装包从[3]可以下载到。
安装步骤参照[7]
Protocol Buffers library用于序列化信息,在[6]中可以下载到。

3 Examples

安装好后,通过简单的例子学习一下如何使用ns3-gym[5]

3.1 Basic Interface

  1. 在Python脚本中,使用gym.make('ns3-v0'),启动位于当前工作目录的ns-3仿真脚本。
import gym
import ns3gym
import MyAgent

env = gym.make('ns3-v0')
obs = env.reset()
agent = MyAgent.Agent()

while True:
  action = agent.get_action(obs)
  obs, reward, done, info = env.step(action)

  if done:
    break
env.close()
  1. 任何ns-3仿真脚本可以用作Gym环境。只需要实例化OpenGymInterface并实现ns3-gym C++接口中的函数,如下所示:
Ptr<OpenGymSpace> GetObservationSpace();
Ptr<OpenGymSpace> GetActionSpace();
Ptr<OpenGymDataContainer> GetObservation();
float GetReward();
bool GetGameOver();
std::string GetExtraInfo();
bool ExecuteActions(Ptr<OpenGymDataContainer> action);

4 References

[1] Gawlowicz, Piotr & Zubow, Anatolij. (2019). ns-3 meets OpenAI Gym: The Playground for Machine Learning in Networking Research. 113-120. 10.1145/3345768.3355908. http://www.tkn.tu-berlin.de/fileadmin/fg112/Papers/2019/gawlowicz19_mswim.pdf

[2] Gawowicz, P. , & Zubow, A. . (2018). Ns3-gym: extending openai gym for networking research.

[3] ns3-gym-master, https://github.com/tkn-tub/ns3-gym , 链接: https://pan.baidu.com/s/1ZMi1SHmX2tXs_wzCz7UObQ 提取码: iysb

[4] NS3-GYM App Store, https://apps.nsnam.org/app/ns3-gym/

[5] ns3-gym 例子, https://github.com/tkn-tub/ns3-gym/tree/master/scratch

[6] protobuf, https://github.com/protocolbuffers/protobuf

[7] ns3gym与ns3ai的安装方法https://blog.youkuaiyun.com/m0_49448331/article/details/112616074

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值