Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pgawlowicz committed Jul 7, 2022
1 parent 64962a5 commit e2b573f
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,47 @@ see https://www.nsnam.org/wiki/Installation
```
2. Install ZMQ and Protocol Buffers libs:
```
# to install protobuf-3.6 on ubuntu 16.04:
sudo add-apt-repository ppa:maarten-fonville/protobuf
sudo apt-get update
apt-get install libzmq5 libzmq5-dev
apt-get install libprotobuf-dev
apt-get install protobuf-compiler
```
3. Configure and build ns-3 project (if you are going to use Python virtual environment, please execute these commands inside it):
3. Clone ns3-gym repository in to `contrib` directory and change the branch:
```
cd ./contrib
git clone [email protected]:tkn-tub/ns3-gym.git ./opengym
cd opengym/
git checkout app-ns-3.36+
```
It is important to use the `opengym` as the name of the ns3-gym app directory.

3. Configure and build ns-3 project:
```
# Opengym Protocol Buffer messages (C++ and Python) are build during configure
./waf configure
./waf build
./ns3 configure --enable-examples
./ns3 build
```
Note: Opengym Protocol Buffer messages (C++ and Python) are build during configure.

4. Install ns3gym located in model/ns3gym (Python3 required)
```
pip3 install ./model/ns3gym
cd ./contrib/opengym/
pip3 install -U ./model/ns3gym
```

5. (Optional) Install all libraries required by your agent (like tensorflow, keras, etc.).

6. Run example:
```
cd ./scratch/opengym
cd ./contrib/opengym/examples/opengym/
./simple_test.py
```

7. (Optional) Start ns-3 simulation script and Gym agent separately in two terminals (useful for debugging):
```
# Terminal 1
./waf --run "opengym"
./ns3 run "opengym"
# Terminal 2
cd ./scratch/opengym
cd ./contrib/opengym/examples/opengym/
./test.py --start=0
```

Expand All @@ -65,8 +71,10 @@ All examples can be found [here](./examples/).
import gym
import ns3gym
import MyAgent
from ns3gym import ns3env
env = gym.make('ns3-v0')
#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()
Expand Down Expand Up @@ -128,23 +136,23 @@ Moreover, using the event-based interface, we already have an example Python Gym

In order to run it, please execute:
```
cd ./scratch/rl-tcp
cd ./contrib/opengym/examples/rl-tcp/
./test_tcp.py
```

Or in two terminals:
```
# Terminal 1:
./waf --run "rl-tcp --transport_prot=TcpRl"
./ns3 run "rl-tcp --transport_prot=TcpRl"
# Terminal 2:
cd ./scratch/rl-tcp/
cd ./contrib/opengym/examples/rl-tcp/
./test_tcp.py --start=0
```

Note, that our Python TCP NewReno implementation achieves the same number of transmitted packets like the one implemented in ns3 (see the output of ns-3 simulation, i.e. `RxPkts: 5367` in both cases). Please execute the following command to cross-check:
```
./waf --run "rl-tcp --transport_prot=TcpNewReno"
./ns3 run "rl-tcp --transport_prot=TcpNewReno"
```

Contact
Expand Down

0 comments on commit e2b573f

Please sign in to comment.