Skip to content

Instantly share code, notes, and snippets.

@SGman98
Last active December 3, 2024 02:38
Show Gist options
  • Select an option

  • Save SGman98/fe8606bc307258ca672202ee46b185e4 to your computer and use it in GitHub Desktop.

Select an option

Save SGman98/fe8606bc307258ca672202ee46b185e4 to your computer and use it in GitHub Desktop.

NS3 + opengym manual installation

references: ns3 ns3-gym

Run the one line command or follow the step by step guide

One line command

source <(curl -s https://gist.githubusercontent.com/SGman98/fe8606bc307258ca672202ee46b185e4/raw/setup-ns3-opengym)

Step by step

System setup

sudo apt update && sudo apt upgrade

Create workspace directory in ~/workspace

mkdir ~/workspace && cd ~/workspace

Install ns3

sudo apt install g++ python3
git clone https://gitlab.com/nsnam/ns-3-allinone.git
cd ns-3-allinone
python3 download.py -n ns-3.35

Install opengym

sudo apt install libzmq5 libzmq3-dev libprotobuf-dev protobuf-compiler python3-pip
cd ~/workspace/ns-3-allinone/ns-3.35
git clone -b app https://github.com/tkn-tub/ns3-gym.git ./contrib/opengym

Enable other modules

  • visualizer

    pip install PyBindGen
    sudo apt install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3
  • dpdk

    sudo apt install libdpdk-dev

    fix file

    sed -i '415s/CALL_MASTER/CALL_MAIN/' ~/workspace/ns-3-allinone/ns-3.35/src/fd-net-device/model/dpdk-net-device.cc

Build ns3

./waf configure --enable-examples
./waf build

Build ns3gym

cd ~/workspace/ns-3-allinone/ns-3.35/contrib/opengym/
pip3 install --user ./model/ns3gym

Downgrade protobuf

pip install protobuf==3.20.

Run examples

Simple test

cd ~/workspace/ns-3-allinone/ns-3.35/contrib/opengym/examples/opengym
./simple_test.py

Test simulation

Terminal 1

cd ~/workspace/ns-3-allinone/ns-3.35/
./waf --run "opengym"

Terminal 2

cd ~/workspace/ns-3-allinone/ns-3.35/contrib/opengym/examples/opengym/
./test.py --start=0

Test viz

cd ~/workspace/ns-3-allinone/ns-3.35/
./waf --run first --vis
#!/bin/bash
# Update/Upgrade system
sudo apt -y update && sudo apt -y upgrade
# Install ns3
sudo apt -y install g++ python3 python3-pip
git clone https://gitlab.com/nsnam/ns-3-allinone.git ~/workspace/ns-3-allinone
python3 ~/workspace/ns-3-allinone/download.py -n ns-3.35
# Install opengym
sudo apt -y install libzmq5 libzmq3-dev libprotobuf-dev protobuf-compiler
git clone -b app https://github.com/tkn-tub/ns3-gym.git ~/workspace/ns-3-allinone/ns-3.35/contrib/opengym
# Install extra modules
sudo apt -y install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3
pip install PyBindGen
sudo apt -y install libdpdk-dev
sed -i '415s/CALL_MASTER/CALL_MAIN/' ~/workspace/ns-3-allinone/ns-3.35/src/fd-net-device/model/dpdk-net-device.cc
# Build
cd ~/workspace/ns-3-allinone/ns-3.35/
./waf configure --enable-examples
./waf build
# Install opengym...
pip install --user ~/workspace/ns-3-allinone/ns-3.35/contrib/opengym/model/ns3gym
# Fix protobuf version
pip install protobuf==3.20.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment