diff --git a/scripts/bench-client.sh b/scripts/bench-client.sh new file mode 100755 index 0000000..f60d19e --- /dev/null +++ b/scripts/bench-client.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# scripts/bench-client.sh — M8 benchmark harness (Client side) +# Runs the simulator locally, pointing to a remote substrate server. + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +cd "$ROOT" + +SUBSTRATE_IP="${1:-}" +if [[ -z "$SUBSTRATE_IP" ]]; then + echo "Usage: ./scripts/bench-client.sh " + exit 1 +fi + +WARMUP_S="${WARMUP_S:-20}" +WINDOW_S="${WINDOW_S:-50}" +RATE_HZ="${RATE_HZ:-100}" +BUILD="${BUILD:-release}" + +SIMULATOR="$ROOT/target/$BUILD/simulator" +if [[ ! -x "$SIMULATOR" ]]; then + echo "Building simulator..." + cargo build --release -p simulator + SIMULATOR="$ROOT/target/release/simulator" +fi + +ENTITIES_LIST=(10000 50000 100000 200000) +LOSS_LIST=(0 1 5) + +for entities in "${ENTITIES_LIST[@]}"; do + devices=$(( entities / 5 )) + for loss in "${LOSS_LIST[@]}"; do + echo "" + echo "==================================================" + echo "Configuration: $entities entities, $loss% loss" + echo "==================================================" + read -p "Press Enter to start simulator for $((WARMUP_S + WINDOW_S + 5)) seconds..." /dev/null || true + wait "$SIM_PID" 2>/dev/null || true + done +done + +echo "All benchmark client runs complete!" diff --git a/scripts/bench-loss.sh b/scripts/bench-loss.sh index ea993a1..0a4780e 100755 --- a/scripts/bench-loss.sh +++ b/scripts/bench-loss.sh @@ -15,6 +15,7 @@ WINDOW_S="${WINDOW_S:-50}" RATE_HZ="${RATE_HZ:-100}" BUILD="${BUILD:-release}" IFACE="${IFACE:-eth0}" +RUN_SIMULATOR="${RUN_SIMULATOR:-1}" OUT_CSV="${OUT_CSV:-data/loopback/final_table.csv}" @@ -46,11 +47,19 @@ done step "Building ($BUILD)" if [[ "$BUILD" == "release" ]]; then - cargo build --release -p substrate -p simulator >/dev/null + if [[ "$RUN_SIMULATOR" -eq 1 ]]; then + cargo build --release -p substrate -p simulator >/dev/null + else + cargo build --release -p substrate >/dev/null + fi SUBSTRATE="$ROOT/target/release/substrate" SIMULATOR="$ROOT/target/release/simulator" else - cargo build -p substrate -p simulator >/dev/null + if [[ "$RUN_SIMULATOR" -eq 1 ]]; then + cargo build -p substrate -p simulator >/dev/null + else + cargo build -p substrate >/dev/null + fi SUBSTRATE="$ROOT/target/debug/substrate" SIMULATOR="$ROOT/target/debug/simulator" fi @@ -116,14 +125,19 @@ for entities in "${ENTITIES_LIST[@]}"; do fi fi - sim_args=( - --profile industrial - --rate-hz "$RATE_HZ" - --count 0 - --devices "$devices" - ) - RUST_LOG=warn "$SIMULATOR" "${sim_args[@]}" >"$LOG_DIR/sim_${entities}_${loss}.log" 2>&1 & - SIM_PID=$! + if [[ "$RUN_SIMULATOR" -eq 1 ]]; then + sim_args=( + --profile industrial + --rate-hz "$RATE_HZ" + --count 0 + --devices "$devices" + ) + RUST_LOG=warn "$SIMULATOR" "${sim_args[@]}" >"$LOG_DIR/sim_${entities}_${loss}.log" 2>&1 & + SIM_PID=$! + else + echo -e "\n${BOLD}Ready for: $entities entities, $loss% loss${RESET}" + read -p "Press Enter to begin recording (ensure Mac simulator is started)..." /dev/null || true - wait "$SIM_PID" 2>/dev/null || true - SIM_PID="" + if [[ "$RUN_SIMULATOR" -eq 1 ]]; then + kill -TERM "$SIM_PID" 2>/dev/null || true + wait "$SIM_PID" 2>/dev/null || true + SIM_PID="" + fi rec_after=$(get_value "$AFTER" 'substrate_received_total\{tier="t1"\}') drop_after=$(get_value "$AFTER" 'substrate_dropped_total\{tier="t1"\}') diff --git a/scripts/setup-cm5.sh b/scripts/setup-cm5.sh new file mode 100755 index 0000000..532c82b --- /dev/null +++ b/scripts/setup-cm5.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# scripts/setup-cm5.sh — CM5 Provisioning +# Installs necessary dependencies on the CM5 via SSH and syncs the repository. + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +cd "$ROOT" + +CM5_HOST="${1:-}" +CM5_USER="${2:-pi}" + +if [[ -z "$CM5_HOST" ]]; then + echo "Usage: ./scripts/setup-cm5.sh [USERNAME]" + echo "Example: ./scripts/setup-cm5.sh 192.168.1.50 pi" + exit 1 +fi + +echo "==================================================" +echo "1. Installing system dependencies on $CM5_HOST..." +echo "==================================================" + +ssh -t "$CM5_USER@$CM5_HOST" << 'EOF' +set -e +sudo apt-get update +sudo apt-get install -y curl lsof iproute2 gawk build-essential pkg-config libssl-dev cmake rsync + +if ! command -v cargo &> /dev/null; then + echo "Installing Rust toolchain..." + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +else + echo "Rust is already installed." +fi +EOF + +echo "" +echo "==================================================" +echo "2. Syncing codebase to CM5..." +echo "==================================================" +rsync -avz --exclude 'target' --exclude '.git' --exclude 'data' --exclude 'paper/_output' ./ "$CM5_USER@$CM5_HOST:~/quic_ecs_dt/" + +echo "" +echo "==================================================" +echo "✅ CM5 is configured and code is synced!" +echo "==================================================" +echo "To start the server benchmarking script, SSH into the CM5:" +echo " ssh $CM5_USER@$CM5_HOST" +echo " cd ~/quic_ecs_dt" +echo " source ~/.cargo/env" +echo " RUN_SIMULATOR=0 ./scripts/bench-loss.sh"