add Final Infrastructure Setup
This commit is contained in:
commit
7733dde658
174 changed files with 204949 additions and 0 deletions
|
|
@ -0,0 +1,119 @@
|
|||
network_scenarios:
|
||||
# ---------------------------------------------------------------------------
|
||||
# 00. Baseline
|
||||
# ---------------------------------------------------------------------------
|
||||
baseline:
|
||||
description: "Normalzustand"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 01. Slow Connection
|
||||
# ---------------------------------------------------------------------------
|
||||
slow-connection:
|
||||
description: "Langsam & Latenz (Satellit)"
|
||||
interfaces:
|
||||
ens4:
|
||||
- {
|
||||
root: true,
|
||||
type: "tbf",
|
||||
args: "rate 256kbit burst 1540 latency 50ms",
|
||||
}
|
||||
ens5:
|
||||
- {
|
||||
root: true,
|
||||
type: "tbf",
|
||||
args: "rate 256kbit burst 1540 latency 50ms",
|
||||
}
|
||||
ens6:
|
||||
- { root: true, handle: "1:", type: "netem", args: "delay 300ms" }
|
||||
- {
|
||||
parent: "1:1",
|
||||
handle: "10:",
|
||||
type: "tbf",
|
||||
args: "rate 512kbit burst 1540 latency 50ms",
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 02. High Latency
|
||||
# ---------------------------------------------------------------------------
|
||||
high-latency:
|
||||
description: "Hohe Latenz"
|
||||
interfaces:
|
||||
ens4:
|
||||
- {
|
||||
root: true,
|
||||
type: "netem",
|
||||
args: "delay 200ms 20ms distribution normal",
|
||||
}
|
||||
ens5:
|
||||
- {
|
||||
root: true,
|
||||
type: "netem",
|
||||
args: "delay 200ms 20ms distribution normal",
|
||||
}
|
||||
ens6:
|
||||
- {
|
||||
root: true,
|
||||
type: "netem",
|
||||
args: "delay 350ms 30ms distribution normal",
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 03. Packet Loss
|
||||
# ---------------------------------------------------------------------------
|
||||
packet-loss:
|
||||
description: "Paketverlust"
|
||||
interfaces:
|
||||
ens4: [{ root: true, type: "netem", args: "loss 15% 10%" }]
|
||||
ens5: [{ root: true, type: "netem", args: "loss 15% 10%" }]
|
||||
ens6: [{ root: true, type: "netem", args: "loss 5% 2%" }]
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 06. Congestion
|
||||
# ---------------------------------------------------------------------------
|
||||
congestion:
|
||||
description: "Überlastung (Delay + Loss + Rate Limit)"
|
||||
interfaces:
|
||||
ens4:
|
||||
- {
|
||||
root: true,
|
||||
handle: "1:",
|
||||
type: "netem",
|
||||
args: "delay 50ms 20ms loss 3% 5%",
|
||||
}
|
||||
- {
|
||||
parent: "1:1",
|
||||
handle: "10:",
|
||||
type: "tbf",
|
||||
args: "rate 2mbit burst 32kbit latency 800ms",
|
||||
}
|
||||
ens5:
|
||||
- {
|
||||
root: true,
|
||||
handle: "1:",
|
||||
type: "netem",
|
||||
args: "delay 50ms 20ms loss 3% 5%",
|
||||
}
|
||||
- {
|
||||
parent: "1:1",
|
||||
handle: "10:",
|
||||
type: "tbf",
|
||||
args: "rate 2mbit burst 32kbit latency 800ms",
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 07. Partial Outage (IPTables Block)
|
||||
# ---------------------------------------------------------------------------
|
||||
partial-outage:
|
||||
description: "Verbindung W0 <-> W1 tot"
|
||||
blocks:
|
||||
- { src: "ens4", dst: "ens5" }
|
||||
- { src: "ens5", dst: "ens4" }
|
||||
interfaces:
|
||||
ens6: [{ root: true, type: "netem", args: "delay 10ms" }]
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 08. Flapping
|
||||
# ---------------------------------------------------------------------------
|
||||
flapping:
|
||||
description: "Wackelkontakt (30s an/aus)"
|
||||
flapping_enabled: true
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
---
|
||||
- name: "Szenario-Info: {{ network_scenarios[scenario].description }}"
|
||||
debug:
|
||||
msg: "Activating Szenario '{{ scenario }}'"
|
||||
|
||||
# --- 1. CLEANUP
|
||||
|
||||
- name: Stop Flapping Service (falls aktiv)
|
||||
systemd:
|
||||
name: flapping_simulation
|
||||
state: stopped
|
||||
enabled: no
|
||||
ignore_errors: true
|
||||
|
||||
- name: Reset Traffic Control
|
||||
shell: "tc qdisc del dev {{ item }} root"
|
||||
loop: [ens4, ens5, ens6]
|
||||
ignore_errors: true
|
||||
changed_when: false
|
||||
|
||||
- name: Reset IPTables Blocks
|
||||
iptables:
|
||||
chain: FORWARD
|
||||
action: flush
|
||||
changed_when: false
|
||||
|
||||
# --- 2. INSTALL FLAPPING
|
||||
|
||||
- name: Installing Flapping script & service
|
||||
block:
|
||||
- template:
|
||||
src: flapping_service.sh.j2
|
||||
dest: /usr/local/bin/flapping_simulation.sh
|
||||
mode: "0755"
|
||||
- template:
|
||||
src: flapping.service.j2
|
||||
dest: /etc/systemd/system/flapping_simulation.service
|
||||
- systemd:
|
||||
name: flapping_simulation
|
||||
state: started
|
||||
daemon_reload: yes
|
||||
when: network_scenarios[scenario].flapping_enabled | default(false)
|
||||
|
||||
# --- 3. APPLY TRAFFIC CONTROL
|
||||
|
||||
- name: Apply Complex TC Rules
|
||||
shell: >
|
||||
tc qdisc add dev {{ item.0.key }}
|
||||
{% if item.1.root | default(false) %}root{% else %}parent {{ item.1.parent }}{% endif %}
|
||||
{% if item.1.handle is defined %}handle {{ item.1.handle }}{% endif %}
|
||||
{{ item.1.type }}
|
||||
{{ item.1.args }}
|
||||
loop: "{{ network_scenarios[scenario].interfaces | default({}) | dict2items | subelements('value') }}"
|
||||
when: network_scenarios[scenario].interfaces is defined
|
||||
|
||||
# --- 4. APPLY IPTABLES BLOCKS ---
|
||||
|
||||
- name: Apply Static Blocks
|
||||
iptables:
|
||||
chain: FORWARD
|
||||
in_interface: "{{ item.src }}"
|
||||
out_interface: "{{ item.dst }}"
|
||||
jump: DROP
|
||||
loop: "{{ network_scenarios[scenario].blocks | default([]) }}"
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=Network Flapping Simulation
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/flapping_simulation.sh
|
||||
ExecStop=/usr/bin/iptables -D FORWARD -i ens4 -o ens5 -j DROP ; /usr/bin/iptables -D FORWARD -i ens5 -o ens4 -j DROP
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
while true; do
|
||||
iptables -I FORWARD 1 -i ens4 -o ens5 -j DROP
|
||||
iptables -I FORWARD 1 -i ens5 -o ens4 -j DROP
|
||||
sleep 30
|
||||
|
||||
iptables -D FORWARD -i ens4 -o ens5 -j DROP 2>/dev/null || true
|
||||
iptables -D FORWARD -i ens5 -o ens4 -j DROP 2>/dev/null || true
|
||||
sleep 30
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue