A repository to contain the code to generate the supporting plots
APACHE-2.0 License
This repository holds the code that is used to run the ns-3 simulations to generate the data and produce the RWPM plots used for my thesis.
This code was written for use with the ns-3.32 simulator and is designed to be run from within the scratch folder.
This is a very simple simulation of 500 nodes in a 1km x 1km area that move around according to the RWPM and it collects the nodes speed and position every second,
pip install matplotlib sem seaborn requests
If building netanim:
(additionally, on ubuntu 20.10, you need to add an additional repo because qt4 no longer ships with it)
Reproducibility is one of the key goals of simulator studies.
Download and build copy of the ns-3.32 all-in-one distribution.
wget https://www.nsnam.org/release/ns-allinone-3.32.tar.bz2
tar xjvf ns-allinone-3.32.tar.bz2
cd ns-allinone-3.32
python3 ./build.py --enable-examples --enable-tests
Change directories to the scratch/
folder of the ns-3.32 source
distribution.
cd ns-3.32/scratch/
Clone this repository.
git clone [email protected]:marshallasch/speedfalloff-plots.git
Change directory back to the ns-3.32
folder of the source distribution
and re-configure ./waf
so it can cache the new changes
cd ..
./waf configure --enable-examples --enable-tests
./waf build
Run the example simulation that is included within the module.
./waf --run 'scratch/speedfalloff-plots/speedfalloff-plots'
This will produce an output file in the form of:
# time(seconds) nodeID xLocation yLocation xVelocity yVelocity
0 0 831.69 955.872 0 0
...
There are a number of flags that can be given to change various parameters.
See ./waf --run 'scratch/speedfalloff-plots/speedfalloff-plots --help'
for the available options
$ docker build \
--build-arg GIT_COMMIT=$(git rev-parse -q --verify HEAD) \
--build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
-t marshallasch/speedfalloff:latest .
The build variant can be configured using the BUILD_PROFILE
build-arg
, it can be set to either debug
, release
, or optimized
.
It is set to debug
by default.
In order to keep a version of the figure generator we have developed a prebuilt docker image that can be used to run the simulation without needing to install ns3 or any of its dependencies.
The prebuilt docker container can be used in one of three ways:
bash
shellThe interactive shell will put you in the ns3 root directory.
Depending on which docker image tag is used ns3 can either be built in debug mode or optimized mode.
The simulation script has been pre installed in the scratch
folder.
SEM has been installed and the sem runner script can be accessed in the parent directory.
docker run --rm -it marshallasch/speedfalloff:optimized bash
Any flags that are given to the container in the docker run command are passed directly to the waf script.
It is equivalent to running ./waf --run "scratch/speedfalloff-plots/speedfalloff-plots <my flags>"
.
docker run --rm marshallasch/speedfalloff:optimized --runTime=5
By giving the sem
command to the docker container the sem script will be run to collect the simulation results and generate the figures.
The results will be put into the /results
directory, which can be mounted so the figures can be used.
docker run --rm -v "$(pwd)/results:/results" marshallasch/speedfalloff:optimized sem
Alternatively you can run the SEM script manually by placing it in the parent directory of the ns3-3.2 folder.
Some modifications will need to me made to the simulation.py
script as it is developed to be used in the docker container.
Specifically the location that it writes the files to should be modified.
To use it ns3 needs to be installed on the system and the script needs to be placed outside of the ns3 directory, as shown below.
Note, this currently requires features from SEM that are only in the develop
branch.
ns-3.32/
scratch/
speedfalloff-plots/
....
simulation.py
This directory structure can be changed somewhat by editing the script, but it must be outside the directory.
Then running ./simulation.py
from the parent directory will compile and run the simulations as well as generate the figures.