Unofficial docker implementation of ndnSIM.
Dockerfiles can be found in the repository page.
ndnSIM is a patched version of the popular ns-3 network simulator, for details please visit the ndnSIM Introduction page.
Features about that Docker image:
- providing both
optimizedanddebugcompiled ndnSIM (v2.8+ only) - Python 2 for old simulations support (v2.8+ only)
pipenvinstalled for your custom Python (2 & 3) dependencies (v2.8+ only)- R &
renvinstalled for your custom R dependencies (v2.8+ only) docker-composewith custom volume support for your simulations- visualizer dependencies installed
Feel free to contribute with issues/PRs!
A simulation can be every NDN waf project in your drive, you just need to
specify the absolute path.
Logging can be enabled using the NS_LOG variable, e.g. NS_LOG=ndn.Producer:ndn.Consumer.
As reported in ndnsim.net, to show logs you need ndnSIM to be compiled in debug mode.
From version 2.8 this Docker image supports optimized mode by default (e.g. 2.8 tag)
and debug mode appending -debug (e.g. 2.8-debug): clearly you need to edit the docker run
commands you see in this doc and in docker-compose.yml file.
In that case you will need to configure the simulation with the debug option enabled:
$ ./waf configure --debug
$ NS_LOG=ndn.Producer:ndn.Consumer ./waf --run=ndn-simpleIf you want to directly run a simulation into the docker container you can use the following command.
$ docker run \
-u $(id -u):$(id -g) \
-it \
emrevoid/ndnsim:2.8 \
/home/ndn/ndnSIM/ns-3/waf --run=bench-simulatorIf you want to spawn a shell replace the last command line with bash, then
execute the command. You can now type commands into the docker container. To run
a simulation move into the proper location and run the waf command.
$ ./waf --run=bench-simulatorTo run the visualizer you need to use the --vis option to the waf command.
Install x11docker to securely run the visualizer GUI.
$ x11docker \
-- -v ~/hub/docker-ndnsim/simulation/:/simulation \
-- emrevoid/ndnsim:2.8 \
/home/ndn/ndnSIM/ns-3/waf --run=bench-simulator --visIf you don't want to use it for any reason, check out their wiki.
Example:
$ xhost +SI:localuser:$(id -un)
$ docker run --rm \
-it \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
-v ~/hub/docker-ndnsim/simulation/:/simulation \
--ipc=host \
--user $(id -u):$(id -g) \
--cap-drop=ALL \
--security-opt=no-new-privileges \
emrevoid/ndnsim:2.8 \
/home/ndn/ndnSIM/ns-3/waf --run=bench-simulator --visAs reported into ndnsim.net
you can write and run simulations directly inside the NS-3 scratch/ or src/ndnSIM/examples/ folders.
But for separation of concerns it is recommended to use a separated repository for your scenario stuff (simulation sources, extensions, graph scripts...).
To make it available into the dockerized ndnSIM you can use the --volume option to mount local files into the isolated environment.
$ docker run \
-u $(id -u):$(id -g) \
-it \
-v ~/hub/docker-ndnsim/simulation/:/simulation \
emrevoid/ndnsim:2.8 \
/simulation/waf configure && \
/simulation/waf --run=simulation-source-fileIf you want to use visualizer module while running simulations from a separate repository you have to previously run the waf shell into the NS-3 folder:
~/ndnSIM/ns-3$ ./waf shell
$ cd ~/simulation
$ ./waf configure
$ PKG_LIBRARY_PATH=/usr/local/lib ./waf --run ndn-simple --visInto the docker-compose.yml file you can edit the volumes and entrypoint
entries according to your simulation location.
Comment the entrypoint entry if you want to spawn the container shell.
$ UID=$(id -u) GID=$(id -g) docker-compose run --rm ndnsimUsing docker-compose you will not need to use x11docker.
From Using renv with Docker.
$ RENV_PATHS_CACHE_HOST=$(pwd)/simulation/renv_modules
$ RENV_PATHS_CACHE_CONTAINER=/home/ndn/renv_modules
$ docker run \
-u $(id -u):$(id -g) \
-it \
-e "RENV_PATHS_CACHE=${RENV_PATHS_CACHE_CONTAINER}" \
-v "${RENV_PATHS_CACHE_HOST}:${RENV_PATHS_CACHE_CONTAINER}" \
emrevoid/ndnsim:2.8 \
/home/ndn/ndnSIM/ns-3/waf --run=bench-simulatorFor the docker-compose version just add the proper options as yml entries.
See here.
