Setup - ns3 Simulator
Setup - ns3 Simulator
Setup - ns3 Simulator
bz2
7 tar jxvf ns-allinone-3.36.1.tar.bz2
8 cd ns-allinone-3.36.1/
9 ./build.py --enable-examples --enable-tests
10 cd ns-3.36.1/
11 ./ns3 run hello-simulator
download
tar -xzf ns3-gym-1.0.2.tar.gz
move opengym to ns-allinone-3.36.1/contrib
127 apt-get install libzmq5 libzmq5-dev
128 sudo apt-get install libzmq5 libzmq5-dev
129 apt-get install libprotobuf-dev
130 sudo apt-get install libprotobuf-dev
131 apt-get install protobuf-compiler
132 sudo apt-get install protobuf-compiler
133 ./ns3 configure --enable-examples
134 /home/hp/ns-allinone-3.36.1/ns-3.36.1/ns3 configure --enable-examples
135 /home/hp/ns-allinone-3.36.1/ns-3.36.1/ns3 build
cd ./contrib/opengym/
pip3 install -U ./model/ns3gym
cd ./examples/opengym/
172 ./test.py
173 ./simple_test.py
Installation ns3-mmwave
This repository contains a complete ns-3 installation with the addition of the
mmwave module.
ns3-gym
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.
It is important to use the opengym as the name of the ns3-gym app directory.
Run example:
cd ./contrib/opengym/examples/opengym/
./simple_test.py
(Optional) Start ns-3 simulation script and Gym agent separately in two terminals
(useful for debugging):
# Terminal 1
./ns3 run "opengym"
# Terminal 2
cd ./contrib/opengym/examples/opengym/
./test.py --start=0
Examples
All examples can be found here.
Basic Interface
Example Python script. Note, that gym.make('ns3-v0') starts ns-3 simulation script
located in current working directory.
import gym
import ns3gym
import MyAgent
from ns3gym import ns3env
#env = gym.make('ns3-v0') <--- causes some errors with the new OpenAI Gym
framework, please use ns3env.Ns3Env()
env = ns3env.Ns3Env()
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()
Any ns-3 simulation script can be used as a Gym environment. This requires only to
instantiate OpenGymInterface and implement the ns3-gym C++ interface consisting of
the following functions:
Ptr<OpenGymSpace> GetObservationSpace();
Ptr<OpenGymSpace> GetActionSpace();
Ptr<OpenGymDataContainer> GetObservation();
float GetReward();
bool GetGameOver();
std::string GetExtraInfo();
bool ExecuteActions(Ptr<OpenGymDataContainer> action);
Note, that the generic ns3-gym interface allows to observe any variable or
parameter in a simulation.
sudo apt-get install autoconf automake libtool curl make g++ unzip -y
git clone https://github.com/google/protobuf.git
cd protobuf
git submodule update --init --recursive
for ns3-dev
cd ./ns3-dev
solution :
using “https://github.com/tkn-tub/ns3-gym/pull/72/files”
#ifdef I
#undef I
#endif