-
Notifications
You must be signed in to change notification settings - Fork 198
/
Copy pathpumba_combined.sh
executable file
·47 lines (36 loc) · 1.13 KB
/
pumba_combined.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# This script demonstrates using both netem and iptables commands together
# to create more complex and realistic network chaos scenarios.
# Common image for both commands
NETTOOLS_IMAGE="ghcr.io/alexei-led/pumba-alpine-nettools:latest"
# Pull the image in advance (optional)
docker pull $NETTOOLS_IMAGE
# Create asymmetric network degradation scenario:
# 1. Add delay to outgoing traffic (slow uploads) with netem
# 2. Drop incoming packets (simulate packet loss) with iptables
# Add delay to outgoing traffic (simulates slow upload)
../bin/pumba --log-level info netem \
--duration 5m \
--interface eth0 \
--tc-image $NETTOOLS_IMAGE \
delay \
--time 500 \
--jitter 50 \
combined-server &
NETEM_PID=$!
# Wait a moment to ensure the first command starts properly
sleep 2
# Drop incoming packets (simulates packet loss)
../bin/pumba --log-level info iptables \
--duration 5m \
--protocol tcp \
--dst-port 80 \
--iptables-image $NETTOOLS_IMAGE \
loss \
--probability 0.3 \
combined-server &
IPTABLES_PID=$!
# Wait for both processes to complete
wait $NETEM_PID
wait $IPTABLES_PID
echo "Network chaos complete!"