This code is provided as-is, with no guarantee. Try to understand the python
code, and read these instructions carefully.
- Create an environment variable named
$NS3_ROOT_DIR
in your Linux operating system. The environment variable should point to yourns-3
root directory. For example, on my computer, I created the environment variable as follows:
export NS3_ROOT_DIR="/home/adil/eclipse-workspace/ns-3.30.1-eclipse/ns-3.30.1"
- Your user-created modules should be created in a directory under
$NS3_ROOT_DIR/contrib
-
Create a module as a folder under
$NS3_ROOT_DIR/contrib
, let's call ituser
. Do not place C++ header and code files directly underuser
directory, put them in subfolders. For example, create folders namedmodel
,helper
andexamples
. This scripts scans those subfolder and generate awscript
file written inpython
.- If you have a folder named
examples
, it will treated differently.
- If you have a folder named
-
Run this script with
--name=user
to scan the$NS3_ROOT_DIR/contrib/user
folder. This will create two files namedwscript_user
andwscript_user_examples
.
./MakeWscript.py --name=user
-
Copy the generated
wscript_user
to$NS3_ROOT_DIR/contrib/user/wscript
and thewscript_examples
to$NS3_ROOT_DIR/contrib/user/wscript
.- Supplying the
--m
argument make it automatically copy thewscript
files to their destination
- Supplying the
-
You can modify the resulting
wscript
files by modifying the modules they depend on, or to comment out whether you want to build examples.
-
In your
ns-3
you need to run./waf --configure
to scan for changes undercontrib
directory.- This will create a
.h
file namedmodulename-module.h
. For example, if our module is nameduser
, it will create a file nameduser-module.h
that includes all the header files in your module.
- This will create a
-
To include your modules from your
ns-3
simulations, simply perform an include of theuser-module.h
file#include "ns3/user-module.h"
For any questions you can contact me [email protected]
or [email protected]