diff --git a/.gitignore b/.gitignore index 121e2b4..996b361 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ compile_commands.json platform.xml scenarios inputs.json -results/logs +logs +analysis/scheduler/*.csv \ No newline at end of file diff --git a/README.md b/README.md index 8434108..205417a 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ - Then `make`from the project root folder - If the project compiles successfully, you are ready to run simulations! ### Paper's Simulations -- To run all the simulations presented in the paper simply run `./results/paper.sh` -this will create the file `results/results.csv` containing all the results. This will also create an -`inputs.json` that you can modify at your convenience -### Simulations -- The file `inputs.json` controls the inputs to the simulator. You should only care about this file -if you want custom simulations -- To run the simulation just run `make run` This will also generate a file called `platform.xml` corresponding to the simulated platform +- To run a particular experiment, use the `run_*.sh` scripts +- Results are available in the `results/` folder +### Notes +- The `inputs.json` file controls the inputs to the simulator. +You should only care about this file if you want custom simulations. +- To run a simulation using `inputs.json` just run `make run` +This will also generate a file called `platform.xml` corresponding to the simulated platform - To generate a *csv* output from the simulation results you can use: `make run 2>&1|./parser.awk` diff --git a/run_strategy_combined.sh b/run_strategy_combined.sh new file mode 100755 index 0000000..aeb1671 --- /dev/null +++ b/run_strategy_combined.sh @@ -0,0 +1,136 @@ +#!/usr/bin/env bash + +set -e + +wai=$(dirname $(readlink -f "$0")) +scenarios="${wai}/scenarios" +inputs="${wai}/inputs.json" +simulator="make run" +sched="${wai}/analysis/scheduler/analysis.sh" +parser="${wai}/parser.awk" +results="${wai}/results/strategy_combined.csv" # UPDATE HERE TO CHANGE OUTPUT CSV FILE NAME +aheaders="simkey,wireless,wakeupfor" +avalues="none,none,none" +log_file="${wai}/logs/$(date +%s).org" && mkdir -p "${wai}/logs/" +gen_log=0 # Should we generate logs ? + +run-simulation () { + # Generate inputs + $scenarios $seed $simtime $wakeupevery $wakeupfor $n_nodes $extended $hint $poff $pon $prx $ptx $datasize $bitrate $hintsize $latency $shutdown_on_rcv $unschedule_on_rcv $farhint $hintdist > "$inputs" + + # Init logs + [ $gen_log -eq 1 ] && echo -e "* seed=$seed simtime=$simtime wakeupevery=$wakeupevery wakeupfor=$wakeupfor n_nodes=$n_nodes extended=$extended hint=$hint poff=$poff pon=$pon prx=$prx ptx=$ptx datasize=$datasize bitrate=$bitrate \n" >> "${log_file}" + + # Run simulations + tmp=$(mktemp) + $simulator &> $tmp + [ $gen_log -eq 1 ] && cp $tmp "${log_file}" + + # Gen csv + [ ! -e "$results" ] && { cat $tmp | $parser | sed "1 s/$/,${aheaders}/g" | sed "2,\$s/$/,${avalues}/" > "$results"; } + [ -e "$results" ] && { cat $tmp | $parser | sed 1d | sed "s/$/,${avalues}/" >> "$results"; } + + # Gen scheduler analysis + [ $seed -eq 1 ] && $sched $tmp "logs/$(echo ${avalues}|tr ',' '_')_hint${hint}_extended${extended}.png" + + # Clear tmp + rm $tmp +} + +# Default Parameters +seed=0 +simtime=86400 # One day +wakeupevery=3600 +wakeupfor=60 +n_nodes=13 # First node will be the sender so n_receivers=n_nodes-1 +extended="false" +hint="false" +poff=0 +pon=0.4 +prx=0.16 +ptx=0.16 +datasize=1000000 # 1Mb +hintsize=8 # Integer +hintdist=10800 # Hint distance while using farhint +latency=0 # in Seconds +shutdown_on_rcv="true" +unschedule_on_rcv="true" +farhint="true" +bitrate="100kbps" + + +run-scenarios() { + # Configure number of seed per scenarios + nseed=200 + + # Baseline + avalues="baseline,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rBaseline...${seed}" + run-simulation + done + echo + + # Hint + hint="true" + avalues="hint,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rHint...${seed}" + run-simulation + done + hint="false" + echo + + # Extended + extended="true" + avalues="extended,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rExtended...${seed}" + run-simulation + done + extended="false" + echo + + # Hint+Extended + extended="true" + hint="true" + avalues="hintandextended,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rHint + Extended...${seed}" + run-simulation + done + extended="false" + hint="false" + echo +} + +# Clean previous runs +[ -e "${results}" ] && rm "${results}" + +for wakeupfor in 60 180 +do + + # Lora + echo "----- Run Lora (wakeupfor=$wakeupfor) -----" + wireless="lora" + bitrate="50kbps" + pon=0.4 + prx=0.16 + ptx=0.16 + latency=0 + run-scenarios + + # NbIot + echo "----- Run NbIoT (wakeupfor=$wakeupfor) -----" + wireless="nbiot" + bitrate="200kbps" + pon=0.4 + prx=0.65 + ptx=0.65 + latency=0 + run-scenarios +done diff --git a/run_strategies.sh b/run_strategy_farhint.sh similarity index 96% rename from run_strategies.sh rename to run_strategy_farhint.sh index 7c9a4ae..57a7c73 100755 --- a/run_strategies.sh +++ b/run_strategy_farhint.sh @@ -8,7 +8,7 @@ inputs="${wai}/inputs.json" simulator="make run" sched="${wai}/analysis/scheduler/analysis.sh" parser="${wai}/parser.awk" -results="${wai}/test.csv" # UPDATE HERE TO CHANGE OUTPUT CSV FILE NAME +results="${wai}/results/strategy_farhint.csv" # UPDATE HERE TO CHANGE OUTPUT CSV FILE NAME aheaders="simkey,wireless,wakeupfor" avalues="none,none,none" log_file="${wai}/logs/$(date +%s).org" && mkdir -p "${wai}/logs/" @@ -55,7 +55,7 @@ hintdist=10800 # Hint distance while using farhint latency=0 # in Seconds shutdown_on_rcv="false" unschedule_on_rcv="false" -farhint="false" +farhint="true" bitrate="100kbps" diff --git a/run_strategy_sor.sh b/run_strategy_sor.sh new file mode 100755 index 0000000..2f36123 --- /dev/null +++ b/run_strategy_sor.sh @@ -0,0 +1,136 @@ +#!/usr/bin/env bash + +set -e + +wai=$(dirname $(readlink -f "$0")) +scenarios="${wai}/scenarios" +inputs="${wai}/inputs.json" +simulator="make run" +sched="${wai}/analysis/scheduler/analysis.sh" +parser="${wai}/parser.awk" +results="${wai}/results/strategy_sor.csv" # UPDATE HERE TO CHANGE OUTPUT CSV FILE NAME +aheaders="simkey,wireless,wakeupfor" +avalues="none,none,none" +log_file="${wai}/logs/$(date +%s).org" && mkdir -p "${wai}/logs/" +gen_log=0 # Should we generate logs ? + +run-simulation () { + # Generate inputs + $scenarios $seed $simtime $wakeupevery $wakeupfor $n_nodes $extended $hint $poff $pon $prx $ptx $datasize $bitrate $hintsize $latency $shutdown_on_rcv $unschedule_on_rcv $farhint $hintdist > "$inputs" + + # Init logs + [ $gen_log -eq 1 ] && echo -e "* seed=$seed simtime=$simtime wakeupevery=$wakeupevery wakeupfor=$wakeupfor n_nodes=$n_nodes extended=$extended hint=$hint poff=$poff pon=$pon prx=$prx ptx=$ptx datasize=$datasize bitrate=$bitrate \n" >> "${log_file}" + + # Run simulations + tmp=$(mktemp) + $simulator &> $tmp + [ $gen_log -eq 1 ] && cp $tmp "${log_file}" + + # Gen csv + [ ! -e "$results" ] && { cat $tmp | $parser | sed "1 s/$/,${aheaders}/g" | sed "2,\$s/$/,${avalues}/" > "$results"; } + [ -e "$results" ] && { cat $tmp | $parser | sed 1d | sed "s/$/,${avalues}/" >> "$results"; } + + # Gen scheduler analysis + [ $seed -eq 1 ] && $sched $tmp "logs/$(echo ${avalues}|tr ',' '_')_hint${hint}_extended${extended}.png" + + # Clear tmp + rm $tmp +} + +# Default Parameters +seed=0 +simtime=86400 # One day +wakeupevery=3600 +wakeupfor=60 +n_nodes=13 # First node will be the sender so n_receivers=n_nodes-1 +extended="false" +hint="false" +poff=0 +pon=0.4 +prx=0.16 +ptx=0.16 +datasize=1000000 # 1Mb +hintsize=8 # Integer +hintdist=10800 # Hint distance while using farhint +latency=0 # in Seconds +shutdown_on_rcv="true" +unschedule_on_rcv="false" +farhint="false" +bitrate="100kbps" + + +run-scenarios() { + # Configure number of seed per scenarios + nseed=200 + + # Baseline + avalues="baseline,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rBaseline...${seed}" + run-simulation + done + echo + + # Hint + hint="true" + avalues="hint,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rHint...${seed}" + run-simulation + done + hint="false" + echo + + # Extended + extended="true" + avalues="extended,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rExtended...${seed}" + run-simulation + done + extended="false" + echo + + # Hint+Extended + extended="true" + hint="true" + avalues="hintandextended,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rHint + Extended...${seed}" + run-simulation + done + extended="false" + hint="false" + echo +} + +# Clean previous runs +[ -e "${results}" ] && rm "${results}" + +for wakeupfor in 60 180 +do + + # Lora + echo "----- Run Lora (wakeupfor=$wakeupfor) -----" + wireless="lora" + bitrate="50kbps" + pon=0.4 + prx=0.16 + ptx=0.16 + latency=0 + run-scenarios + + # NbIot + echo "----- Run NbIoT (wakeupfor=$wakeupfor) -----" + wireless="nbiot" + bitrate="200kbps" + pon=0.4 + prx=0.65 + ptx=0.65 + latency=0 + run-scenarios +done diff --git a/run_strategy_uor.sh b/run_strategy_uor.sh new file mode 100755 index 0000000..cc78291 --- /dev/null +++ b/run_strategy_uor.sh @@ -0,0 +1,136 @@ +#!/usr/bin/env bash + +set -e + +wai=$(dirname $(readlink -f "$0")) +scenarios="${wai}/scenarios" +inputs="${wai}/inputs.json" +simulator="make run" +sched="${wai}/analysis/scheduler/analysis.sh" +parser="${wai}/parser.awk" +results="${wai}/results/strategy_uor.csv" # UPDATE HERE TO CHANGE OUTPUT CSV FILE NAME +aheaders="simkey,wireless,wakeupfor" +avalues="none,none,none" +log_file="${wai}/logs/$(date +%s).org" && mkdir -p "${wai}/logs/" +gen_log=0 # Should we generate logs ? + +run-simulation () { + # Generate inputs + $scenarios $seed $simtime $wakeupevery $wakeupfor $n_nodes $extended $hint $poff $pon $prx $ptx $datasize $bitrate $hintsize $latency $shutdown_on_rcv $unschedule_on_rcv $farhint $hintdist > "$inputs" + + # Init logs + [ $gen_log -eq 1 ] && echo -e "* seed=$seed simtime=$simtime wakeupevery=$wakeupevery wakeupfor=$wakeupfor n_nodes=$n_nodes extended=$extended hint=$hint poff=$poff pon=$pon prx=$prx ptx=$ptx datasize=$datasize bitrate=$bitrate \n" >> "${log_file}" + + # Run simulations + tmp=$(mktemp) + $simulator &> $tmp + [ $gen_log -eq 1 ] && cp $tmp "${log_file}" + + # Gen csv + [ ! -e "$results" ] && { cat $tmp | $parser | sed "1 s/$/,${aheaders}/g" | sed "2,\$s/$/,${avalues}/" > "$results"; } + [ -e "$results" ] && { cat $tmp | $parser | sed 1d | sed "s/$/,${avalues}/" >> "$results"; } + + # Gen scheduler analysis + [ $seed -eq 1 ] && $sched $tmp "logs/$(echo ${avalues}|tr ',' '_')_hint${hint}_extended${extended}.png" + + # Clear tmp + rm $tmp +} + +# Default Parameters +seed=0 +simtime=86400 # One day +wakeupevery=3600 +wakeupfor=60 +n_nodes=13 # First node will be the sender so n_receivers=n_nodes-1 +extended="false" +hint="false" +poff=0 +pon=0.4 +prx=0.16 +ptx=0.16 +datasize=1000000 # 1Mb +hintsize=8 # Integer +hintdist=10800 # Hint distance while using farhint +latency=0 # in Seconds +shutdown_on_rcv="false" +unschedule_on_rcv="true" +farhint="false" +bitrate="100kbps" + + +run-scenarios() { + # Configure number of seed per scenarios + nseed=200 + + # Baseline + avalues="baseline,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rBaseline...${seed}" + run-simulation + done + echo + + # Hint + hint="true" + avalues="hint,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rHint...${seed}" + run-simulation + done + hint="false" + echo + + # Extended + extended="true" + avalues="extended,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rExtended...${seed}" + run-simulation + done + extended="false" + echo + + # Hint+Extended + extended="true" + hint="true" + avalues="hintandextended,$wireless,$wakeupfor" + for seed in $(seq 1 $nseed) + do + printf "\rHint + Extended...${seed}" + run-simulation + done + extended="false" + hint="false" + echo +} + +# Clean previous runs +[ -e "${results}" ] && rm "${results}" + +for wakeupfor in 60 180 +do + + # Lora + echo "----- Run Lora (wakeupfor=$wakeupfor) -----" + wireless="lora" + bitrate="50kbps" + pon=0.4 + prx=0.16 + ptx=0.16 + latency=0 + run-scenarios + + # NbIot + echo "----- Run NbIoT (wakeupfor=$wakeupfor) -----" + wireless="nbiot" + bitrate="200kbps" + pon=0.4 + prx=0.65 + ptx=0.65 + latency=0 + run-scenarios +done