-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64258f7
commit f24cfa0
Showing
9 changed files
with
810 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
BUILD | ||
config/graphs/autosave.json | ||
results |
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,6 @@ | ||
#!/bin/sh | ||
|
||
source config/environments/docker/config.sh | ||
|
||
# Build Docker image | ||
docker build -t $DOCKER_IMAGE_EMULATOR -f $DOCKER_FILE_EMULATOR . |
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,14 @@ | ||
#!/bin/sh | ||
|
||
# Stop and delete Docker containers and network namespaces | ||
cleanup() { | ||
(docker stop channel; docker rm channel) || true | ||
(docker stop source; docker rm source) || true | ||
(docker stop sink; docker rm sink) || true | ||
|
||
sudo ip netns delete channel || true | ||
sudo ip netns delete source || true | ||
sudo ip netns delete sink || true | ||
} | ||
|
||
cleanup &> /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,12 @@ | ||
#!/bin/sh | ||
|
||
# Build normal emulator Docker image | ||
DOCKER_FILE_EMULATOR="Dockerfile" | ||
DOCKER_IMAGE_EMULATOR="channel_emulator" | ||
|
||
# Build emulator Docker image with machine learning support | ||
#DOCKER_FILE_EMULATOR="Dockerfile_ml" | ||
#DOCKER_IMAGE_EMULATOR="channel_emulator_ml" | ||
|
||
# User emulator Docker image for source and sink | ||
DOCKER_IMAGE_SOURCE_SINK=$DOCKER_IMAGE_EMULATOR |
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,17 @@ | ||
[metadata] | ||
name = "Docker" | ||
description = "Docker environment" | ||
|
||
[config] | ||
mqtt.host = "172.17.0.1" | ||
|
||
interface.source = "in" | ||
interface.sink = "out" | ||
|
||
docker_container.source = "source" | ||
docker_container.channel = "channel" | ||
docker_container.sink = "sink" | ||
|
||
#run_prefix.source = "" | ||
#run_prefix.channel = "" | ||
#run_prefix.sink = "" |
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,38 @@ | ||
#!/bin/sh | ||
|
||
source config/environments/docker/config.sh | ||
|
||
# Start Docker containers | ||
docker run -d -it -v $(pwd)/config:/config --name channel $DOCKER_IMAGE_EMULATOR | ||
docker run -d -it --privileged --name source $DOCKER_IMAGE_SOURCE_SINK | ||
docker run -d -it --privileged --name sink $DOCKER_IMAGE_SOURCE_SINK | ||
|
||
# Create links between Docker containers | ||
setup_network() { | ||
pid_channel=$(docker inspect -f '{{.State.Pid}}' channel) | ||
pid_source=$(docker inspect -f '{{.State.Pid}}' source) | ||
pid_sink=$(docker inspect -f '{{.State.Pid}}' sink) | ||
|
||
sudo mkdir -p /var/run/netns/ | ||
sudo ln -sfT /proc/$pid_channel/ns/net /var/run/netns/channel | ||
sudo ln -sfT /proc/$pid_source/ns/net /var/run/netns/source | ||
sudo ln -sfT /proc/$pid_sink/ns/net /var/run/netns/sink | ||
|
||
sudo ip link add emulator netns source type veth peer name in netns channel | ||
sudo ip netns exec source ethtool -K emulator rx off tx off | ||
sudo ip netns exec source ip addr add 10.0.1.1/24 dev emulator | ||
sudo ip netns exec channel ip link set in up | ||
sudo ip netns exec source ip link set lo up | ||
sudo ip netns exec source ip link set emulator up | ||
sudo ip netns exec source ip route add 10.0.2.0/24 dev emulator | ||
|
||
sudo ip link add emulator netns sink type veth peer name out netns channel | ||
sudo ip netns exec sink ethtool -K emulator rx off tx off | ||
sudo ip netns exec sink ip addr add 10.0.2.1/24 dev emulator | ||
sudo ip netns exec channel ip link set out up | ||
sudo ip netns exec sink ip link set lo up | ||
sudo ip netns exec sink ip link set emulator up | ||
sudo ip netns exec sink ip route add 10.0.1.0/24 dev emulator | ||
} | ||
|
||
setup_network > /dev/null |
Oops, something went wrong.