-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker: easily start a simulation in a docker container
- Loading branch information
1 parent
53ad70a
commit d412d37
Showing
5 changed files
with
110 additions
and
47 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM ubuntu:22.04 | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
#### | ||
# Machine setup and dependecies installation | ||
#### | ||
RUN apt-get update \ | ||
&& apt-get install --no-install-recommends --quiet --assume-yes \ | ||
clang-format \ | ||
cmake \ | ||
g++ \ | ||
gdb \ | ||
gcc \ | ||
git \ | ||
make \ | ||
libgsl-dev \ | ||
libxml2-dev \ | ||
patch \ | ||
pkg-config \ | ||
python3 \ | ||
python3-venv \ | ||
python3-pip \ | ||
python-is-python3 \ | ||
rapidjson-dev \ | ||
doxygen \ | ||
graphviz | ||
|
||
# Use local versione of the simulator | ||
|
||
#RUN mkdir IoD_Sim | ||
#COPY . ./IoD_Sim/ | ||
|
||
# Use remote version of the simulator | ||
RUN git clone https://github.com/telematics-lab/IoD_Sim.git | ||
|
||
WORKDIR ./IoD_Sim | ||
RUN ./tools/prepare-ns3-docker.sh | ||
RUN ./tools/configure-iodsim.sh | ||
WORKDIR ./ns3 | ||
RUN ./ns3 build -j$(grep -c ^processor /proc/cpuinfo) | ||
WORKDIR .. | ||
|
||
ENTRYPOINT ["/bin/bash","./tools/simulate.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
check_availability() { | ||
PRG_NAME=$1 | ||
|
||
command -v $PRG_NAME &> /dev/null | ||
if [ "$?" -ne 0 ]; then | ||
echo "The program \"${PRG_NAME}\" is not available in your system. \ | ||
Please install it, then re-run this script." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# check dependencies | ||
check_availability git | ||
check_availability patch | ||
|
||
git submodule update --init | ||
|
||
pushd ns3 > /dev/null | ||
for patchfile in ../tools/*.patch | ||
do | ||
patch -s -p1 < $patchfile | ||
done | ||
popd > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
usage() { | ||
echo "Usage:" | ||
echo "sudo docker run --rm -v ./results:/IoD_Sim/results -v ./scenario:/IoD_Sim/scenario docker_iod_sim [--help] <simulation_file_name>" | ||
echo | ||
echo "Options:" | ||
echo " --help Shows help message." | ||
echo " <simulation_file_name> Name of the .json file to simulate." | ||
exit 1 | ||
} | ||
|
||
if [[ "$1" == "--help" ]]; then | ||
usage | ||
elif [[ -z "$1" ]]; then | ||
usage | ||
elif [[ ! -f "./scenario/$1.json" ]]; then | ||
echo "Error: File '$1.json' doesn't exist." | ||
usage | ||
else | ||
source .venv/bin/activate && ./ns3/ns3 run "iodsim --config=../scenario/$1.json" | ||
chmod -R 777 ./results/* | ||
fi |