Network simulator 2 version 2.35 running inside docker
-
Install Docker.
-
Download docker image from public Docker Hub Registry:
docker pull ekiourk/ns2
(alternatively, you can build an image from Dockerfile:
docker build -t ns2 github.com/ekiourk/docker-ns2
)
The following command will start the container and run all validation tests
docker run -it ekiourk/ns2 ./validate
docker run -it ekiourk/ns2 ns
-
Create a tcl script or download one using
wget http://nile.wpi.edu/NS/Example/ns-simple.tcl
locally -
Run
docker run -it -v $PWD/ns-simple.tcl:/ns-simple.tcl ekiourk/ns2 ns /ns-simple.tcl
by using the -v flag to put the script from your current directory inside the root directory in the container
-
First run container with bash in order to get a prompt inside the container. Make sure you mount the X11 socket and set the DISPLAY environment variable
docker run -it -v $PWD/ns-simple.tcl:/ns-simple.tcl -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY ekiourk/ns2 bash
-
After you are inside the container run ns /ns-simple.tcl and NAM should open ready to animate the simulation
If there are problems starting NAM then try to set the argument --cap-add=SYS_ADMIN and run xhost local:root
on the host