Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added LoRaEMU and LoRa ECLA. #5

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 69 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
ARG ARCH=

# == build dtn7-rs, dtn-dwd, dtnchat

FROM ${ARCH}rust:1.64 as builder
WORKDIR /root
RUN rustup component add rustfmt
Expand All @@ -20,6 +22,13 @@ RUN git clone https://github.com/gh0st42/dtnchat && cd dtnchat && \
git checkout 93f1450 && \
cargo install --bins --examples --root /usr/local --path .

RUN apt-get update && apt-get -y install libudev-dev protobuf-compiler

RUN git clone https://github.com/BigJk/dtn7-rs-lora-ecla.git && cd dtn7-rs-lora-ecla && \
git checkout 0277dbc8151300e260698cf32beab7bcb98d58f5 && \
cargo install --locked --bins --examples --root /usr/local --path .

# == build wtf, loraemu

FROM ${ARCH}golang:1.19 as gobuilder

Expand All @@ -40,6 +49,60 @@ ENV PATH=$PATH:./bin
RUN make build && \
cp bin/wtfutil /usr/local/bin/

# == fetch node frontend building of loraemu

RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node

ENV NODE_VERSION 19.7.0

RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& case "${dpkgArch##*-}" in \
amd64) ARCH='x64';; \
ppc64el) ARCH='ppc64le';; \
s390x) ARCH='s390x';; \
arm64) ARCH='arm64';; \
armhf) ARCH='armv7l';; \
i386) ARCH='x86';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac \
# gpg keys listed at https://github.com/nodejs/node#release-keys
&& set -ex \
&& for key in \
4ED778F539E3634C779C87C6D7062848A1AB005C \
141F07595B7B3FFE74309A937405533BE57C7D57 \
74F12602B6F1C4E913FAA37AD3A89613643B6201 \
61FC681DFB92A079F1685E77973F295594EC4689 \
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \
C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
108F52B48DB57BB0CC439B2997B01419BD92F80A \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.gz" \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.gz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xzf "node-v$NODE_VERSION-linux-$ARCH.tar.gz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.gz" SHASUMS256.txt.asc SHASUMS256.txt \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \
# smoke tests
&& node --version \
&& npm --version

# == build loraemu + frontend and move files to /usr/local/bin

RUN git clone https://github.com/bigjk/loraemu.git $GOPATH/src/github.com/bigjk/loraemu && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version tag or commit ID should be pinned here

cd $GOPATH/src/github.com/bigjk/loraemu && \
./build_all.sh && \
mv ./release/emu ./release/loraemu && \
mv ./release/log-inspect ./release/loraemu-log-inspect && \
mv -v ./release/* /usr/local/bin/

WORKDIR $GOPATH/src/github.com/bigjk/loraemu

FROM ${ARCH}gh0st42/coreemu-lab:1.1.0

Expand All @@ -66,9 +129,12 @@ RUN curl -sL https://deb.nodesource.com/setup_16.x | bash && \
rm -rf /var/lib/apt/lists/*

COPY configs/dtnmap.json /root/nodered/
COPY --from=builder /usr/local/bin/* /usr/local/bin/

# copy executables from builders

COPY --from=builder /usr/local/bin/* /usr/local/bin/
COPY --from=gobuilder /usr/local/bin/* /usr/local/bin/
COPY --from=gobuilder /usr/local/bin/frontend /usr/local/bin/frontend

RUN touch /root/.Xresources
RUN touch /root/.Xauthority
Expand All @@ -84,7 +150,7 @@ COPY coregui/config.yaml /root/.coregui/
COPY coregui/icons/* /root/.coregui/icons/
COPY scenarios/*.xml /root/.coregui/xmls/
COPY configs/dtn7.yml /root/

COPY loraemu/ /root/loraemu

# --------------------------- moNNT.py Installation ---------------------------

Expand Down Expand Up @@ -136,5 +202,6 @@ EXPOSE 22
EXPOSE 1190
EXPOSE 5901
EXPOSE 50051
EXPOSE 8291
ENTRYPOINT [ "/entrypoint.sh" ]
WORKDIR /root
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Currently, the following example scenarios are included:
- [dtn dwd](https//github.com/stg-tud/dtn-dwd): delay-tolerant weather warnings
- [dtnchat](https://github.com/gh0st42/dtnchat): a simple text-based dtn chat including a chatbot
- [NNTP DTN](https://github.com/teschmitt/moNNT.py): a NNTP-to-DTN gateway for group discussions using thunderbard, pan, etc.
- [LoRaEMU](https://github.com/BigJk/LoRaEMU) + [LoRa dtn7 ecla](https://github.com/BigJk/dtn7-rs-lora-ecla): a LoRa simulator combined with a lora ecla for dtn7
- [dtn7zero](https://github.com/dtn7/dtn7zero): IoT sensor reading and value plotting over DTN, using dtn7zero and dtn7-rs nodes

## Running
Expand Down Expand Up @@ -37,6 +38,24 @@ You can then connect with any VNC client to the local *dtn7 showroom* instance w

*NOTE:* In case of weird connection problems within the showroom, please make sure that *ebtables* and *sch_netem* kernel modules are loaded!

## LoRaEMU Demos

- LoRaEMU is accessible inside the container via the ``loraemu`` command
- Scenario runner and example scenarios are under ``/root/loraemu/scenarios``
- Scenarios can be run with ``./run.sh <scenario_name> <run_time>``
- Available scenarios
- ``darmstadt``: Real world like scenario akin to Darmstadt
- ``connected_grid``: Fully connected grid
- ``line_collision``: 5 nodes in row to highlight collision behaviour

### Example: Darmstadt

Open a shell into the terminal. Run the command and open ``http://127.0.0.1:8291/`` in your webbrowser.

```
cd /root/loraemu/scenarios && ./run.sh darmstadt 20m
```

## Manually building the container

Just run `docker build -t dtn7-showroom .` and run it with `docker run --rm -it --name showroom -p 5901:5901 --privileged -v /tmp/shared:/shared dtn7-showroom`
Expand Down
1 change: 1 addition & 0 deletions dtn7-showroom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ docker run --rm -it \
-p 50052:50051 \
-p 2023:22 \
-p 1190:1190 \
-p 8291:8291 \
-v $SHARED:/shared \
--privileged \
$INTERACTIVE \
Expand Down
10 changes: 10 additions & 0 deletions loraemu/scenarios/connected_grid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Connected Grid Scenario

## Options

Options are passed via environment variables.

- **SEND_MSG**: String to send (default: "hello world")
- **SEND_NODE**: Which node to send from (defualt: "0_0")
- **RECEIVE_NODE**: Which node to send to (defualt: "5_5")
- **MSG_COUNT**: How many messages to send (default: 1)
11 changes: 11 additions & 0 deletions loraemu/scenarios/connected_grid/post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SENT=$(rg --no-filename "Transmission of bundle requested" $1/cmdlogs/*.txt | wc -l)
RECEIVED=$(rg --no-filename "Received bundle for local delivery" $1/cmdlogs/*.txt | wc -l)

if [ $SENT -eq $RECEIVED ] ; then
echo "EXPERIMENT RESULT: Success | tx: $SENT, rx: $RECEIVED"
else
echo "EXPERIMENT RESULT: Failed | tx: $SENT, rx: $RECEIVED"
exit 1
fi
66 changes: 66 additions & 0 deletions loraemu/scenarios/connected_grid/scenario.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"freq": 868,
"gamma": 2.2,
"refDistance": 40,
"kmRange": 10,
"packetConfig": {
"preambleLen": 32,
"spreadingFactor": 7,
"bandWidth": 250,
"codingRate": 8,
"crc": true,
"explicitHeader": false,
"lowDataRateOptimization": false
},
"nodes": [
{"id": "node0_0", "online": true, "rxSens": -139, "txGain": 20, "x": 1.0, "y": 1.0, "z": 1},
{"id": "node0_1", "online": true, "rxSens": -139, "txGain": 20, "x": 1.0, "y": 2.6, "z": 1},
{"id": "node0_2", "online": true, "rxSens": -139, "txGain": 20, "x": 1.0, "y": 4.2, "z": 1},
{"id": "node0_3", "online": true, "rxSens": -139, "txGain": 20, "x": 1.0, "y": 5.800000000000001, "z": 1},
{"id": "node0_4", "online": true, "rxSens": -139, "txGain": 20, "x": 1.0, "y": 7.4, "z": 1},
{"id": "node0_5", "online": true, "rxSens": -139, "txGain": 20, "x": 1.0, "y": 9.0, "z": 1},
{"id": "node1_0", "online": true, "rxSens": -139, "txGain": 20, "x": 2.6, "y": 1.0, "z": 1},
{"id": "node1_1", "online": true, "rxSens": -139, "txGain": 20, "x": 2.6, "y": 2.6, "z": 1},
{"id": "node1_2", "online": true, "rxSens": -139, "txGain": 20, "x": 2.6, "y": 4.2, "z": 1},
{"id": "node1_3", "online": true, "rxSens": -139, "txGain": 20, "x": 2.6, "y": 5.800000000000001, "z": 1},
{"id": "node1_4", "online": true, "rxSens": -139, "txGain": 20, "x": 2.6, "y": 7.4, "z": 1},
{"id": "node1_5", "online": true, "rxSens": -139, "txGain": 20, "x": 2.6, "y": 9.0, "z": 1},
{"id": "node2_0", "online": true, "rxSens": -139, "txGain": 20, "x": 4.2, "y": 1.0, "z": 1},
{"id": "node2_1", "online": true, "rxSens": -139, "txGain": 20, "x": 4.2, "y": 2.6, "z": 1},
{"id": "node2_2", "online": true, "rxSens": -139, "txGain": 20, "x": 4.2, "y": 4.2, "z": 1},
{"id": "node2_3", "online": true, "rxSens": -139, "txGain": 20, "x": 4.2, "y": 5.800000000000001, "z": 1},
{"id": "node2_4", "online": true, "rxSens": -139, "txGain": 20, "x": 4.2, "y": 7.4, "z": 1},
{"id": "node2_5", "online": true, "rxSens": -139, "txGain": 20, "x": 4.2, "y": 9.0, "z": 1},
{"id": "node3_0", "online": true, "rxSens": -139, "txGain": 20, "x": 5.800000000000001, "y": 1.0, "z": 1},
{"id": "node3_1", "online": true, "rxSens": -139, "txGain": 20, "x": 5.800000000000001, "y": 2.6, "z": 1},
{"id": "node3_2", "online": true, "rxSens": -139, "txGain": 20, "x": 5.800000000000001, "y": 4.2, "z": 1},
{"id": "node3_3", "online": true, "rxSens": -139, "txGain": 20, "x": 5.800000000000001, "y": 5.800000000000001, "z": 1},
{"id": "node3_4", "online": true, "rxSens": -139, "txGain": 20, "x": 5.800000000000001, "y": 7.4, "z": 1},
{"id": "node3_5", "online": true, "rxSens": -139, "txGain": 20, "x": 5.800000000000001, "y": 9.0, "z": 1},
{"id": "node4_0", "online": true, "rxSens": -139, "txGain": 20, "x": 7.4, "y": 1.0, "z": 1},
{"id": "node4_1", "online": true, "rxSens": -139, "txGain": 20, "x": 7.4, "y": 2.6, "z": 1},
{"id": "node4_2", "online": true, "rxSens": -139, "txGain": 20, "x": 7.4, "y": 4.2, "z": 1},
{"id": "node4_3", "online": true, "rxSens": -139, "txGain": 20, "x": 7.4, "y": 5.800000000000001, "z": 1},
{"id": "node4_4", "online": true, "rxSens": -139, "txGain": 20, "x": 7.4, "y": 7.4, "z": 1},
{"id": "node4_5", "online": true, "rxSens": -139, "txGain": 20, "x": 7.4, "y": 9.0, "z": 1},
{"id": "node5_0", "online": true, "rxSens": -139, "txGain": 20, "x": 9.0, "y": 1.0, "z": 1},
{"id": "node5_1", "online": true, "rxSens": -139, "txGain": 20, "x": 9.0, "y": 2.6, "z": 1},
{"id": "node5_2", "online": true, "rxSens": -139, "txGain": 20, "x": 9.0, "y": 4.2, "z": 1},
{"id": "node5_3", "online": true, "rxSens": -139, "txGain": 20, "x": 9.0, "y": 5.800000000000001, "z": 1},
{"id": "node5_4", "online": true, "rxSens": -139, "txGain": 20, "x": 9.0, "y": 7.4, "z": 1},
{"id": "node5_5", "online": true, "rxSens": -139, "txGain": 20, "x": 9.0, "y": 9.0, "z": 1}
],
"ignoreCollisions": false,
"timeScaling": 1,
"commands": {
"delayMs": 0,
"beforeStart": 1000,
"perNode": [
"fmt('%s/loclad -d --ecla_addr 127.0.0.1:%v --ecla_module LoRa --lora_agent websocket --lora_arg 127.0.0.1%s:%s --strategy_name %s --strategy_config=%s --dtnd=#%s/dtnd# --dtnd_args=#-w %v -r epidemic -n %s --ecla -e incoming -e emergency -d -i 500h#', env('LORA_ECLA'), 3000 + i, bind, nodeId, env('STRATEGY', 'quadrant'), env('STRATEGY_ARGS', ''), env('DTND'), 3000 + i, safe(nodeId))"
],
"start": [
"./sending.sh"
]
},
"web": ":8291"
}
21 changes: 21 additions & 0 deletions loraemu/scenarios/connected_grid/sending.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

SEND_MSG=${SEND_MSG:-"hello world"}
SEND_NODE=${SEND_NODE:-"0_0"}
RECEIVE_NODE=${RECEIVE_NODE:-"5_5"}
MSG_COUNT=${MSG_COUNT:-"1"}
SEND_WAIT=${SEND_WAIT:-"0"}

COORDS=(${SEND_NODE//_/ })

# Convert xy to port of dtnd. We know that ports are ascending from 3000 (0x0), so we can
# calculate the port of the sending node.
PORT=$(echo "scale=4; 3000 + ${COORDS[0]} + ${COORDS[1]} * 6" | bc -l)

echo "x=${COORDS[0]} y=${COORDS[1]} port=$PORT"

for (( c=1; c<=$MSG_COUNT; c++ ))
do
echo ${SEND_MSG} | "$DTND/dtnsend" -p $PORT --receiver dtn://node$RECEIVE_NODE/incoming;
sleep ${SEND_WAIT}
done
Binary file added loraemu/scenarios/darmstadt/darmstadt_7x7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions loraemu/scenarios/darmstadt/post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SENT=$(rg --no-filename "Transmission of bundle requested" $1/cmdlogs/*.txt | wc -l)
RECEIVED=$(rg --no-filename "Received bundle for local delivery" $1/cmdlogs/*.txt | wc -l)

if [ $SENT -eq $RECEIVED ] ; then
echo "EXPERIMENT RESULT: Success | tx: $SENT, rx: $RECEIVED"
else
echo "EXPERIMENT RESULT: Failed | tx: $SENT, rx: $RECEIVED"
exit 1
fi
Loading