From a29625a6efa8fa017934b0d4b40965be3bdd8841 Mon Sep 17 00:00:00 2001 From: Emanuele Giona Date: Wed, 14 Feb 2024 12:26:45 +0100 Subject: [PATCH] ns3-base: release v1.0.0 --- CHANGELOG.md | 21 +++ CITATION.cff | 26 +++ README.md | 210 +++++++++++++++++++++- build-all.sh | 38 ++++ u18.04-n3.33/Dockerfile | 94 ++++++++++ u18.04-n3.33/ns3-build/build-debug.sh | 59 ++++++ u18.04-n3.33/ns3-build/build-optimized.sh | 60 +++++++ u18.04-n3.33/ns3-utils/Makefile | 182 +++++++++++++++++++ u18.04-n3.34/Dockerfile | 94 ++++++++++ u18.04-n3.34/ns3-build/build-debug.sh | 59 ++++++ u18.04-n3.34/ns3-build/build-optimized.sh | 60 +++++++ u18.04-n3.34/ns3-utils/Makefile | 182 +++++++++++++++++++ u18.04-n3.35/Dockerfile | 94 ++++++++++ u18.04-n3.35/ns3-build/build-debug.sh | 59 ++++++ u18.04-n3.35/ns3-build/build-optimized.sh | 60 +++++++ u18.04-n3.35/ns3-utils/Makefile | 182 +++++++++++++++++++ u20.04-n3.40/Dockerfile | 94 ++++++++++ u20.04-n3.40/ns3-build/build-debug.sh | 59 ++++++ u20.04-n3.40/ns3-build/build-optimized.sh | 60 +++++++ u20.04-n3.40/ns3-utils/Makefile | 182 +++++++++++++++++++ u22.04-n3.40/Dockerfile | 94 ++++++++++ u22.04-n3.40/ns3-build/build-debug.sh | 59 ++++++ u22.04-n3.40/ns3-build/build-optimized.sh | 60 +++++++ u22.04-n3.40/ns3-utils/Makefile | 182 +++++++++++++++++++ u22.04-n3.41/Dockerfile | 94 ++++++++++ u22.04-n3.41/ns3-build/build-debug.sh | 59 ++++++ u22.04-n3.41/ns3-build/build-optimized.sh | 60 +++++++ u22.04-n3.41/ns3-utils/Makefile | 182 +++++++++++++++++++ 28 files changed, 2663 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 CITATION.cff create mode 100755 build-all.sh create mode 100644 u18.04-n3.33/Dockerfile create mode 100644 u18.04-n3.33/ns3-build/build-debug.sh create mode 100644 u18.04-n3.33/ns3-build/build-optimized.sh create mode 100644 u18.04-n3.33/ns3-utils/Makefile create mode 100644 u18.04-n3.34/Dockerfile create mode 100644 u18.04-n3.34/ns3-build/build-debug.sh create mode 100644 u18.04-n3.34/ns3-build/build-optimized.sh create mode 100644 u18.04-n3.34/ns3-utils/Makefile create mode 100644 u18.04-n3.35/Dockerfile create mode 100644 u18.04-n3.35/ns3-build/build-debug.sh create mode 100644 u18.04-n3.35/ns3-build/build-optimized.sh create mode 100644 u18.04-n3.35/ns3-utils/Makefile create mode 100644 u20.04-n3.40/Dockerfile create mode 100644 u20.04-n3.40/ns3-build/build-debug.sh create mode 100644 u20.04-n3.40/ns3-build/build-optimized.sh create mode 100644 u20.04-n3.40/ns3-utils/Makefile create mode 100644 u22.04-n3.40/Dockerfile create mode 100644 u22.04-n3.40/ns3-build/build-debug.sh create mode 100644 u22.04-n3.40/ns3-build/build-optimized.sh create mode 100644 u22.04-n3.40/ns3-utils/Makefile create mode 100644 u22.04-n3.41/Dockerfile create mode 100644 u22.04-n3.41/ns3-build/build-debug.sh create mode 100644 u22.04-n3.41/ns3-build/build-optimized.sh create mode 100644 u22.04-n3.41/ns3-utils/Makefile diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4b1a9cd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog + +## Release v1.0.0 + +[Link to release][v100] + +`ns3-base` initial release. + +Images follow the same Dockerfile structure and additional utilities as seen in [`ns3-woss` v2.0.1][img-inspo] and later versions. + +Supported versions: + +- OS: Ubuntu 18.04 LTS, 20.04 LTS, 22.04 LTS + +- ns-3: from 3.33 to 3.41 + + + + +[v100]: ./releases/tag/v1.0.0 +[img-inspo]: https://github.com/SENSES-Lab-Sapienza/ns3-woss-docker/releases/tag/v2.0.1 diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..59591f4 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,26 @@ +# This CITATION.cff file was generated with cffinit. +# Visit https://bit.ly/cffinit to generate yours today! + +cff-version: 1.2.0 +title: ns-3 Docker images +message: >- + If you use any of the Docker images described in + this repository, please cite this work using the + following metadata. +type: software +authors: + - given-names: Emanuele + family-names: Giona + email: giona@di.uniroma1.it + affiliation: >- + Department of Computer Science, Sapienza + University of Rome + orcid: 'https://orcid.org/0000-0003-0871-7156' +url: >- + https://github.com/emanuelegiona/ns3-base-docker +keywords: + - docker + - ns-3 + - network-simulation +license: MIT +doi: 10.5281/zenodo.10657287 diff --git a/README.md b/README.md index 45f502d..bbb2b49 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,208 @@ -# ns3-base -ns-3 installations using Docker +# ns-3 base Docker images + +[ns-3][ns3] installations using [Docker][docker]. + +The scope of this repository is to automate the installation process of +ns-3 in order to provide a hassle-free setup process for a +simulation environment. + +Images ship with ns-3 installations, provided pre-built in `debug` and `optimized` profiles, with the *former* being the active version on a first run; utility scripts to quickly switch between them are provided (see below). + +## Available configurations *(latest first)* + +Docker image name: [**`egiona/ns3-base`**][docker-hub-repo]. + +| Docker image tag | OS | ns-3 | Build system | Dockerfile | +| :---: | :---: | :---: | :---: | :---: | +| [`u22.04-n3.41`][image6] | Ubuntu 22.04 | [3.41][ns3.41] | CMake | [link][file6] | +| [`u22.04-n3.40`][image5] | Ubuntu 22.04 | [3.40][ns3.40] | CMake | [link][file5] | +| [`u20.04-n3.40`][image4] | Ubuntu 20.04 | [3.40][ns3.40] | CMake | [link][file4] | +| [`u18.04-n3.35`][image3] | Ubuntu 18.04 | [3.35][ns3.35] | Waf | [link][file3] | +| [`u18.04-n3.34`][image2] | Ubuntu 18.04 | [3.34][ns3.34] | Waf | [link][file2] | +| [`u18.04-n3.33`][image1] | Ubuntu 18.04 | [3.33][ns3.33] | Waf | [link][file1] | + +Full changelog can be found at [this page](./CHANGELOG.md). + + + + + +### Contributing + +Any problems should be reported via the GitHub issue tracker. + +Users are welcomed to contribute new images (_e.g._ different base image or other ns-3 versions) via Pull Request and adhering to the following style: + +- Directory named `` with: `A` equal to an arbitrary versioned base image short-hand (_i.e._ `u20.04` refers to Ubuntu 20.04); and `B` equal to the ns-3 version bundled (_i.e._ `n3.40` refers to ns-3.40). + + Such directory name will also be used as image tag. + +- The directory shall contain a well-commented `Dockerfile` for the image creation. + + Other contents may be freely modified, although for uniformity purposes it is advised to maintain the same functionality they provide. + The `ns3-build` directory contains useful scripts to swap between ns-3 builds and development utilities; if modified, you should take care of solving this task. + +# Usage guidelines + +## Core instructions + +> The following instructions should apply to all platforms supported by Docker. +However, _utility scripts_ are only provided for UNIX-like systems. + +1. Install Docker (please refer to [official guidelines][docker-install] w.r.t. your own OS) + +2. Select your desired Docker image according to the table above using + + `docker pull egiona/ns3-base:` + + _Please refer to the table above for latest available tags._
+ _Usage of old tags found on [DockerHub][docker-hub-repo] is generally discouraged, unless you have a reason to do it._ + +3. Retrieve the desired image identifier using + + `docker images` + +4. Launch a container using the selected image using + + `docker run -td --name ` + +5. Launch a live terminal from the container using + + `docker exec -it /bin/bash` + + _You can obtain a running container's ID using_  `docker ps` _, or_  `docker container ls -a` _(the latter also includes containers in any state)._ + +## Utility scripts + +1. You can switch between `debug` and `optimized` builds of ns-3 (see [details][ns3-builds]) using + + [`./build-debug.sh`][latest-debug] or [`./build-optimized.sh`][latest-optimized] respectively. + + The aforementioned utility scripts are placed in the directory `/home` of a container's filesystem. + +2. A utility script in the form of a [Makefile][latest-makefile] is provided. + + Similarly to [build scripts][latest-build], this utility Makefile is placed in the directory `/home` of a container's filesystem. + + This script allows for easy decoupling of development directory from ns-3's source directory. + Indeed, it is possible to keep novel modules and program driver scripts outside `src` (or `contrib`) and `scratch` directories of the ns-3 installation directory during development, and only copying them afterwards. + This is especially useful when paired with mounted directories. + + Multiple targets are present, allowing: ns-3 current version checking, compilation and execution of simulation driver programs (copying them to `scratch` subdir first), management of ns-3 modules (creation in `contrib` subdir and copy outside, synchronization of contents, elimination), and debugging (GNU debugger, Valgrind, ns-3 tests). + + Use the following command for all details: + + `make help` + +## Optional instructions + +> As long as you `docker restart` the same container, any modification to its contents will be preserved. +However, it is advisable to keep a _local backup copy_ of your modules and experiment results. + +1. Copy an arbitrary local file into the container's filesystem using + + `docker cp :` + +2. Copy an arbitrary container's file to local filesystem using + + `docker cp : ` + +3. Mount a local directory into a container (just once, instead of `docker run`) using + + `docker run -td --mount type=bind,source=,target= --name ` + + _Paths to be mounted must be absolute._ + + _This is only needed the **first time** a container is instantiated, subsequent calls to_  `docker start` _on the same container will automatically load the mounted directory._ + + _**Warning:** existing container contents at the same target path will be overwritten with the ones provided by the local filesystem._ + +4. An environment variable `CXX_CONFIG` is available for user-defined scripts to adapt their GCC compilation parameters; by default, such variable holds the following contents: + + `CXX_CONFIG="-Wall -Werror -Wno-unused-variable"` + + Moreover, [build scripts][latest-build] provide an exit value reflective of ns-3's configuration and build outcome: this might be leveraged in CD/CI pipelines. + +# Citing this work + +If you use any of the Docker images described in this repository, please cite this work using any of the following methods: + +**APA** +``` +Giona, E. ns-3 Docker images [Computer software]. https://doi.org/10.5281/zenodo.10657287 +``` + +**BibTeX** +``` +@software{Giona_ns-3_Docker, +author = {Giona, Emanuele}, +doi = {10.5281/zenodo.10657287}, +license = {MIT}, +title = {{ns-3 Docker images}}, +url = {https://github.com/emanuelegiona/ns3-base-docker} +} +``` + +Bibliography entries generated using [Citation File Format][cff] described in the [CITATION.cff][citation] file. + +# License + +**Copyright (c) 2024 Emanuele Giona ([SENSES Lab][senseslab], Sapienza University of Rome)** + +This repository and Docker images themselves are distributed under [MIT license][docker-license]. + +However, ns-3 is distributed under its [own license][ns3-license]. +All installed packages may also be subject to their own license, and the license chosen for the Docker images does not necessarily apply to them. + +**Diclaimer: Docker, Ubuntu, ns-3, and other cited or included software belongs to their respective owners.** + + + +[ns3]: https://www.nsnam.org/ +[docker]: https://www.docker.com/ + +[docker-hub-repo]: https://hub.docker.com/r/egiona/ns3-base + +[ns3.33]: https://www.nsnam.org/releases/ns-3-33/ +[ns3.34]: https://www.nsnam.org/releases/ns-3-34/ +[ns3.35]: https://www.nsnam.org/releases/ns-3-35/ +[ns3.40]: https://www.nsnam.org/releases/ns-3-40/ +[ns3.41]: https://www.nsnam.org/releases/ns-3-41/ + +[latest-debug]: ./u22.04-n3.41/ns3-build/build-debug.sh +[latest-optimized]: ./u22.04-n3.41/ns3-build/build-optimized.sh +[latest-build]: ./u22.04-n3.41/ns3-build/ +[latest-makefile]: ./u22.04-n3.41/ns3-utils/Makefile + +[image6]: https://hub.docker.com/r/egiona/ns3-base/tags?page=1&name=u22.04-n3.41 +[image5]: https://hub.docker.com/r/egiona/ns3-base/tags?page=1&name=u22.04-n3.40 +[image4]: https://hub.docker.com/r/egiona/ns3-base/tags?page=1&name=u20.04-n3.40 +[image3]: https://hub.docker.com/r/egiona/ns3-base/tags?page=1&name=u18.04-n3.35 +[image2]: https://hub.docker.com/r/egiona/ns3-base/tags?page=1&name=u18.04-n3.34 +[image1]: https://hub.docker.com/r/egiona/ns3-base/tags?page=1&name=u18.04-n3.33 +[file6]: ./u22.04-n3.41/Dockerfile +[file5]: ./u22.04-n3.40/Dockerfile +[file4]: ./u20.04-n3.40/Dockerfile +[file3]: ./u18.04-n3.35/Dockerfile +[file2]: ./u18.04-n3.34/Dockerfile +[file1]: ./u18.04-n3.33/Dockerfile + +[docker-install]: https://docs.docker.com/engine/install/ + +[ns3-builds]: https://www.nsnam.org/docs/release/3.40/tutorial/html/getting-started.html#build-profiles + +[cff]: https://citation-file-format.github.io/ +[citation]: ./CITATION.cff + +[senseslab]: https://senseslab.diag.uniroma1.it/ +[docker-license]: ./LICENSE +[ns3-license]: https://www.nsnam.org/develop/contributing-code/licensing/ diff --git a/build-all.sh b/build-all.sh new file mode 100755 index 0000000..676b26e --- /dev/null +++ b/build-all.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +IMG_NAME=egiona/ns3-base + +# Iterate on all supported configurations and (re)build images +for img_dir in */ ; do + CURR_TAG="${img_dir%/}" + + echo ">>> Building image '${IMG_NAME}:${CURR_TAG}'..." + cd "${CURR_TAG}" && \ + docker buildx build -t "${IMG_NAME}:${CURR_TAG}" . && \ + docker push "${IMG_NAME}:${CURR_TAG}" && \ + docker image rm "${IMG_NAME}:${CURR_TAG}" && \ + cd .. +done diff --git a/u18.04-n3.33/Dockerfile b/u18.04-n3.33/Dockerfile new file mode 100644 index 0000000..b9725d8 --- /dev/null +++ b/u18.04-n3.33/Dockerfile @@ -0,0 +1,94 @@ +# syntax=docker/dockerfile:1 + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +FROM ubuntu:18.04 + +LABEL maintainer="giona.emanuele@gmail.com" +LABEL version="0.1" +LABEL description="Ubuntu 18.04 with ns-3.33" + +ARG NS_ALLINONE="ns-allinone-3.33" +ARG NS_VER="ns-3.33" + +ARG TMP_DOWNLOAD_DIR="/home/downloads" + +# ===== Evinronment variables available in containers too ===== +# Separate directories for uniformity with later versions +ENV NS3_DEBUG_DIR="/home/ns3-debug" +ENV NS3_OPTIMIZED_DIR="/home/ns3-optimized" + +# Variable pointing at ns-3 dedicated Python 3 environment +ENV NS3_PY_ENV="/home/ns3-pyenv" + +# ===== Basic OS updates and ns-3 requirements ===== +ARG DEBIAN_FRONTEND=noninteractive +RUN apt -y update && apt -y upgrade && \ + apt -y install make wget build-essential g++ python3 virtualenv apt-utils && \ + apt -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools && \ + apt -y install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 && \ + apt -y install autoconf cvs bzr unrar && \ + apt -y install gdb valgrind && \ + apt -y install uncrustify && \ + apt -y install doxygen graphviz imagemagick && \ + apt -y install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils dvipng latexmk && \ + apt -y install python3-sphinx dia && \ + apt -y install gsl-bin libgsl-dev libgslcblas0 && \ + apt -y install tcpdump && \ + apt -y install sqlite sqlite3 libsqlite3-dev && \ + apt -y install libxml2 libxml2-dev && \ + apt -y install cmake libc6-dev libc6-dev-i386 libclang-6.0-dev llvm-6.0-dev automake python3-pip && \ + pip3 install cxxfilt && \ + apt -y install libgtk-3-dev && \ + apt -y install vtun lxc uml-utilities libboost-all-dev && \ + apt -y install gfortran unzip && \ +# ===== Downloading: ns-3 source; Creating: Python 3 environment for ns-3 ===== + cd /home && mkdir "$TMP_DOWNLOAD_DIR" && cd "$TMP_DOWNLOAD_DIR" && \ + wget "https://www.nsnam.org/releases/$NS_ALLINONE.tar.bz2" && \ + tar xjf "$NS_ALLINONE.tar.bz2" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_DEBUG_DIR" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_OPTIMIZED_DIR" && \ + # Python virtual environment for ns-3 + virtualenv --python=/usr/bin/python3 "$NS3_PY_ENV" + +# ===== Building: ns-3; Cleanup: temporary downloads directory ===== +ENV NS3_DEBUG_DIR="$NS3_DEBUG_DIR/$NS_VER" +ENV NS3_OPTIMIZED_DIR="$NS3_OPTIMIZED_DIR/$NS_VER" +ENV CXX_CONFIG="-Wall -Werror -Wno-unused-variable" + +COPY ns3-build/* ns3-utils/* /home/ +RUN cd /home && \ + # Build: debug + chmod +x build-debug.sh && ./build-debug.sh && \ + # Build: optimized + chmod +x build-optimized.sh && ./build-optimized.sh && \ + # Utility for switching between profiles + echo "" >> ~/.bashrc && \ + echo "# Automatic .bashrc reload and NS3 profile variable" >> ~/.bashrc && \ + echo "trap '. ~/.bashrc' USR1" >> ~/.bashrc && \ + echo 'export NS3_CURR_PROFILE=${NS3_DEBUG_DIR}' >> ~/.bashrc && \ + # Cleanup + rm -rf "$TMP_DOWNLOAD_DIR" && ./build-debug.sh + +CMD ["/bin/bash"] diff --git a/u18.04-n3.33/ns3-build/build-debug.sh b/u18.04-n3.33/ns3-build/build-debug.sh new file mode 100644 index 0000000..f7b9f1e --- /dev/null +++ b/u18.04-n3.33/ns3-build/build-debug.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_DEBUG_DIR} + +echo "Switching to debug profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=debug --out=build --enable-examples --enable-tests" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./waf configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./waf build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./waf --check-profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_DEBUG_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u18.04-n3.33/ns3-build/build-optimized.sh b/u18.04-n3.33/ns3-build/build-optimized.sh new file mode 100644 index 0000000..85acb74 --- /dev/null +++ b/u18.04-n3.33/ns3-build/build-optimized.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_OPTIMIZED_DIR} + +echo "Switching to optimized profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=optimized --out=build --enable-examples --enable-tests" +CXX_CONFIG="-Wall" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./waf configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./waf build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./waf --check-profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_OPTIMIZED_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u18.04-n3.33/ns3-utils/Makefile b/u18.04-n3.33/ns3-utils/Makefile new file mode 100644 index 0000000..1ecc311 --- /dev/null +++ b/u18.04-n3.33/ns3-utils/Makefile @@ -0,0 +1,182 @@ +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +CWD := $(CURDIR) + +.ONESHELL: + +help: + @echo "Usage: make target [arguments]" + @echo "Targets:" + @echo " - help\n\tShows this help message." + @echo " --- Builds profiles ---" + @echo " - show_profile\n\tShows the ns-3 build profile currently in use." + @echo " --- Simulation driver programs ---" + @echo " - compile FILE=\n\tCopies the given driver program, then uses ./waf to compile it against ns-3." + @echo " - build_run FILE= [ARGS=] [LOG=]\n\tBuilds and executes the given driver program." + @echo " - run FILE= [ARGS=] [LOG=]\n\tExecutes the given driver program (no building first)." + @echo " - clean FILE=\n\tDeletes the given driver program." + @echo " --- Modules ---" + @echo " - new_module FILE=\n\tUses a ns-3 utility to create a new module under 'contrib/' with the given name, also copying it locally." + @echo " - sync_module FILE=\n\tReplaces contents of the module under 'contrib/' with local contents." + @echo " - rm_module FILE=\n\tRemoves the module with the given name (placed under 'contrib/')." + @echo " --- Debug ---" + @echo " - valgrind FILE= LOG=\n\tRuns the driver program through the Valgrind memory checking tool, writing the log to a file." + @echo " - gdb FILE=\n\tRuns the driver program through the GNU debugger." + @echo " - test SUITE= [LOG=]\n\tRuns the ns-3 testing tool selecting the given test suite." + @echo " - gdb_test SUITE=\n\tRuns the ns-3 testing tool selecting the given test suite, through the GNU debugger." + +show_profile: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --check-profile + @deactivate + +compile: +ifeq ($(FILE),) + $(error 'compile' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Compiling..." + @cp -f $(FILE) $(NS3_CURR_PROFILE)/scratch/ + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf + @deactivate + @echo " Done." + +build_run: +ifeq ($(FILE),) + $(error 'build_run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./waf --run scratch/$(FILE) --command-template="%s $(ARGS)" +else + @./waf --run scratch/$(FILE) --command-template="%s $(ARGS)" >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +run: +ifeq ($(FILE),) + $(error 'run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./waf --run-no-build scratch/$(FILE) --command-template="%s $(ARGS)" +else + @./waf --run-no-build scratch/$(FILE) --command-template="%s $(ARGS)" >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +clean: +ifeq ($(FILE),) + $(error 'clean' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Cleaning..." + @cd $(NS3_CURR_PROFILE) + @rm scratch/$(FILE) + @echo " Done." + +new_module: +ifeq ($(FILE),) + $(error 'new_module' target requires a FILE variable with the new module's name) +endif + @echo " Creating new module $(NS3_CURR_PROFILE)/contrib/$(FILE)..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./utils/create-module.py contrib/$(FILE) + @cd $(CWD) + @cp -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) $(FILE)/ + @deactivate + @echo " Done." + +rm_module: +ifeq ($(FILE),) + $(error 'rm_module' target requires a FILE variable with the module's name) +endif + @echo " Removing module contrib/$(FILE)..." + @rm -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) + @echo " Done." + +sync_module: +ifeq ($(FILE),) + $(error 'sync_module' target requires a FILE variable with the module's name) +endif + @echo " Syncronizing module..." + @make rm_module FILE=$(FILE) + @cp -rf $(FILE)/ $(NS3_CURR_PROFILE)/contrib/ + @echo " Done." + +valgrind: +ifeq ($(FILE),) + $(error 'valgrind' target requires a FILE variable with the ns-3 driver program name) +endif +ifeq ($(LOG),) + $(error 'valgrind' target requires a LOG variable with the path to the log file) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --run scratch/$(FILE) --command-template="valgrind --leak-check=full --show-leak-kinds=all --log-file=$(LOG) %s" + @deactivate + @echo " Done." + +gdb: +ifeq ($(FILE),) + $(error 'gdb' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --run scratch/$(FILE) --command-template="gdb %s" + @deactivate + @echo " Done." + +test: +ifeq ($(SUITE),) + $(error 'test' target requires a SUITE variable with the ns-3 test suite name) +endif + @echo " Testing..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./test.py -n -s $(SUITE) +else + @./test.py -n -s $(SUITE) --text=$(LOG) +endif + @deactivate + @echo " Done." + +gdb_test: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --run test-runner --command-template="gdb %s" + @deactivate + +.PHONY: clean diff --git a/u18.04-n3.34/Dockerfile b/u18.04-n3.34/Dockerfile new file mode 100644 index 0000000..58e5fb4 --- /dev/null +++ b/u18.04-n3.34/Dockerfile @@ -0,0 +1,94 @@ +# syntax=docker/dockerfile:1 + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +FROM ubuntu:18.04 + +LABEL maintainer="giona.emanuele@gmail.com" +LABEL version="0.1" +LABEL description="Ubuntu 18.04 with ns-3.34" + +ARG NS_ALLINONE="ns-allinone-3.34" +ARG NS_VER="ns-3.34" + +ARG TMP_DOWNLOAD_DIR="/home/downloads" + +# ===== Evinronment variables available in containers too ===== +# Separate directories for uniformity with later versions +ENV NS3_DEBUG_DIR="/home/ns3-debug" +ENV NS3_OPTIMIZED_DIR="/home/ns3-optimized" + +# Variable pointing at ns-3 dedicated Python 3 environment +ENV NS3_PY_ENV="/home/ns3-pyenv" + +# ===== Basic OS updates and ns-3 requirements ===== +ARG DEBIAN_FRONTEND=noninteractive +RUN apt -y update && apt -y upgrade && \ + apt -y install make wget build-essential g++ python3 virtualenv apt-utils && \ + apt -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools && \ + apt -y install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 && \ + apt -y install autoconf cvs bzr unrar && \ + apt -y install gdb valgrind && \ + apt -y install uncrustify && \ + apt -y install doxygen graphviz imagemagick && \ + apt -y install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils dvipng latexmk && \ + apt -y install python3-sphinx dia && \ + apt -y install gsl-bin libgsl-dev libgslcblas0 && \ + apt -y install tcpdump && \ + apt -y install sqlite sqlite3 libsqlite3-dev && \ + apt -y install libxml2 libxml2-dev && \ + apt -y install cmake libc6-dev libc6-dev-i386 libclang-6.0-dev llvm-6.0-dev automake python3-pip && \ + pip3 install cxxfilt && \ + apt -y install libgtk-3-dev && \ + apt -y install vtun lxc uml-utilities libboost-all-dev && \ + apt -y install gfortran unzip && \ +# ===== Downloading: ns-3 source; Creating: Python 3 environment for ns-3 ===== + cd /home && mkdir "$TMP_DOWNLOAD_DIR" && cd "$TMP_DOWNLOAD_DIR" && \ + wget "https://www.nsnam.org/releases/$NS_ALLINONE.tar.bz2" && \ + tar xjf "$NS_ALLINONE.tar.bz2" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_DEBUG_DIR" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_OPTIMIZED_DIR" && \ + # Python virtual environment for ns-3 + virtualenv --python=/usr/bin/python3 "$NS3_PY_ENV" + +# ===== Building: ns-3; Cleanup: temporary downloads directory ===== +ENV NS3_DEBUG_DIR="$NS3_DEBUG_DIR/$NS_VER" +ENV NS3_OPTIMIZED_DIR="$NS3_OPTIMIZED_DIR/$NS_VER" +ENV CXX_CONFIG="-Wall -Werror -Wno-unused-variable" + +COPY ns3-build/* ns3-utils/* /home/ +RUN cd /home && \ + # Build: debug + chmod +x build-debug.sh && ./build-debug.sh && \ + # Build: optimized + chmod +x build-optimized.sh && ./build-optimized.sh && \ + # Utility for switching between profiles + echo "" >> ~/.bashrc && \ + echo "# Automatic .bashrc reload and NS3 profile variable" >> ~/.bashrc && \ + echo "trap '. ~/.bashrc' USR1" >> ~/.bashrc && \ + echo 'export NS3_CURR_PROFILE=${NS3_DEBUG_DIR}' >> ~/.bashrc && \ + # Cleanup + rm -rf "$TMP_DOWNLOAD_DIR" && ./build-debug.sh + +CMD ["/bin/bash"] diff --git a/u18.04-n3.34/ns3-build/build-debug.sh b/u18.04-n3.34/ns3-build/build-debug.sh new file mode 100644 index 0000000..f7b9f1e --- /dev/null +++ b/u18.04-n3.34/ns3-build/build-debug.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_DEBUG_DIR} + +echo "Switching to debug profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=debug --out=build --enable-examples --enable-tests" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./waf configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./waf build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./waf --check-profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_DEBUG_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u18.04-n3.34/ns3-build/build-optimized.sh b/u18.04-n3.34/ns3-build/build-optimized.sh new file mode 100644 index 0000000..85acb74 --- /dev/null +++ b/u18.04-n3.34/ns3-build/build-optimized.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_OPTIMIZED_DIR} + +echo "Switching to optimized profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=optimized --out=build --enable-examples --enable-tests" +CXX_CONFIG="-Wall" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./waf configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./waf build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./waf --check-profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_OPTIMIZED_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u18.04-n3.34/ns3-utils/Makefile b/u18.04-n3.34/ns3-utils/Makefile new file mode 100644 index 0000000..1ecc311 --- /dev/null +++ b/u18.04-n3.34/ns3-utils/Makefile @@ -0,0 +1,182 @@ +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +CWD := $(CURDIR) + +.ONESHELL: + +help: + @echo "Usage: make target [arguments]" + @echo "Targets:" + @echo " - help\n\tShows this help message." + @echo " --- Builds profiles ---" + @echo " - show_profile\n\tShows the ns-3 build profile currently in use." + @echo " --- Simulation driver programs ---" + @echo " - compile FILE=\n\tCopies the given driver program, then uses ./waf to compile it against ns-3." + @echo " - build_run FILE= [ARGS=] [LOG=]\n\tBuilds and executes the given driver program." + @echo " - run FILE= [ARGS=] [LOG=]\n\tExecutes the given driver program (no building first)." + @echo " - clean FILE=\n\tDeletes the given driver program." + @echo " --- Modules ---" + @echo " - new_module FILE=\n\tUses a ns-3 utility to create a new module under 'contrib/' with the given name, also copying it locally." + @echo " - sync_module FILE=\n\tReplaces contents of the module under 'contrib/' with local contents." + @echo " - rm_module FILE=\n\tRemoves the module with the given name (placed under 'contrib/')." + @echo " --- Debug ---" + @echo " - valgrind FILE= LOG=\n\tRuns the driver program through the Valgrind memory checking tool, writing the log to a file." + @echo " - gdb FILE=\n\tRuns the driver program through the GNU debugger." + @echo " - test SUITE= [LOG=]\n\tRuns the ns-3 testing tool selecting the given test suite." + @echo " - gdb_test SUITE=\n\tRuns the ns-3 testing tool selecting the given test suite, through the GNU debugger." + +show_profile: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --check-profile + @deactivate + +compile: +ifeq ($(FILE),) + $(error 'compile' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Compiling..." + @cp -f $(FILE) $(NS3_CURR_PROFILE)/scratch/ + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf + @deactivate + @echo " Done." + +build_run: +ifeq ($(FILE),) + $(error 'build_run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./waf --run scratch/$(FILE) --command-template="%s $(ARGS)" +else + @./waf --run scratch/$(FILE) --command-template="%s $(ARGS)" >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +run: +ifeq ($(FILE),) + $(error 'run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./waf --run-no-build scratch/$(FILE) --command-template="%s $(ARGS)" +else + @./waf --run-no-build scratch/$(FILE) --command-template="%s $(ARGS)" >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +clean: +ifeq ($(FILE),) + $(error 'clean' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Cleaning..." + @cd $(NS3_CURR_PROFILE) + @rm scratch/$(FILE) + @echo " Done." + +new_module: +ifeq ($(FILE),) + $(error 'new_module' target requires a FILE variable with the new module's name) +endif + @echo " Creating new module $(NS3_CURR_PROFILE)/contrib/$(FILE)..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./utils/create-module.py contrib/$(FILE) + @cd $(CWD) + @cp -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) $(FILE)/ + @deactivate + @echo " Done." + +rm_module: +ifeq ($(FILE),) + $(error 'rm_module' target requires a FILE variable with the module's name) +endif + @echo " Removing module contrib/$(FILE)..." + @rm -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) + @echo " Done." + +sync_module: +ifeq ($(FILE),) + $(error 'sync_module' target requires a FILE variable with the module's name) +endif + @echo " Syncronizing module..." + @make rm_module FILE=$(FILE) + @cp -rf $(FILE)/ $(NS3_CURR_PROFILE)/contrib/ + @echo " Done." + +valgrind: +ifeq ($(FILE),) + $(error 'valgrind' target requires a FILE variable with the ns-3 driver program name) +endif +ifeq ($(LOG),) + $(error 'valgrind' target requires a LOG variable with the path to the log file) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --run scratch/$(FILE) --command-template="valgrind --leak-check=full --show-leak-kinds=all --log-file=$(LOG) %s" + @deactivate + @echo " Done." + +gdb: +ifeq ($(FILE),) + $(error 'gdb' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --run scratch/$(FILE) --command-template="gdb %s" + @deactivate + @echo " Done." + +test: +ifeq ($(SUITE),) + $(error 'test' target requires a SUITE variable with the ns-3 test suite name) +endif + @echo " Testing..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./test.py -n -s $(SUITE) +else + @./test.py -n -s $(SUITE) --text=$(LOG) +endif + @deactivate + @echo " Done." + +gdb_test: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --run test-runner --command-template="gdb %s" + @deactivate + +.PHONY: clean diff --git a/u18.04-n3.35/Dockerfile b/u18.04-n3.35/Dockerfile new file mode 100644 index 0000000..28d5832 --- /dev/null +++ b/u18.04-n3.35/Dockerfile @@ -0,0 +1,94 @@ +# syntax=docker/dockerfile:1 + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +FROM ubuntu:18.04 + +LABEL maintainer="giona.emanuele@gmail.com" +LABEL version="0.1" +LABEL description="Ubuntu 18.04 with ns-3.35" + +ARG NS_ALLINONE="ns-allinone-3.35" +ARG NS_VER="ns-3.35" + +ARG TMP_DOWNLOAD_DIR="/home/downloads" + +# ===== Evinronment variables available in containers too ===== +# Separate directories for uniformity with later versions +ENV NS3_DEBUG_DIR="/home/ns3-debug" +ENV NS3_OPTIMIZED_DIR="/home/ns3-optimized" + +# Variable pointing at ns-3 dedicated Python 3 environment +ENV NS3_PY_ENV="/home/ns3-pyenv" + +# ===== Basic OS updates and ns-3 requirements ===== +ARG DEBIAN_FRONTEND=noninteractive +RUN apt -y update && apt -y upgrade && \ + apt -y install make wget build-essential g++ python3 virtualenv apt-utils && \ + apt -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools && \ + apt -y install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 && \ + apt -y install autoconf cvs bzr unrar && \ + apt -y install gdb valgrind && \ + apt -y install uncrustify && \ + apt -y install doxygen graphviz imagemagick && \ + apt -y install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils dvipng latexmk && \ + apt -y install python3-sphinx dia && \ + apt -y install gsl-bin libgsl-dev libgslcblas0 && \ + apt -y install tcpdump && \ + apt -y install sqlite sqlite3 libsqlite3-dev && \ + apt -y install libxml2 libxml2-dev && \ + apt -y install cmake libc6-dev libc6-dev-i386 libclang-6.0-dev llvm-6.0-dev automake python3-pip && \ + pip3 install cxxfilt && \ + apt -y install libgtk-3-dev && \ + apt -y install vtun lxc uml-utilities libboost-all-dev && \ + apt -y install gfortran unzip && \ +# ===== Downloading: ns-3 source; Creating: Python 3 environment for ns-3 ===== + cd /home && mkdir "$TMP_DOWNLOAD_DIR" && cd "$TMP_DOWNLOAD_DIR" && \ + wget "https://www.nsnam.org/releases/$NS_ALLINONE.tar.bz2" && \ + tar xjf "$NS_ALLINONE.tar.bz2" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_DEBUG_DIR" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_OPTIMIZED_DIR" && \ + # Python virtual environment for ns-3 + virtualenv --python=/usr/bin/python3 "$NS3_PY_ENV" + +# ===== Building: ns-3; Cleanup: temporary downloads directory ===== +ENV NS3_DEBUG_DIR="$NS3_DEBUG_DIR/$NS_VER" +ENV NS3_OPTIMIZED_DIR="$NS3_OPTIMIZED_DIR/$NS_VER" +ENV CXX_CONFIG="-Wall -Werror -Wno-unused-variable" + +COPY ns3-build/* ns3-utils/* /home/ +RUN cd /home && \ + # Build: debug + chmod +x build-debug.sh && ./build-debug.sh && \ + # Build: optimized + chmod +x build-optimized.sh && ./build-optimized.sh && \ + # Utility for switching between profiles + echo "" >> ~/.bashrc && \ + echo "# Automatic .bashrc reload and NS3 profile variable" >> ~/.bashrc && \ + echo "trap '. ~/.bashrc' USR1" >> ~/.bashrc && \ + echo 'export NS3_CURR_PROFILE=${NS3_DEBUG_DIR}' >> ~/.bashrc && \ + # Cleanup + rm -rf "$TMP_DOWNLOAD_DIR" && ./build-debug.sh + +CMD ["/bin/bash"] diff --git a/u18.04-n3.35/ns3-build/build-debug.sh b/u18.04-n3.35/ns3-build/build-debug.sh new file mode 100644 index 0000000..f7b9f1e --- /dev/null +++ b/u18.04-n3.35/ns3-build/build-debug.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_DEBUG_DIR} + +echo "Switching to debug profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=debug --out=build --enable-examples --enable-tests" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./waf configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./waf build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./waf --check-profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_DEBUG_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u18.04-n3.35/ns3-build/build-optimized.sh b/u18.04-n3.35/ns3-build/build-optimized.sh new file mode 100644 index 0000000..85acb74 --- /dev/null +++ b/u18.04-n3.35/ns3-build/build-optimized.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_OPTIMIZED_DIR} + +echo "Switching to optimized profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=optimized --out=build --enable-examples --enable-tests" +CXX_CONFIG="-Wall" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./waf configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./waf build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./waf --check-profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_OPTIMIZED_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u18.04-n3.35/ns3-utils/Makefile b/u18.04-n3.35/ns3-utils/Makefile new file mode 100644 index 0000000..1ecc311 --- /dev/null +++ b/u18.04-n3.35/ns3-utils/Makefile @@ -0,0 +1,182 @@ +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +CWD := $(CURDIR) + +.ONESHELL: + +help: + @echo "Usage: make target [arguments]" + @echo "Targets:" + @echo " - help\n\tShows this help message." + @echo " --- Builds profiles ---" + @echo " - show_profile\n\tShows the ns-3 build profile currently in use." + @echo " --- Simulation driver programs ---" + @echo " - compile FILE=\n\tCopies the given driver program, then uses ./waf to compile it against ns-3." + @echo " - build_run FILE= [ARGS=] [LOG=]\n\tBuilds and executes the given driver program." + @echo " - run FILE= [ARGS=] [LOG=]\n\tExecutes the given driver program (no building first)." + @echo " - clean FILE=\n\tDeletes the given driver program." + @echo " --- Modules ---" + @echo " - new_module FILE=\n\tUses a ns-3 utility to create a new module under 'contrib/' with the given name, also copying it locally." + @echo " - sync_module FILE=\n\tReplaces contents of the module under 'contrib/' with local contents." + @echo " - rm_module FILE=\n\tRemoves the module with the given name (placed under 'contrib/')." + @echo " --- Debug ---" + @echo " - valgrind FILE= LOG=\n\tRuns the driver program through the Valgrind memory checking tool, writing the log to a file." + @echo " - gdb FILE=\n\tRuns the driver program through the GNU debugger." + @echo " - test SUITE= [LOG=]\n\tRuns the ns-3 testing tool selecting the given test suite." + @echo " - gdb_test SUITE=\n\tRuns the ns-3 testing tool selecting the given test suite, through the GNU debugger." + +show_profile: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --check-profile + @deactivate + +compile: +ifeq ($(FILE),) + $(error 'compile' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Compiling..." + @cp -f $(FILE) $(NS3_CURR_PROFILE)/scratch/ + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf + @deactivate + @echo " Done." + +build_run: +ifeq ($(FILE),) + $(error 'build_run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./waf --run scratch/$(FILE) --command-template="%s $(ARGS)" +else + @./waf --run scratch/$(FILE) --command-template="%s $(ARGS)" >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +run: +ifeq ($(FILE),) + $(error 'run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./waf --run-no-build scratch/$(FILE) --command-template="%s $(ARGS)" +else + @./waf --run-no-build scratch/$(FILE) --command-template="%s $(ARGS)" >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +clean: +ifeq ($(FILE),) + $(error 'clean' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Cleaning..." + @cd $(NS3_CURR_PROFILE) + @rm scratch/$(FILE) + @echo " Done." + +new_module: +ifeq ($(FILE),) + $(error 'new_module' target requires a FILE variable with the new module's name) +endif + @echo " Creating new module $(NS3_CURR_PROFILE)/contrib/$(FILE)..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./utils/create-module.py contrib/$(FILE) + @cd $(CWD) + @cp -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) $(FILE)/ + @deactivate + @echo " Done." + +rm_module: +ifeq ($(FILE),) + $(error 'rm_module' target requires a FILE variable with the module's name) +endif + @echo " Removing module contrib/$(FILE)..." + @rm -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) + @echo " Done." + +sync_module: +ifeq ($(FILE),) + $(error 'sync_module' target requires a FILE variable with the module's name) +endif + @echo " Syncronizing module..." + @make rm_module FILE=$(FILE) + @cp -rf $(FILE)/ $(NS3_CURR_PROFILE)/contrib/ + @echo " Done." + +valgrind: +ifeq ($(FILE),) + $(error 'valgrind' target requires a FILE variable with the ns-3 driver program name) +endif +ifeq ($(LOG),) + $(error 'valgrind' target requires a LOG variable with the path to the log file) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --run scratch/$(FILE) --command-template="valgrind --leak-check=full --show-leak-kinds=all --log-file=$(LOG) %s" + @deactivate + @echo " Done." + +gdb: +ifeq ($(FILE),) + $(error 'gdb' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --run scratch/$(FILE) --command-template="gdb %s" + @deactivate + @echo " Done." + +test: +ifeq ($(SUITE),) + $(error 'test' target requires a SUITE variable with the ns-3 test suite name) +endif + @echo " Testing..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./test.py -n -s $(SUITE) +else + @./test.py -n -s $(SUITE) --text=$(LOG) +endif + @deactivate + @echo " Done." + +gdb_test: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./waf --run test-runner --command-template="gdb %s" + @deactivate + +.PHONY: clean diff --git a/u20.04-n3.40/Dockerfile b/u20.04-n3.40/Dockerfile new file mode 100644 index 0000000..67f54b1 --- /dev/null +++ b/u20.04-n3.40/Dockerfile @@ -0,0 +1,94 @@ +# syntax=docker/dockerfile:1 + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +FROM ubuntu:20.04 + +LABEL maintainer="giona.emanuele@gmail.com" +LABEL version="0.1" +LABEL description="Ubuntu 20.04 with ns-3.40" + +ARG NS_ALLINONE="ns-allinone-3.40" +ARG NS_VER="ns-3.40" + +ARG TMP_DOWNLOAD_DIR="/home/downloads" + +# ===== Evinronment variables available in containers too ===== +# Separate directories simplify CMake build between profiles +ENV NS3_DEBUG_DIR="/home/ns3-debug" +ENV NS3_OPTIMIZED_DIR="/home/ns3-optimized" + +# Variable pointing at ns-3 dedicated Python 3 environment +ENV NS3_PY_ENV="/home/ns3-pyenv" + +# ===== Basic OS updates and ns-3 requirements ===== +ARG DEBIAN_FRONTEND=noninteractive +RUN apt -y update && apt -y upgrade && \ + apt -y install make wget build-essential g++ python3 virtualenv apt-utils && \ + apt -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools && \ + apt -y install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 && \ + apt -y install autoconf cvs bzr unrar && \ + apt -y install gdb valgrind && \ + apt -y install uncrustify && \ + apt -y install doxygen graphviz imagemagick && \ + apt -y install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils dvipng latexmk && \ + apt -y install python3-sphinx dia && \ + apt -y install gsl-bin libgsl-dev libgslcblas0 && \ + apt -y install tcpdump && \ + apt -y install sqlite sqlite3 libsqlite3-dev && \ + apt -y install libxml2 libxml2-dev && \ + apt -y install cmake libc6-dev libc6-dev-i386 libclang-6.0-dev llvm-6.0-dev automake python3-pip && \ + pip3 install cxxfilt && \ + apt -y install libgtk-3-dev && \ + apt -y install vtun lxc uml-utilities libboost-all-dev && \ + apt -y install gfortran unzip && \ +# ===== Downloading: ns-3 source; Creating: Python 3 environment for ns-3 ===== + cd /home && mkdir "$TMP_DOWNLOAD_DIR" && cd "$TMP_DOWNLOAD_DIR" && \ + wget "https://www.nsnam.org/releases/$NS_ALLINONE.tar.bz2" && \ + tar xjf "$NS_ALLINONE.tar.bz2" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_DEBUG_DIR" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_OPTIMIZED_DIR" && \ + # Python virtual environment for ns-3 + virtualenv --python=/usr/bin/python3 "$NS3_PY_ENV" + +# ===== Building: ns-3; Cleanup: temporary downloads directory ===== +ENV NS3_DEBUG_DIR="$NS3_DEBUG_DIR/$NS_VER" +ENV NS3_OPTIMIZED_DIR="$NS3_OPTIMIZED_DIR/$NS_VER" +ENV CXX_CONFIG="-Wall -Werror -Wno-unused-variable" + +COPY ns3-build/* ns3-utils/* /home/ +RUN cd /home && \ + # Build: debug + chmod +x build-debug.sh && ./build-debug.sh && \ + # Build: optimized + chmod +x build-optimized.sh && ./build-optimized.sh && \ + # Utility for switching between profiles + echo "" >> ~/.bashrc && \ + echo "# Automatic .bashrc reload and NS3 profile variable" >> ~/.bashrc && \ + echo "trap '. ~/.bashrc' USR1" >> ~/.bashrc && \ + echo 'export NS3_CURR_PROFILE=${NS3_DEBUG_DIR}' >> ~/.bashrc && \ + # Cleanup + rm -rf "$TMP_DOWNLOAD_DIR" && ./build-debug.sh + +CMD ["/bin/bash"] diff --git a/u20.04-n3.40/ns3-build/build-debug.sh b/u20.04-n3.40/ns3-build/build-debug.sh new file mode 100644 index 0000000..9c97128 --- /dev/null +++ b/u20.04-n3.40/ns3-build/build-debug.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_DEBUG_DIR} + +echo "Switching to debug profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=debug --out=build --enable-examples --enable-tests" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./ns3 configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./ns3 build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./ns3 show profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_DEBUG_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u20.04-n3.40/ns3-build/build-optimized.sh b/u20.04-n3.40/ns3-build/build-optimized.sh new file mode 100644 index 0000000..d6b0bc3 --- /dev/null +++ b/u20.04-n3.40/ns3-build/build-optimized.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_OPTIMIZED_DIR} + +echo "Switching to optimized profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=optimized --out=build --enable-examples --enable-tests" +CXX_CONFIG="-Wall" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./ns3 configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./ns3 build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./ns3 show profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_OPTIMIZED_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u20.04-n3.40/ns3-utils/Makefile b/u20.04-n3.40/ns3-utils/Makefile new file mode 100644 index 0000000..36ce95d --- /dev/null +++ b/u20.04-n3.40/ns3-utils/Makefile @@ -0,0 +1,182 @@ +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +CWD := $(CURDIR) + +.ONESHELL: + +help: + @echo "Usage: make target [arguments]" + @echo "Targets:" + @echo " - help\n\tShows this help message." + @echo " --- Builds profiles ---" + @echo " - show_profile\n\tShows the ns-3 build profile currently in use." + @echo " --- Simulation driver programs ---" + @echo " - compile FILE=\n\tCopies the given driver program, then uses ./ns3 to compile it against ns-3." + @echo " - build_run FILE= [ARGS=] [LOG=]\n\tBuilds and executes the given driver program." + @echo " - run FILE= [ARGS=] [LOG=]\n\tExecutes the given driver program (no building first)." + @echo " - clean FILE=\n\tDeletes the given driver program." + @echo " --- Modules ---" + @echo " - new_module FILE=\n\tUses a ns-3 utility to create a new module under 'contrib/' with the given name, also copying it locally." + @echo " - sync_module FILE=\n\tReplaces contents of the module under 'contrib/' with local contents." + @echo " - rm_module FILE=\n\tRemoves the module with the given name (placed under 'contrib/')." + @echo " --- Debug ---" + @echo " - valgrind FILE= LOG=\n\tRuns the driver program through the Valgrind memory checking tool, writing the log to a file." + @echo " - gdb FILE=\n\tRuns the driver program through the GNU debugger." + @echo " - test SUITE= [LOG=]\n\tRuns the ns-3 testing tool selecting the given test suite." + @echo " - gdb_test SUITE=\n\tRuns the ns-3 testing tool selecting the given test suite, through the GNU debugger." + +show_profile: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 show profile + @deactivate + +compile: +ifeq ($(FILE),) + $(error 'compile' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Compiling..." + @cp -f $(FILE) $(NS3_CURR_PROFILE)/scratch/ + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 + @deactivate + @echo " Done." + +build_run: +ifeq ($(FILE),) + $(error 'build_run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" +else + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +run: +ifeq ($(FILE),) + $(error 'run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" --no-build +else + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" --no-build >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +clean: +ifeq ($(FILE),) + $(error 'clean' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Cleaning..." + @cd $(NS3_CURR_PROFILE) + @rm scratch/$(FILE) + @echo " Done." + +new_module: +ifeq ($(FILE),) + $(error 'new_module' target requires a FILE variable with the new module's name) +endif + @echo " Creating new module $(NS3_CURR_PROFILE)/contrib/$(FILE)..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./utils/create-module.py contrib/$(FILE) + @cd $(CWD) + @cp -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) $(FILE)/ + @deactivate + @echo " Done." + +rm_module: +ifeq ($(FILE),) + $(error 'rm_module' target requires a FILE variable with the module's name) +endif + @echo " Removing module contrib/$(FILE)..." + @rm -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) + @echo " Done." + +sync_module: +ifeq ($(FILE),) + $(error 'sync_module' target requires a FILE variable with the module's name) +endif + @echo " Syncronizing module..." + @make rm_module FILE=$(FILE) + @cp -rf $(FILE)/ $(NS3_CURR_PROFILE)/contrib/ + @echo " Done." + +valgrind: +ifeq ($(FILE),) + $(error 'valgrind' target requires a FILE variable with the ns-3 driver program name) +endif +ifeq ($(LOG),) + $(error 'valgrind' target requires a LOG variable with the path to the log file) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 run scratch/$(FILE) --command-template="valgrind --leak-check=full --show-leak-kinds=all --log-file=$(LOG) %s" + @deactivate + @echo " Done." + +gdb: +ifeq ($(FILE),) + $(error 'gdb' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 run scratch/$(FILE) --command-template="gdb %s" + @deactivate + @echo " Done." + +test: +ifeq ($(SUITE),) + $(error 'test' target requires a SUITE variable with the ns-3 test suite name) +endif + @echo " Testing..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./test.py -n -s $(SUITE) +else + @./test.py -n -s $(SUITE) --text=$(LOG) +endif + @deactivate + @echo " Done." + +gdb_test: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 run test-runner --command-template="gdb %s" + @deactivate + +.PHONY: clean diff --git a/u22.04-n3.40/Dockerfile b/u22.04-n3.40/Dockerfile new file mode 100644 index 0000000..22f2c7f --- /dev/null +++ b/u22.04-n3.40/Dockerfile @@ -0,0 +1,94 @@ +# syntax=docker/dockerfile:1 + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +FROM ubuntu:22.04 + +LABEL maintainer="giona.emanuele@gmail.com" +LABEL version="0.1" +LABEL description="Ubuntu 22.04 with ns-3.40" + +ARG NS_ALLINONE="ns-allinone-3.40" +ARG NS_VER="ns-3.40" + +ARG TMP_DOWNLOAD_DIR="/home/downloads" + +# ===== Evinronment variables available in containers too ===== +# Separate directories simplify CMake build between profiles +ENV NS3_DEBUG_DIR="/home/ns3-debug" +ENV NS3_OPTIMIZED_DIR="/home/ns3-optimized" + +# Variable pointing at ns-3 dedicated Python 3 environment +ENV NS3_PY_ENV="/home/ns3-pyenv" + +# ===== Basic OS updates and ns-3 requirements ===== +ARG DEBIAN_FRONTEND=noninteractive +RUN apt -y update && apt -y upgrade && \ + apt -y install make wget build-essential g++ python3 virtualenv apt-utils && \ + apt -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools && \ + apt -y install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 && \ + apt -y install autoconf cvs bzr unrar && \ + apt -y install gdb valgrind && \ + apt -y install uncrustify && \ + apt -y install doxygen graphviz imagemagick && \ + apt -y install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils dvipng latexmk && \ + apt -y install python3-sphinx dia && \ + apt -y install gsl-bin libgsl-dev libgslcblas0 && \ + apt -y install tcpdump && \ + apt -y install sqlite sqlite3 libsqlite3-dev && \ + apt -y install libxml2 libxml2-dev && \ + apt -y install cmake libc6-dev libc6-dev-i386 automake python3-pip && \ + pip3 install cxxfilt && \ + apt -y install libgtk-3-dev && \ + apt -y install vtun lxc uml-utilities libboost-all-dev && \ + apt -y install gfortran unzip && \ +# ===== Downloading: ns-3 source; Creating: Python 3 environment for ns-3 ===== + cd /home && mkdir "$TMP_DOWNLOAD_DIR" && cd "$TMP_DOWNLOAD_DIR" && \ + wget "https://www.nsnam.org/releases/$NS_ALLINONE.tar.bz2" && \ + tar xjf "$NS_ALLINONE.tar.bz2" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_DEBUG_DIR" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_OPTIMIZED_DIR" && \ + # Python virtual environment for ns-3 + virtualenv --python=/usr/bin/python3 "$NS3_PY_ENV" + +# ===== Building: ns-3; Cleanup: temporary downloads directory ===== +ENV NS3_DEBUG_DIR="$NS3_DEBUG_DIR/$NS_VER" +ENV NS3_OPTIMIZED_DIR="$NS3_OPTIMIZED_DIR/$NS_VER" +ENV CXX_CONFIG="-Wall -Werror -Wno-unused-variable" + +COPY ns3-build/* ns3-utils/* /home/ +RUN cd /home && \ + # Build: debug + chmod +x build-debug.sh && ./build-debug.sh && \ + # Build: optimized + chmod +x build-optimized.sh && ./build-optimized.sh && \ + # Utility for switching between profiles + echo "" >> ~/.bashrc && \ + echo "# Automatic .bashrc reload and NS3 profile variable" >> ~/.bashrc && \ + echo "trap '. ~/.bashrc' USR1" >> ~/.bashrc && \ + echo 'export NS3_CURR_PROFILE=${NS3_DEBUG_DIR}' >> ~/.bashrc && \ + # Cleanup + rm -rf "$TMP_DOWNLOAD_DIR" && ./build-debug.sh + +CMD ["/bin/bash"] diff --git a/u22.04-n3.40/ns3-build/build-debug.sh b/u22.04-n3.40/ns3-build/build-debug.sh new file mode 100644 index 0000000..9c97128 --- /dev/null +++ b/u22.04-n3.40/ns3-build/build-debug.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_DEBUG_DIR} + +echo "Switching to debug profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=debug --out=build --enable-examples --enable-tests" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./ns3 configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./ns3 build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./ns3 show profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_DEBUG_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u22.04-n3.40/ns3-build/build-optimized.sh b/u22.04-n3.40/ns3-build/build-optimized.sh new file mode 100644 index 0000000..d6b0bc3 --- /dev/null +++ b/u22.04-n3.40/ns3-build/build-optimized.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_OPTIMIZED_DIR} + +echo "Switching to optimized profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=optimized --out=build --enable-examples --enable-tests" +CXX_CONFIG="-Wall" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./ns3 configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./ns3 build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./ns3 show profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_OPTIMIZED_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u22.04-n3.40/ns3-utils/Makefile b/u22.04-n3.40/ns3-utils/Makefile new file mode 100644 index 0000000..36ce95d --- /dev/null +++ b/u22.04-n3.40/ns3-utils/Makefile @@ -0,0 +1,182 @@ +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +CWD := $(CURDIR) + +.ONESHELL: + +help: + @echo "Usage: make target [arguments]" + @echo "Targets:" + @echo " - help\n\tShows this help message." + @echo " --- Builds profiles ---" + @echo " - show_profile\n\tShows the ns-3 build profile currently in use." + @echo " --- Simulation driver programs ---" + @echo " - compile FILE=\n\tCopies the given driver program, then uses ./ns3 to compile it against ns-3." + @echo " - build_run FILE= [ARGS=] [LOG=]\n\tBuilds and executes the given driver program." + @echo " - run FILE= [ARGS=] [LOG=]\n\tExecutes the given driver program (no building first)." + @echo " - clean FILE=\n\tDeletes the given driver program." + @echo " --- Modules ---" + @echo " - new_module FILE=\n\tUses a ns-3 utility to create a new module under 'contrib/' with the given name, also copying it locally." + @echo " - sync_module FILE=\n\tReplaces contents of the module under 'contrib/' with local contents." + @echo " - rm_module FILE=\n\tRemoves the module with the given name (placed under 'contrib/')." + @echo " --- Debug ---" + @echo " - valgrind FILE= LOG=\n\tRuns the driver program through the Valgrind memory checking tool, writing the log to a file." + @echo " - gdb FILE=\n\tRuns the driver program through the GNU debugger." + @echo " - test SUITE= [LOG=]\n\tRuns the ns-3 testing tool selecting the given test suite." + @echo " - gdb_test SUITE=\n\tRuns the ns-3 testing tool selecting the given test suite, through the GNU debugger." + +show_profile: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 show profile + @deactivate + +compile: +ifeq ($(FILE),) + $(error 'compile' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Compiling..." + @cp -f $(FILE) $(NS3_CURR_PROFILE)/scratch/ + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 + @deactivate + @echo " Done." + +build_run: +ifeq ($(FILE),) + $(error 'build_run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" +else + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +run: +ifeq ($(FILE),) + $(error 'run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" --no-build +else + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" --no-build >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +clean: +ifeq ($(FILE),) + $(error 'clean' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Cleaning..." + @cd $(NS3_CURR_PROFILE) + @rm scratch/$(FILE) + @echo " Done." + +new_module: +ifeq ($(FILE),) + $(error 'new_module' target requires a FILE variable with the new module's name) +endif + @echo " Creating new module $(NS3_CURR_PROFILE)/contrib/$(FILE)..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./utils/create-module.py contrib/$(FILE) + @cd $(CWD) + @cp -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) $(FILE)/ + @deactivate + @echo " Done." + +rm_module: +ifeq ($(FILE),) + $(error 'rm_module' target requires a FILE variable with the module's name) +endif + @echo " Removing module contrib/$(FILE)..." + @rm -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) + @echo " Done." + +sync_module: +ifeq ($(FILE),) + $(error 'sync_module' target requires a FILE variable with the module's name) +endif + @echo " Syncronizing module..." + @make rm_module FILE=$(FILE) + @cp -rf $(FILE)/ $(NS3_CURR_PROFILE)/contrib/ + @echo " Done." + +valgrind: +ifeq ($(FILE),) + $(error 'valgrind' target requires a FILE variable with the ns-3 driver program name) +endif +ifeq ($(LOG),) + $(error 'valgrind' target requires a LOG variable with the path to the log file) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 run scratch/$(FILE) --command-template="valgrind --leak-check=full --show-leak-kinds=all --log-file=$(LOG) %s" + @deactivate + @echo " Done." + +gdb: +ifeq ($(FILE),) + $(error 'gdb' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 run scratch/$(FILE) --command-template="gdb %s" + @deactivate + @echo " Done." + +test: +ifeq ($(SUITE),) + $(error 'test' target requires a SUITE variable with the ns-3 test suite name) +endif + @echo " Testing..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./test.py -n -s $(SUITE) +else + @./test.py -n -s $(SUITE) --text=$(LOG) +endif + @deactivate + @echo " Done." + +gdb_test: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 run test-runner --command-template="gdb %s" + @deactivate + +.PHONY: clean diff --git a/u22.04-n3.41/Dockerfile b/u22.04-n3.41/Dockerfile new file mode 100644 index 0000000..2a0458e --- /dev/null +++ b/u22.04-n3.41/Dockerfile @@ -0,0 +1,94 @@ +# syntax=docker/dockerfile:1 + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +FROM ubuntu:22.04 + +LABEL maintainer="giona.emanuele@gmail.com" +LABEL version="0.1" +LABEL description="Ubuntu 22.04 with ns-3.41" + +ARG NS_ALLINONE="ns-allinone-3.41" +ARG NS_VER="ns-3.41" + +ARG TMP_DOWNLOAD_DIR="/home/downloads" + +# ===== Evinronment variables available in containers too ===== +# Separate directories simplify CMake build between profiles +ENV NS3_DEBUG_DIR="/home/ns3-debug" +ENV NS3_OPTIMIZED_DIR="/home/ns3-optimized" + +# Variable pointing at ns-3 dedicated Python 3 environment +ENV NS3_PY_ENV="/home/ns3-pyenv" + +# ===== Basic OS updates and ns-3 requirements ===== +ARG DEBIAN_FRONTEND=noninteractive +RUN apt -y update && apt -y upgrade && \ + apt -y install make wget build-essential g++ python3 virtualenv apt-utils && \ + apt -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools && \ + apt -y install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 && \ + apt -y install autoconf cvs bzr unrar && \ + apt -y install gdb valgrind && \ + apt -y install uncrustify && \ + apt -y install doxygen graphviz imagemagick && \ + apt -y install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils dvipng latexmk && \ + apt -y install python3-sphinx dia && \ + apt -y install gsl-bin libgsl-dev libgslcblas0 && \ + apt -y install tcpdump && \ + apt -y install sqlite sqlite3 libsqlite3-dev && \ + apt -y install libxml2 libxml2-dev && \ + apt -y install cmake libc6-dev libc6-dev-i386 automake python3-pip && \ + pip3 install cxxfilt && \ + apt -y install libgtk-3-dev && \ + apt -y install vtun lxc uml-utilities libboost-all-dev && \ + apt -y install gfortran unzip && \ +# ===== Downloading: ns-3 source; Creating: Python 3 environment for ns-3 ===== + cd /home && mkdir "$TMP_DOWNLOAD_DIR" && cd "$TMP_DOWNLOAD_DIR" && \ + wget "https://www.nsnam.org/releases/$NS_ALLINONE.tar.bz2" && \ + tar xjf "$NS_ALLINONE.tar.bz2" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_DEBUG_DIR" && \ + cp -R "$NS_ALLINONE/" ../ && mv ../"$NS_ALLINONE" "$NS3_OPTIMIZED_DIR" && \ + # Python virtual environment for ns-3 + virtualenv --python=/usr/bin/python3 "$NS3_PY_ENV" + +# ===== Building: ns-3; Cleanup: temporary downloads directory ===== +ENV NS3_DEBUG_DIR="$NS3_DEBUG_DIR/$NS_VER" +ENV NS3_OPTIMIZED_DIR="$NS3_OPTIMIZED_DIR/$NS_VER" +ENV CXX_CONFIG="-Wall -Werror -Wno-unused-variable" + +COPY ns3-build/* ns3-utils/* /home/ +RUN cd /home && \ + # Build: debug + chmod +x build-debug.sh && ./build-debug.sh && \ + # Build: optimized + chmod +x build-optimized.sh && ./build-optimized.sh && \ + # Utility for switching between profiles + echo "" >> ~/.bashrc && \ + echo "# Automatic .bashrc reload and NS3 profile variable" >> ~/.bashrc && \ + echo "trap '. ~/.bashrc' USR1" >> ~/.bashrc && \ + echo 'export NS3_CURR_PROFILE=${NS3_DEBUG_DIR}' >> ~/.bashrc && \ + # Cleanup + rm -rf "$TMP_DOWNLOAD_DIR" && ./build-debug.sh + +CMD ["/bin/bash"] diff --git a/u22.04-n3.41/ns3-build/build-debug.sh b/u22.04-n3.41/ns3-build/build-debug.sh new file mode 100644 index 0000000..9c97128 --- /dev/null +++ b/u22.04-n3.41/ns3-build/build-debug.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_DEBUG_DIR} + +echo "Switching to debug profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=debug --out=build --enable-examples --enable-tests" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./ns3 configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./ns3 build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./ns3 show profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_DEBUG_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u22.04-n3.41/ns3-build/build-optimized.sh b/u22.04-n3.41/ns3-build/build-optimized.sh new file mode 100644 index 0000000..d6b0bc3 --- /dev/null +++ b/u22.04-n3.41/ns3-build/build-optimized.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +NS3_DIR=${NS3_OPTIMIZED_DIR} + +echo "Switching to optimized profile in ns-3..." + +cd $NS3_DIR + +NS3_CONFIG="--build-profile=optimized --out=build --enable-examples --enable-tests" +CXX_CONFIG="-Wall" + +. ${NS3_PY_ENV}/bin/activate + +OUTCOME=1 +CXXFLAGS="${CXX_CONFIG}" ./ns3 configure $NS3_CONFIG && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: configuration failed" + exit 1 +fi + +OUTCOME=1 +./ns3 build && OUTCOME=0 + +if [[ "$OUTCOME" -eq 1 ]]; then + echo "Error: build failed" + exit 1 +fi + +./ns3 show profile +deactivate + +sed -i 's/^\(export NS3_CURR_PROFILE=\).*$/\1${NS3_OPTIMIZED_DIR}/' ~/.bashrc && \ +cd /home && \ +kill -USR1 $PPID + +exit 0 diff --git a/u22.04-n3.41/ns3-utils/Makefile b/u22.04-n3.41/ns3-utils/Makefile new file mode 100644 index 0000000..36ce95d --- /dev/null +++ b/u22.04-n3.41/ns3-utils/Makefile @@ -0,0 +1,182 @@ +# MIT License + +# Copyright (c) 2024 Emanuele Giona (SENSES Lab, +# Sapienza University of Rome) + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +CWD := $(CURDIR) + +.ONESHELL: + +help: + @echo "Usage: make target [arguments]" + @echo "Targets:" + @echo " - help\n\tShows this help message." + @echo " --- Builds profiles ---" + @echo " - show_profile\n\tShows the ns-3 build profile currently in use." + @echo " --- Simulation driver programs ---" + @echo " - compile FILE=\n\tCopies the given driver program, then uses ./ns3 to compile it against ns-3." + @echo " - build_run FILE= [ARGS=] [LOG=]\n\tBuilds and executes the given driver program." + @echo " - run FILE= [ARGS=] [LOG=]\n\tExecutes the given driver program (no building first)." + @echo " - clean FILE=\n\tDeletes the given driver program." + @echo " --- Modules ---" + @echo " - new_module FILE=\n\tUses a ns-3 utility to create a new module under 'contrib/' with the given name, also copying it locally." + @echo " - sync_module FILE=\n\tReplaces contents of the module under 'contrib/' with local contents." + @echo " - rm_module FILE=\n\tRemoves the module with the given name (placed under 'contrib/')." + @echo " --- Debug ---" + @echo " - valgrind FILE= LOG=\n\tRuns the driver program through the Valgrind memory checking tool, writing the log to a file." + @echo " - gdb FILE=\n\tRuns the driver program through the GNU debugger." + @echo " - test SUITE= [LOG=]\n\tRuns the ns-3 testing tool selecting the given test suite." + @echo " - gdb_test SUITE=\n\tRuns the ns-3 testing tool selecting the given test suite, through the GNU debugger." + +show_profile: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 show profile + @deactivate + +compile: +ifeq ($(FILE),) + $(error 'compile' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Compiling..." + @cp -f $(FILE) $(NS3_CURR_PROFILE)/scratch/ + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 + @deactivate + @echo " Done." + +build_run: +ifeq ($(FILE),) + $(error 'build_run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" +else + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +run: +ifeq ($(FILE),) + $(error 'run' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " $(shell date): running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" --no-build +else + @./ns3 run scratch/$(FILE) --command-template="%s $(ARGS)" --no-build >> $(LOG) 2>&1 +endif + @deactivate + @echo " $(shell date): done." + +clean: +ifeq ($(FILE),) + $(error 'clean' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Cleaning..." + @cd $(NS3_CURR_PROFILE) + @rm scratch/$(FILE) + @echo " Done." + +new_module: +ifeq ($(FILE),) + $(error 'new_module' target requires a FILE variable with the new module's name) +endif + @echo " Creating new module $(NS3_CURR_PROFILE)/contrib/$(FILE)..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./utils/create-module.py contrib/$(FILE) + @cd $(CWD) + @cp -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) $(FILE)/ + @deactivate + @echo " Done." + +rm_module: +ifeq ($(FILE),) + $(error 'rm_module' target requires a FILE variable with the module's name) +endif + @echo " Removing module contrib/$(FILE)..." + @rm -rf $(NS3_CURR_PROFILE)/contrib/$(FILE) + @echo " Done." + +sync_module: +ifeq ($(FILE),) + $(error 'sync_module' target requires a FILE variable with the module's name) +endif + @echo " Syncronizing module..." + @make rm_module FILE=$(FILE) + @cp -rf $(FILE)/ $(NS3_CURR_PROFILE)/contrib/ + @echo " Done." + +valgrind: +ifeq ($(FILE),) + $(error 'valgrind' target requires a FILE variable with the ns-3 driver program name) +endif +ifeq ($(LOG),) + $(error 'valgrind' target requires a LOG variable with the path to the log file) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 run scratch/$(FILE) --command-template="valgrind --leak-check=full --show-leak-kinds=all --log-file=$(LOG) %s" + @deactivate + @echo " Done." + +gdb: +ifeq ($(FILE),) + $(error 'gdb' target requires a FILE variable with the ns-3 driver program name) +endif + @echo " Running..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 run scratch/$(FILE) --command-template="gdb %s" + @deactivate + @echo " Done." + +test: +ifeq ($(SUITE),) + $(error 'test' target requires a SUITE variable with the ns-3 test suite name) +endif + @echo " Testing..." + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) +ifeq ($(LOG),) + @./test.py -n -s $(SUITE) +else + @./test.py -n -s $(SUITE) --text=$(LOG) +endif + @deactivate + @echo " Done." + +gdb_test: + @. $(NS3_PY_ENV)/bin/activate + @cd $(NS3_CURR_PROFILE) + @./ns3 run test-runner --command-template="gdb %s" + @deactivate + +.PHONY: clean