99 lines
3.1 KiB
Bash
Executable File
99 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#!/bin/bash
|
|
# Continuous traffic generator for OAI UE containers (no intervals, runs virtually forever).
|
|
# Usage examples:
|
|
# ./traffic_runner.sh --profile boring
|
|
# PROFILE=bulk_download ./traffic_runner.sh
|
|
|
|
set -euo pipefail
|
|
|
|
PROFILE="${PROFILE:-}"
|
|
|
|
# Fixed server coordinates
|
|
IPERF_HOST_UDP="192.168.71.129"
|
|
IPERF_HOST_TCP="192.168.71.130"
|
|
IPERF_PORT_UDP=5201
|
|
IPERF_PORT_TCP=5202
|
|
OAITUN_IP="$(ip -o -4 addr show dev oaitun_ue1 | awk '{print $4}' | cut -d/ -f1)"
|
|
|
|
# Very long duration to approximate "forever"
|
|
LONG_T="${LONG_T:-31536000}" # 1 year in seconds
|
|
|
|
# -------------- args --------------
|
|
if [[ $# -gt 0 ]]; then
|
|
case "$1" in
|
|
--profile=*) PROFILE="${1#--profile=}"; shift ;;
|
|
--profile) PROFILE="${2-}"; shift 2 ;;
|
|
-p=*) PROFILE="${1#-p=}"; shift ;;
|
|
-p) PROFILE="${2-}"; shift 2 ;;
|
|
-*) ;; # ignore other flags
|
|
*) PROFILE="$1"; shift ;;
|
|
esac
|
|
fi
|
|
|
|
[[ -n "$PROFILE" ]] || { echo "ERROR: --profile is required" >&2; exit 2; }
|
|
|
|
iperf_tcp_dl_forever() { ( iperf -c "$IPERF_HOST_TCP" -B "$OAITUN_IP" -p "$IPERF_PORT_TCP" -R -t "$LONG_T" >/dev/null 2>&1 ); }
|
|
iperf_tcp_ul_forever() { ( iperf -c "$IPERF_HOST_TCP" -B "$OAITUN_IP" -p "$IPERF_PORT_TCP" -t "$LONG_T" >/dev/null 2>&1 ); }
|
|
# iperf_udp_dl_forever() { ( nohup iperf -u -c "$IPERF_HOST_UDP" -B "$OAITUN_IP" -p "$IPERF_PORT_UDP" -R -t "$LONG_T" >/dev/null 2>&1 ); }
|
|
iperf_udp_dl_forever() { ( iperf -u -c "$IPERF_HOST_UDP" -B "$OAITUN_IP" -p "$IPERF_PORT_UDP" -R -b $1 -t "$LONG_T" >/dev/null 2>&1 ); }
|
|
iperf_udp_ul_forever() { ( iperf -u -c "$IPERF_HOST_UDP" -B "$OAITUN_IP" -p "$IPERF_PORT_UDP" -b $1 -t "$LONG_T" >/dev/null 2>&1 ); }
|
|
|
|
# ---------------- profiles ----------------
|
|
do_boring() {
|
|
iperf_udp_dl_forever 500K
|
|
wait
|
|
# iperf -c "$IPERF_HOST" -p "$IPERF_PORT" -B "$OAITUN_IP" -u -b 25M -t "$LONG_T"
|
|
}
|
|
|
|
do_browsing() {
|
|
iperf_tcp_dl_forever
|
|
iperf_tcp_ul_forever
|
|
wait
|
|
}
|
|
|
|
do_video() {
|
|
iperf_udp_dl_forever 6M
|
|
wait
|
|
}
|
|
|
|
do_bulk_download() {
|
|
iperf -c "$IPERF_HOST" -p "$IPERF_PORT" -B "$OAITUN_IP" -R -P 8 -w 1M -t "$LONG_T"
|
|
wait
|
|
}
|
|
|
|
do_voip() {
|
|
iperf -c "$IPERF_HOST" -p "$IPERF_PORT" -B "$OAITUN_IP" -R -u -b 80K -t "$LONG_T";
|
|
iperf -c "$IPERF_HOST" -p "$IPERF_PORT" -B "$OAITUN_IP" -u -b 80K -t "$LONG_T";
|
|
wait
|
|
}
|
|
|
|
do_iot_chatty() {
|
|
iperf -c "$IPERF_HOST" -p "$IPERF_PORT" -B "$OAITUN_IP" -R -u -b 40K -t "$LONG_T";
|
|
iperf -c "$IPERF_HOST" -p "$IPERF_PORT" -B "$OAITUN_IP" -u -b 20K -t "$LONG_T";
|
|
wait
|
|
}
|
|
|
|
do_gaming() {
|
|
iperf -c "$IPERF_HOST" -p "$IPERF_PORT" -B "$OAITUN_IP" -R -u -b 120K -t "$LONG_T";
|
|
iperf -c "$IPERF_HOST" -p "$IPERF_PORT" -B "$OAITUN_IP" -u -b 10K -t "$LONG_T";
|
|
wait
|
|
}
|
|
|
|
do_idle() {
|
|
tail -f /dev/null
|
|
}
|
|
|
|
# -------------- dispatch --------------
|
|
case "$PROFILE" in
|
|
boring) do_boring;;
|
|
browsing) do_browsing;;
|
|
video) do_video;;
|
|
bulk_download) do_bulk_download;;
|
|
voip) do_voip;;
|
|
iot_chatty) do_iot_chatty;;
|
|
gaming) do_gaming;;
|
|
idle) do_idle;;
|
|
*) echo "Unknown profile: $PROFILE" >&2; exit 1;;
|
|
esac
|