diff --git a/.gitignore b/.gitignore index c96c007..952519a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ libs/rapidjson compile_commands.json platform.xml scenarios +inputs.json diff --git a/inputs.json b/inputs.json deleted file mode 100644 index 757cea0..0000000 --- a/inputs.json +++ /dev/null @@ -1 +0,0 @@ -{"extended":false,"nodes":{"on0":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":true,"data_size":50,"wake_ts":[8.0,18.0,28.0,38.0,48.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0]},"on1":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[5.0,15.0,25.0,35.0,45.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0]},"on2":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[0.0,10.0,20.0,30.0,40.0,50.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on3":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[1.0,11.0,21.0,31.0,41.0,51.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on4":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[2.0,12.0,22.0,32.0,42.0,52.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on5":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[4.0,14.0,24.0,34.0,44.0,54.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on6":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[0.0,10.0,20.0,30.0,40.0,50.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on7":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[0.0,10.0,20.0,30.0,40.0,50.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on8":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[3.0,13.0,23.0,33.0,43.0,53.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on9":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[4.0,14.0,24.0,34.0,44.0,54.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]}}} \ No newline at end of file diff --git a/results/paper.sh b/results/paper.sh new file mode 100755 index 0000000..e039283 --- /dev/null +++ b/results/paper.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +set -e + +wai=$(dirname $(readlink -f "$0")) +scenarios="${wai}/../scenarios" +inputs="${wai}/../inputs.json" +simulator="make -C ${wai}/../ run" +parser="${wai}/../parser.awk" +results="${wai}/results.csv" +nseed=10 + +run-simulation () { + # Generate inputs + $scenarios $seed $simtime $maxstartupdelay $wakeupevery $wakeupfor $n_nodes $extended $hint $poff $pon $prx $ptx $datasize $simkey > "$inputs" + # Run simulations + [ -e "$results" ] && { $simulator 2>&1 | $parser | sed 1d >> "$results"; } || { $simulator 2>&1 | $parser > "$results"; } +} + +# Default Parameters +seed=0 +simtime=100 +maxstartupdelay=1 +wakeupevery=10 +wakeupfor=10 +n_nodes=1 +extended="false" +hint="false" +poff=0 +pon=1 +prx=1 +ptx=5 +datasize=1 +simkey=0 + +# Baseline +echo "Baseline..." +[ -e "${results}" ] && rm "${results}" +simkey="baseline" +for seed in $(seq 1 $nseed) +do + run-simulation +done + +# Hint +echo "Hint..." +hint="true" +simkey="hint" +for seed in $(seq 1 $nseed) +do + run-simulation +done +hint="false" + +# Extended +echo "Extended..." +extended="true" +simkey="extended" +for seed in $(seq 1 $nseed) +do + run-simulation +done +extended="false" + +# Hint+Extended +echo "Hint + Extended..." +extended="true" +hint="true" +simkey="hintandextended" +for seed in $(seq 1 $nseed) +do + run-simulation +done +extended="false" +hint="false" diff --git a/results/results.csv b/results/results.csv new file mode 100644 index 0000000..03eed33 --- /dev/null +++ b/results/results.csv @@ -0,0 +1,41 @@ +node,nWakeUp,nDataRcv,nSendFail,nRcvFail,simkey,seed,energy +on0,1,0,1,0,baseline,1,450.000000 +on0,1,0,1,0,baseline,2,450.000000 +on0,1,0,1,0,baseline,3,450.000000 +on0,1,0,1,0,baseline,4,450.000000 +on0,1,0,1,0,baseline,5,450.000000 +on0,1,0,1,0,baseline,6,450.000000 +on0,1,0,1,0,baseline,7,450.000000 +on0,1,0,1,0,baseline,8,450.000000 +on0,1,0,1,0,baseline,9,450.000000 +on0,1,0,1,0,baseline,10,450.000000 +on0,1,0,1,0,hint,1,450.000000 +on0,1,0,1,0,hint,2,450.000000 +on0,1,0,1,0,hint,3,450.000000 +on0,1,0,1,0,hint,4,450.000000 +on0,1,0,1,0,hint,5,450.000000 +on0,1,0,1,0,hint,6,450.000000 +on0,1,0,1,0,hint,7,450.000000 +on0,1,0,1,0,hint,8,450.000000 +on0,1,0,1,0,hint,9,450.000000 +on0,1,0,1,0,hint,10,450.000000 +on0,1,0,1,0,extended,1,90.000000 +on0,1,0,1,0,extended,2,90.000000 +on0,1,0,1,0,extended,3,90.000000 +on0,1,0,1,0,extended,4,90.000000 +on0,1,0,1,0,extended,5,90.000000 +on0,1,0,1,0,extended,6,90.000000 +on0,1,0,1,0,extended,7,90.000000 +on0,1,0,1,0,extended,8,90.000000 +on0,1,0,1,0,extended,9,90.000000 +on0,1,0,1,0,extended,10,90.000000 +on0,1,0,1,0,hintandextended,1,90.000000 +on0,1,0,1,0,hintandextended,2,90.000000 +on0,1,0,1,0,hintandextended,3,90.000000 +on0,1,0,1,0,hintandextended,4,90.000000 +on0,1,0,1,0,hintandextended,5,90.000000 +on0,1,0,1,0,hintandextended,6,90.000000 +on0,1,0,1,0,hintandextended,7,90.000000 +on0,1,0,1,0,hintandextended,8,90.000000 +on0,1,0,1,0,hintandextended,9,90.000000 +on0,1,0,1,0,hintandextended,10,90.000000 diff --git a/src/Inputs.cc b/src/Inputs.cc index 70f3d51..4eeff77 100644 --- a/src/Inputs.cc +++ b/src/Inputs.cc @@ -17,7 +17,9 @@ Inputs::Inputs(std::string node_name){ use_hint=d["nodes"][node_name.c_str()]["use_hint"].GetBool(); data_size=d["nodes"][node_name.c_str()]["data_size"].GetInt(); extended=d["extended"].GetBool(); - + simkey=d["simkey"].GetString(); + seed=d["seed"].GetInt(); + // Instantiate wake_ts for(auto& v:d["nodes"][node_name.c_str()]["wake_ts"].GetArray()){ wake_ts.push_back(v.GetDouble()); @@ -29,6 +31,10 @@ Inputs::Inputs(std::string node_name){ } // Identity check + if(wake_ts.size()<1){ + std::cerr << "Invalid node configuration: wake_ts.size() == 0" < +#include #include #include -#include +#include #include #include @@ -8,56 +10,68 @@ #include -#define RAND(min,max) (rand()%(max-min)+min) +#define RAND(min,max) (rand()%(max-min+1)+min) using namespace std; using namespace rapidjson; -#define N_NODE 10 -#define EXTENDED false -#define SIMULATION_DURATION 60 -#define POWER_OFF 0 -#define POWER_ON 10 -#define POWER_RX 11 -#define POWER_TX 12 -#define DATA_SIZE 50 -#define USE_HINT false -#define WAKE_UP_EVERY 10 -#define WAKE_UP_FOR 5 -#define MAX_STARTUP_DELAY 10 - -unsigned int seed = 0; - int main(int argc, char **argv){ // Setup seed - if(argc>1){ - srand( atoi(argv[1]) ); + if(argc!=15){ + cerr << "Usage: " << argv[0] << + " " << + " " << + endl; + exit(1); } + // Init parameters + int seed=atoi(argv[1]); + double simtime=stod(argv[2]); + unsigned int maxstartupdelay=atoi(argv[3]); + double wakeupevery=stod(argv[4]); + double wakeupfor=stod(argv[5]); + unsigned int n_nodes=atoi(argv[6]); + bool extended=!strcmp("true",argv[7]); + bool hint=!strcmp("true",argv[8]); + double poff=stod(argv[9]); + double pon=stod(argv[10]); + double prx=stod(argv[11]); + double ptx=stod(argv[12]); + unsigned int datasize=atoi(argv[13]); + string simkey(argv[14]); + + // Setup seed + srand(seed); + // Create document Document d; d.SetObject(); - d.AddMember("extended",EXTENDED,d.GetAllocator()); + Value simkeyValue; + simkeyValue.SetString(simkey.c_str(),simkey.size(),d.GetAllocator()); + d.AddMember("simkey",simkeyValue,d.GetAllocator()); + d.AddMember("seed",Value().SetInt(seed),d.GetAllocator()); + d.AddMember("extended",extended,d.GetAllocator()); // Create nodes Value nodes(kObjectType); - for(int i=0;i writer(buffer); + PrettyWriter writer(buffer); d.Accept(writer); cout << buffer.GetString(); diff --git a/src/simulator.cc b/src/simulator.cc index 13bc711..b34a95b 100644 --- a/src/simulator.cc +++ b/src/simulator.cc @@ -174,5 +174,5 @@ static void obs_node(std::vector args) { } // Done MODE_OFF() - XBT_INFO("Observation node %s finished [LOG2PARSE](node:%s|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d)",selfName.c_str(),selfName.c_str(),nWakeUp,nDataRcv,nSendFail,nRcvFail); + XBT_INFO("Observation node %s finished [LOG2PARSE](node:%s|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d|simkey:%s|seed:%d)",selfName.c_str(),selfName.c_str(),nWakeUp,nDataRcv,nSendFail,nRcvFail,i.simkey.c_str(),i.seed); } \ No newline at end of file