Update to scripts
This commit is contained in:
62
scripts/bench-client.sh
Executable file
62
scripts/bench-client.sh
Executable file
@@ -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 <SUBSTRATE_IP>"
|
||||
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/tty
|
||||
|
||||
sim_args=(
|
||||
--addr "$SUBSTRATE_IP:9000"
|
||||
--profile industrial
|
||||
--rate-hz "$RATE_HZ"
|
||||
--count 0
|
||||
--devices "$devices"
|
||||
)
|
||||
|
||||
# Run in background
|
||||
RUST_LOG=warn "$SIMULATOR" "${sim_args[@]}" &
|
||||
SIM_PID=$!
|
||||
|
||||
sleep_time=$((WARMUP_S + WINDOW_S + 5))
|
||||
echo "Simulator running. Waiting ${sleep_time}s..."
|
||||
sleep "$sleep_time"
|
||||
|
||||
kill -TERM "$SIM_PID" 2>/dev/null || true
|
||||
wait "$SIM_PID" 2>/dev/null || true
|
||||
done
|
||||
done
|
||||
|
||||
echo "All benchmark client runs complete!"
|
||||
@@ -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/tty
|
||||
fi
|
||||
|
||||
sleep "$WARMUP_S"
|
||||
snapshot_to "$BEFORE"
|
||||
@@ -133,9 +147,11 @@ for entities in "${ENTITIES_LIST[@]}"; do
|
||||
sleep "$WINDOW_S"
|
||||
|
||||
snapshot_to "$AFTER"
|
||||
kill -TERM "$SIM_PID" 2>/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"\}')
|
||||
|
||||
51
scripts/setup-cm5.sh
Executable file
51
scripts/setup-cm5.sh
Executable file
@@ -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 <CM5_IP_OR_HOSTNAME> [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"
|
||||
Reference in New Issue
Block a user