Skip to content

Commit 3573dfb

Browse files
committed
Add surveillance experiment (WIP)
1 parent 4291987 commit 3573dfb

File tree

13 files changed

+536
-24
lines changed

13 files changed

+536
-24
lines changed

Dockerfile

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,13 @@ FROM ubuntu:20.04
22

33
ENV PATH_WOTEMU /root/wotemu
44
ENV WAIT_GATEWAYS 10
5-
ENV VERSION_PUMBA 0.7.7
65

7-
RUN apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -y \
8-
python3 \
9-
python3-pip \
10-
iproute2 \
11-
iptables \
12-
tshark \
13-
wget \
14-
curl \
15-
mosquitto \
16-
dnsutils \
17-
cgroup-tools
18-
19-
COPY . ${PATH_WOTEMU}
20-
RUN ${PATH_WOTEMU}/scripts/install-pumba.sh
21-
RUN pip3 install ${PATH_WOTEMU}
6+
WORKDIR ${PATH_WOTEMU}
7+
COPY ./scripts ./scripts
8+
RUN ./scripts/install-image-deps.sh
9+
RUN ./scripts/install-cv-deps.sh
10+
RUN ./scripts/install-pumba.sh
11+
COPY . .
12+
RUN pip3 install -U .[apps]
2213

2314
ENTRYPOINT ["/root/wotemu/entrypoint.sh"]

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
graft wotemu/report/templates
2+
graft wotemu/apps/data
23
global-exclude *.pyc

examples/surveillance.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from wotemu.config import ConfigVars
2+
from wotemu.enums import NetworkConditions
3+
from wotemu.topology.models import (BuiltinApps, Network, Node, NodeApp,
4+
NodeResources, Topology)
5+
6+
_PORT_STREAM = 9898
7+
8+
_ARGS_COMPOSE_PORT_STREAM = {
9+
"environment": {
10+
ConfigVars.OTHER_PORTS_TCP.value: f"{_PORT_STREAM}",
11+
ConfigVars.OTHER_PORTS_UDP.value: f"{_PORT_STREAM}"
12+
}
13+
}
14+
15+
16+
def topology():
17+
network_field = Network(
18+
name="field",
19+
conditions=NetworkConditions.WIFI)
20+
21+
network_edge_link = Network(
22+
name="edge_link",
23+
conditions=NetworkConditions.REGULAR_3G)
24+
25+
network_cloud_user = Network(
26+
name="cloud_user",
27+
conditions=NetworkConditions.CABLE)
28+
29+
camera_resources = NodeResources(
30+
target_cpu_speed=200,
31+
mem_limit="256M")
32+
33+
node_camera = Node(
34+
name="camera",
35+
app=NodeApp(path=BuiltinApps.CAMERA, http=True),
36+
networks=[network_field],
37+
resources=camera_resources,
38+
args_compose=_ARGS_COMPOSE_PORT_STREAM)
39+
40+
detector_resources = NodeResources(
41+
target_cpu_speed=600,
42+
mem_limit="1G")
43+
44+
node_detector = Node(
45+
name="detector",
46+
app=NodeApp(path=BuiltinApps.CLOCK, http=True),
47+
networks=[network_field, network_edge_link],
48+
resources=detector_resources,
49+
args_compose=_ARGS_COMPOSE_PORT_STREAM)
50+
51+
node_cloud_server = Node(
52+
name="cloud_server",
53+
app=NodeApp(path=BuiltinApps.CLOCK, http=True),
54+
networks=[network_edge_link, network_cloud_user])
55+
56+
node_user = Node(
57+
name="user",
58+
app=NodeApp(path=BuiltinApps.CLOCK, http=True),
59+
networks=[network_cloud_user])
60+
61+
topology = Topology(nodes=[
62+
node_camera,
63+
node_detector,
64+
node_cloud_server,
65+
node_user
66+
])
67+
68+
return topology

examples/surveillance.yml

Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
1+
networks:
2+
cloud_user:
3+
attachable: true
4+
driver: overlay
5+
labels:
6+
org.fundacionctic.wotemu.net: ''
7+
name: cloud_user
8+
edge_link:
9+
attachable: true
10+
driver: overlay
11+
labels:
12+
org.fundacionctic.wotemu.net: ''
13+
name: edge_link
14+
field:
15+
attachable: true
16+
driver: overlay
17+
labels:
18+
org.fundacionctic.wotemu.net: ''
19+
name: field
20+
services:
21+
camera:
22+
cap_add:
23+
- ALL
24+
command:
25+
- app
26+
- --path
27+
- wotemu_camera
28+
- --enable-http
29+
depends_on:
30+
- gw_field
31+
- redis
32+
- docker_api_proxy
33+
deploy:
34+
resources:
35+
limits:
36+
memory: 256M
37+
environment:
38+
DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
39+
NODE_HOSTNAME: '{{.Node.Hostname}}'
40+
NODE_ID: '{{.Node.ID}}'
41+
OTHER_PORTS_TCP: '9898'
42+
OTHER_PORTS_UDP: '9898'
43+
PORT_CATALOGUE: '9090'
44+
PORT_COAP: '5683'
45+
PORT_HTTP: '80'
46+
PORT_MQTT: '1883'
47+
PORT_WS: '81'
48+
REDIS_URL: redis://redis
49+
SERVICE_ID: '{{.Service.ID}}'
50+
SERVICE_NAME: '{{.Service.Name}}'
51+
TARGET_CPU_SPEED: 200
52+
hostname: '{{.Task.Name}}'
53+
image: agmangas/wotemu
54+
labels:
55+
org.fundacionctic.wotemu.node: ''
56+
networks:
57+
- field
58+
volumes:
59+
- /var/run/docker.sock:/var/run/docker.sock
60+
cloud_server:
61+
cap_add:
62+
- ALL
63+
command:
64+
- app
65+
- --path
66+
- wotemu_clock
67+
- --enable-http
68+
depends_on:
69+
- docker_api_proxy
70+
- redis
71+
- gw_cloud_user
72+
- gw_edge_link
73+
environment:
74+
DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
75+
NODE_HOSTNAME: '{{.Node.Hostname}}'
76+
NODE_ID: '{{.Node.ID}}'
77+
PORT_CATALOGUE: '9090'
78+
PORT_COAP: '5683'
79+
PORT_HTTP: '80'
80+
PORT_MQTT: '1883'
81+
PORT_WS: '81'
82+
REDIS_URL: redis://redis
83+
SERVICE_ID: '{{.Service.ID}}'
84+
SERVICE_NAME: '{{.Service.Name}}'
85+
hostname: '{{.Task.Name}}'
86+
image: agmangas/wotemu
87+
labels:
88+
org.fundacionctic.wotemu.node: ''
89+
networks:
90+
- cloud_user
91+
- edge_link
92+
volumes:
93+
- /var/run/docker.sock:/var/run/docker.sock
94+
detector:
95+
cap_add:
96+
- ALL
97+
command:
98+
- app
99+
- --path
100+
- wotemu_clock
101+
- --enable-http
102+
depends_on:
103+
- gw_field
104+
- redis
105+
- docker_api_proxy
106+
- gw_edge_link
107+
deploy:
108+
resources:
109+
limits:
110+
memory: 1G
111+
environment:
112+
DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
113+
NODE_HOSTNAME: '{{.Node.Hostname}}'
114+
NODE_ID: '{{.Node.ID}}'
115+
OTHER_PORTS_TCP: '9898'
116+
OTHER_PORTS_UDP: '9898'
117+
PORT_CATALOGUE: '9090'
118+
PORT_COAP: '5683'
119+
PORT_HTTP: '80'
120+
PORT_MQTT: '1883'
121+
PORT_WS: '81'
122+
REDIS_URL: redis://redis
123+
SERVICE_ID: '{{.Service.ID}}'
124+
SERVICE_NAME: '{{.Service.Name}}'
125+
TARGET_CPU_SPEED: 600
126+
hostname: '{{.Task.Name}}'
127+
image: agmangas/wotemu
128+
labels:
129+
org.fundacionctic.wotemu.node: ''
130+
networks:
131+
- field
132+
- edge_link
133+
volumes:
134+
- /var/run/docker.sock:/var/run/docker.sock
135+
docker_api_proxy:
136+
cap_add:
137+
- ALL
138+
deploy:
139+
placement:
140+
constraints:
141+
- node.role == manager
142+
environment:
143+
CONTAINERS: '1'
144+
NETWORKS: '1'
145+
NODES: '1'
146+
SERVICES: '1'
147+
TASKS: '1'
148+
image: tecnativa/docker-socket-proxy
149+
networks:
150+
- field
151+
- cloud_user
152+
- edge_link
153+
volumes:
154+
- /var/run/docker.sock:/var/run/docker.sock
155+
gw_cloud_user:
156+
cap_add:
157+
- ALL
158+
command:
159+
- gateway
160+
- delay --time 5 --jitter 5 --distribution normal
161+
- rate --rate 100mbit
162+
depends_on:
163+
- docker_api_proxy
164+
- redis
165+
environment:
166+
DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
167+
NODE_HOSTNAME: '{{.Node.Hostname}}'
168+
NODE_ID: '{{.Node.ID}}'
169+
PORT_CATALOGUE: '9090'
170+
PORT_COAP: '5683'
171+
PORT_HTTP: '80'
172+
PORT_MQTT: '1883'
173+
PORT_WS: '81'
174+
REDIS_URL: redis://redis
175+
SERVICE_ID: '{{.Service.ID}}'
176+
SERVICE_NAME: '{{.Service.Name}}'
177+
hostname: '{{.Task.Name}}'
178+
image: agmangas/wotemu
179+
labels:
180+
org.fundacionctic.wotemu.gw: ''
181+
networks:
182+
- cloud_user
183+
volumes:
184+
- /var/run/docker.sock:/var/run/docker.sock
185+
gw_edge_link:
186+
cap_add:
187+
- ALL
188+
command:
189+
- gateway
190+
- delay --time 300 --jitter 150 --distribution normal
191+
- rate --rate 1500kbit
192+
depends_on:
193+
- docker_api_proxy
194+
- redis
195+
environment:
196+
DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
197+
NODE_HOSTNAME: '{{.Node.Hostname}}'
198+
NODE_ID: '{{.Node.ID}}'
199+
PORT_CATALOGUE: '9090'
200+
PORT_COAP: '5683'
201+
PORT_HTTP: '80'
202+
PORT_MQTT: '1883'
203+
PORT_WS: '81'
204+
REDIS_URL: redis://redis
205+
SERVICE_ID: '{{.Service.ID}}'
206+
SERVICE_NAME: '{{.Service.Name}}'
207+
hostname: '{{.Task.Name}}'
208+
image: agmangas/wotemu
209+
labels:
210+
org.fundacionctic.wotemu.gw: ''
211+
networks:
212+
- edge_link
213+
volumes:
214+
- /var/run/docker.sock:/var/run/docker.sock
215+
gw_field:
216+
cap_add:
217+
- ALL
218+
command:
219+
- gateway
220+
- delay --time 25 --jitter 5 --distribution normal
221+
- rate --rate 50mbit
222+
depends_on:
223+
- docker_api_proxy
224+
- redis
225+
environment:
226+
DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
227+
NODE_HOSTNAME: '{{.Node.Hostname}}'
228+
NODE_ID: '{{.Node.ID}}'
229+
PORT_CATALOGUE: '9090'
230+
PORT_COAP: '5683'
231+
PORT_HTTP: '80'
232+
PORT_MQTT: '1883'
233+
PORT_WS: '81'
234+
REDIS_URL: redis://redis
235+
SERVICE_ID: '{{.Service.ID}}'
236+
SERVICE_NAME: '{{.Service.Name}}'
237+
hostname: '{{.Task.Name}}'
238+
image: agmangas/wotemu
239+
labels:
240+
org.fundacionctic.wotemu.gw: ''
241+
networks:
242+
- field
243+
volumes:
244+
- /var/run/docker.sock:/var/run/docker.sock
245+
redis:
246+
image: redis:5
247+
labels:
248+
org.fundacionctic.wotemu.redis: ''
249+
networks:
250+
- field
251+
- cloud_user
252+
- edge_link
253+
ports:
254+
- '6379'
255+
user:
256+
cap_add:
257+
- ALL
258+
command:
259+
- app
260+
- --path
261+
- wotemu_clock
262+
- --enable-http
263+
depends_on:
264+
- docker_api_proxy
265+
- redis
266+
- gw_cloud_user
267+
environment:
268+
DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
269+
NODE_HOSTNAME: '{{.Node.Hostname}}'
270+
NODE_ID: '{{.Node.ID}}'
271+
PORT_CATALOGUE: '9090'
272+
PORT_COAP: '5683'
273+
PORT_HTTP: '80'
274+
PORT_MQTT: '1883'
275+
PORT_WS: '81'
276+
REDIS_URL: redis://redis
277+
SERVICE_ID: '{{.Service.ID}}'
278+
SERVICE_NAME: '{{.Service.Name}}'
279+
hostname: '{{.Task.Name}}'
280+
image: agmangas/wotemu
281+
labels:
282+
org.fundacionctic.wotemu.node: ''
283+
networks:
284+
- cloud_user
285+
volumes:
286+
- /var/run/docker.sock:/var/run/docker.sock
287+
version: '3.7'

0 commit comments

Comments
 (0)