This installation works on Ubuntu 22.04 and macOS 15.0 or higher.
- Boost C++ libraries
- Ubuntu:
sudo apt install libboost-all-dev
- macOS:
brew install boost
- Ubuntu:
- Protocol buffers
- Ubuntu:
sudo apt install libprotobuf-dev protobuf-compiler
- macOS:
brew install protobuf
- Ubuntu:
- pybind11
- Ubuntu:
sudo apt install pybind11-dev
- macOS:
brew install pybind11
- Ubuntu:
- A Python virtual environment dedicated for ns3-ai (highly recommended)
- For example, to use conda to create an environment named
ns3ai_env
with python version 3.11:conda create -n ns3ai_env python=3.11
.
- For example, to use conda to create an environment named
-
If a Python virtual environment is used, activate it. The absolute path to the Python executable of this environment, denoted as
<path-to-python>
, will be later passed to cmake vians3
script. You can find the path by first activate it and thenwhich python
. -
Clone this repository at
contrib/ai
cd YOUR_NS3_DIRECTORY
git clone https://github.com/hust-diangroup/ns3-ai.git contrib/ai
- Configure and build the
ai
library
./ns3 configure --enable-examples -- -DPython_EXECUTABLE=<path-to-python> -DPython3_EXECUTABLE=<path-to-python>
./ns3 build ai
- Setup Python interfaces.
pip install -e contrib/ai/python_utils
pip install -e contrib/ai/model/gym-interface/py
- Build the examples (optional)
All targets named ns3ai_*
can be built separately.
# build all examples in all versions
./ns3 build ns3ai_apb_gym ns3ai_apb_msg_stru ns3ai_apb_msg_vec ns3ai_multibss ns3ai_rltcp_gym ns3ai_rltcp_msg ns3ai_ratecontrol_constant ns3ai_ratecontrol_ts ns3ai_ltecqi_msg
# build A-Plus-B example
# with Gym interface
./ns3 build ns3ai_apb_gym
# with Message interface - struct based
./ns3 build ns3ai_apb_msg_stru
# with Message interface - vector based
./ns3 build ns3ai_apb_msg_vec
# build Multi-BSS example
# with Message interface - vector based
./ns3 build ns3ai_multibss
# build RL-TCP example
# with Gym interface
./ns3 build ns3ai_rltcp_gym
# with Message interface - struct based
./ns3 build ns3ai_rltcp_msg
# build Rate-Control examples
# constant rate example, with Message interface - struct based
./ns3 build ns3ai_ratecontrol_constant
# Thompson Sampling example, with Message interface - struct based
./ns3 build ns3ai_ratecontrol_ts
# build LTE-CQI example
# with Message interface - struct based
./ns3 build ns3ai_ltecqi_msg