forked from eniac/MimicNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_2_generate.sh
More file actions
executable file
·44 lines (34 loc) · 971 Bytes
/
run_2_generate.sh
File metadata and controls
executable file
·44 lines (34 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
set -e
if [[ -z ${1} ]]; then
echo "Usage: run_2_generate.sh variant [simulate_options]"
exit 1
fi
. /etc/profile.d/mimicnet.sh
set -x
BASE_DIR=`pwd`
VARIANT=${1}
mkdir -p ${BASE_DIR}/data
echo "Starting simulation..."
cd simulate/simulate_${VARIANT}
exec 5>&1
RESULTS_DIR=$(./run.sh RecordAll ${@:2} | tee /dev/fd/5 | tail -n 1)
RESULTS_FILE=${RESULTS_DIR##*/}
rsync -a ${RESULTS_DIR}/ ${BASE_DIR}/data/${RESULTS_FILE}
rm -r ${RESULTS_DIR}
if [[ ${RESULTS_DIR} =~ /sw([0-9]+)_ ]]; then
NUM_SWITCHES=${BASH_REMATCH[1]}
else
echo "ERROR: unable to extract switch count from ${RESULTS_DIR}"
exit 1
fi
if [[ ${RESULTS_DIR} =~ _s([0-9]+)_ ]]; then
SEED=${BASH_REMATCH[1]}
else
echo "ERROR: unable to extract seed from ${RESULTS_DIR}"
exit 1
fi
cd ${BASE_DIR}
prepare/run_prepare.sh data/${RESULTS_FILE} ${SEED} ${NUM_SWITCHES}
echo "Generate complete! Results are in the following directory:"
echo "data/${RESULTS_FILE}"