95 lines
4.6 KiB
Bash
Executable File
95 lines
4.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
#
|
||
# TP6 — Bufferbloat-Messung (reproduziert die Methode von 2026-06-16)
|
||
#
|
||
# Misst NUR. Ändert NICHTS am Netz. Läuft auf einem kabelgebundenen Client in VLAN10.
|
||
#
|
||
# Vorbedingungen (unten geprüft; die definitive WARP-Kontrolle ist das Menüleisten-Icon,
|
||
# das kann kein Skript sehen):
|
||
# 1. WARP AUS (sonst misst du den Cloudflare-Tunnel, nicht die Liwest-Leitung)
|
||
# 2. genau EIN Interface (nicht dual-homed in VLAN10 UND VLAN20)
|
||
# 3. kabelgebunden, VLAN10 (IP 10.40.10.x)
|
||
#
|
||
# Aufruf: bash tp6-bufferbloat-messung.sh
|
||
# Ergebnis: Linerate-Probe + drei Ping-Reihen (idle / Upload-Last / Download-Last).
|
||
|
||
set -uo pipefail
|
||
|
||
TARGET="1.1.1.1"
|
||
PINGS=24
|
||
SETTLE=30 # Sekunden, die die Sättigung stabil läuft, bevor gepingt wird
|
||
UPLOAD_RATE_KB=430 # ~430 KB/s je Flow × 3 = ~10,3 Mbit (wie 2026-06-16)
|
||
UPLOAD_FILE="$(mktemp -t tp6-upload).bin"
|
||
|
||
# 🔴 speed.cloudflare.com blockt curl mit Default-User-Agent: /__down antwortet dann mit
|
||
# 403 und 1 Byte — die Flows sind sofort tot, die Ping-Reihe sieht sauber aus, und man
|
||
# haelt eine NICHT-Messung fuer "kein Bufferbloat". Deshalb UA + Referer mitschicken.
|
||
# (Am 2026-08-20 genau so passiert; /__up war davon nicht betroffen.)
|
||
CF_UA="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15"
|
||
CF_REF="https://speed.cloudflare.com/"
|
||
|
||
say() { printf '\n\033[1;36m== %s ==\033[0m\n' "$*"; }
|
||
warn() { printf '\033[1;33m⚠️ %s\033[0m\n' "$*"; }
|
||
|
||
say "0. Vorbedingungen"
|
||
|
||
# WARP / Default-Route: physisch (en*) = ok, utun* = VPN/WARP-Verdacht
|
||
DEFAULT_IF="$(route -n get default 2>/dev/null | awk '/interface:/{print $2}')"
|
||
if [[ "$DEFAULT_IF" == utun* ]]; then
|
||
warn "Default-Route über '$DEFAULT_IF' (utun = VPN/WARP). WARP AUSSCHALTEN, dann neu starten."
|
||
else
|
||
echo "Default-Route über '$DEFAULT_IF' — ok (physisch)."
|
||
fi
|
||
|
||
# Dual-Homing / VLAN10: genau eine 10.40.x.x-Adresse, und die muss 10.40.10.x sein
|
||
BF_IPS="$(ifconfig 2>/dev/null | grep -oE 'inet 10\.40\.[0-9]+\.[0-9]+' | awk '{print $2}')"
|
||
BF_COUNT="$(printf '%s\n' "$BF_IPS" | grep -c . || true)"
|
||
echo "BF-Adressen (10.40.x.x):"; printf '%s\n' "$BF_IPS" | sed 's/^/ /'
|
||
if [[ "$BF_COUNT" -ne 1 ]]; then
|
||
warn "$BF_COUNT BF-Adressen aktiv — dual-homed? Genau EIN Interface behalten (VLAN10)."
|
||
fi
|
||
if ! printf '%s\n' "$BF_IPS" | grep -q '^10\.40\.10\.'; then
|
||
warn "Keine 10.40.10.x-Adresse (VLAN10) — kabelgebunden in VLAN10 messen."
|
||
fi
|
||
|
||
# Upload-Datei (200 MB) anlegen
|
||
mkfile 200M "$UPLOAD_FILE" 2>/dev/null || dd if=/dev/zero of="$UPLOAD_FILE" bs=1m count=200 2>/dev/null
|
||
|
||
# Linerate-Probe: wie schnell ist der Upload wirklich? (Runbook §2.3/§5.4)
|
||
say "Linerate-Probe (10 s voller Upload)"
|
||
curl -s -o /dev/null --max-time 10 -A "$CF_UA" -e "$CF_REF" \
|
||
-w " Upload-Linerate: %{speed_upload} B/s\n" \
|
||
--data-binary @"$UPLOAD_FILE" "https://speed.cloudflare.com/__up" || true
|
||
echo " (Referenz 2026-06-16: ~1,28 MB/s = 10,3 Mbit. Deutlich mehr = Tarif geändert → Rate unten anpassen.)"
|
||
|
||
# 1. Idle-Baseline
|
||
say "1. Idle-Baseline (Netz ruhig)"
|
||
ping -c "$PINGS" "$TARGET"
|
||
|
||
# 2. Upload-Sättigung + Ping unter Last
|
||
say "2. Upload-Sättigung (3 Flows × ${UPLOAD_RATE_KB} KB/s) — ${SETTLE}s stabilisieren"
|
||
curl -s -o /dev/null -A "$CF_UA" -e "$CF_REF" --limit-rate "${UPLOAD_RATE_KB}K" --data-binary @"$UPLOAD_FILE" "https://speed.cloudflare.com/__up" & UP1=$!
|
||
curl -s -o /dev/null -A "$CF_UA" -e "$CF_REF" --limit-rate "${UPLOAD_RATE_KB}K" --data-binary @"$UPLOAD_FILE" "https://speed.cloudflare.com/__up" & UP2=$!
|
||
curl -s -o /dev/null -A "$CF_UA" -e "$CF_REF" --limit-rate "${UPLOAD_RATE_KB}K" --data-binary @"$UPLOAD_FILE" "https://speed.cloudflare.com/__up" & UP3=$!
|
||
sleep "$SETTLE"
|
||
say "2a. Ping unter Upload-Last"
|
||
ping -c "$PINGS" "$TARGET"
|
||
kill "$UP1" "$UP2" "$UP3" 2>/dev/null; wait 2>/dev/null
|
||
|
||
# 3. Download-Sättigung + Ping unter Last
|
||
say "3. Download-Sättigung (3 parallele Downloads) — ${SETTLE}s stabilisieren"
|
||
curl -s -o /dev/null -A "$CF_UA" -e "$CF_REF" "https://speed.cloudflare.com/__down?bytes=2000000000" & DL1=$!
|
||
curl -s -o /dev/null -A "$CF_UA" -e "$CF_REF" "https://speed.cloudflare.com/__down?bytes=2000000000" & DL2=$!
|
||
curl -s -o /dev/null -A "$CF_UA" -e "$CF_REF" "https://speed.cloudflare.com/__down?bytes=2000000000" & DL3=$!
|
||
sleep "$SETTLE"
|
||
say "3a. Ping unter Download-Last"
|
||
ping -c "$PINGS" "$TARGET"
|
||
kill "$DL1" "$DL2" "$DL3" 2>/dev/null; wait 2>/dev/null
|
||
|
||
rm -f "$UPLOAD_FILE"
|
||
|
||
say "Fertig"
|
||
echo "Notiere die drei min/avg/max-Zeilen (idle / Upload / Download)."
|
||
echo "Gegenprobe im Browser: https://www.waveform.com/tools/bufferbloat"
|
||
echo "Ergebnis eintragen in docs/tp6-praemisse-messrunbook.md §5."
|