Setup experimentations

This commit is contained in:
Loic Guegan 2021-05-08 17:10:06 +02:00
parent 8b7b9c9e0a
commit f9ce6e80c6
8 changed files with 171 additions and 33 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ libs/rapidjson
compile_commands.json
platform.xml
scenarios
inputs.json

View file

@ -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]}}}

75
results/paper.sh Executable file
View file

@ -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"

41
results/results.csv Normal file
View file

@ -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
1 node nWakeUp nDataRcv nSendFail nRcvFail simkey seed energy
2 on0 1 0 1 0 baseline 1 450.000000
3 on0 1 0 1 0 baseline 2 450.000000
4 on0 1 0 1 0 baseline 3 450.000000
5 on0 1 0 1 0 baseline 4 450.000000
6 on0 1 0 1 0 baseline 5 450.000000
7 on0 1 0 1 0 baseline 6 450.000000
8 on0 1 0 1 0 baseline 7 450.000000
9 on0 1 0 1 0 baseline 8 450.000000
10 on0 1 0 1 0 baseline 9 450.000000
11 on0 1 0 1 0 baseline 10 450.000000
12 on0 1 0 1 0 hint 1 450.000000
13 on0 1 0 1 0 hint 2 450.000000
14 on0 1 0 1 0 hint 3 450.000000
15 on0 1 0 1 0 hint 4 450.000000
16 on0 1 0 1 0 hint 5 450.000000
17 on0 1 0 1 0 hint 6 450.000000
18 on0 1 0 1 0 hint 7 450.000000
19 on0 1 0 1 0 hint 8 450.000000
20 on0 1 0 1 0 hint 9 450.000000
21 on0 1 0 1 0 hint 10 450.000000
22 on0 1 0 1 0 extended 1 90.000000
23 on0 1 0 1 0 extended 2 90.000000
24 on0 1 0 1 0 extended 3 90.000000
25 on0 1 0 1 0 extended 4 90.000000
26 on0 1 0 1 0 extended 5 90.000000
27 on0 1 0 1 0 extended 6 90.000000
28 on0 1 0 1 0 extended 7 90.000000
29 on0 1 0 1 0 extended 8 90.000000
30 on0 1 0 1 0 extended 9 90.000000
31 on0 1 0 1 0 extended 10 90.000000
32 on0 1 0 1 0 hintandextended 1 90.000000
33 on0 1 0 1 0 hintandextended 2 90.000000
34 on0 1 0 1 0 hintandextended 3 90.000000
35 on0 1 0 1 0 hintandextended 4 90.000000
36 on0 1 0 1 0 hintandextended 5 90.000000
37 on0 1 0 1 0 hintandextended 6 90.000000
38 on0 1 0 1 0 hintandextended 7 90.000000
39 on0 1 0 1 0 hintandextended 8 90.000000
40 on0 1 0 1 0 hintandextended 9 90.000000
41 on0 1 0 1 0 hintandextended 10 90.000000

View file

@ -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" <<std::endl;
exit(1);
}
if(wake_ts.size()!=wake_duration.size()){
std::cerr << "Invalid node configuration: wake_ts.size() != wake_duration.size()" <<std::endl;
exit(1);

View file

@ -77,5 +77,7 @@ public:
bool use_hint;
bool extended;
int data_size;
int seed;
std::string simkey;
};

View file

@ -1,6 +1,8 @@
#include <cstdlib>
#include <cstring>
#include <rapidjson/document.h>
#include <rapidjson/filewritestream.h>
#include <rapidjson/writer.h>
#include <rapidjson/prettywriter.h>
#include <cstdio>
#include <iostream>
@ -8,56 +10,68 @@
#include <sstream>
#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] <<
" <seed> <simtime> <maxstartupdelay> <wakeupevery> <wakeupfor> <n_nodes>" <<
" <extended> <hint> <poff> <pon> <prx> <ptx> <datasize> <simkey>" <<
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<N_NODE;i++){
for(int i=0;i<n_nodes;i++){
Value node(kObjectType);
node.SetObject();
node.AddMember("use_hint",USE_HINT,d.GetAllocator());
node.AddMember("power_off",POWER_OFF,d.GetAllocator());
node.AddMember("power_on",POWER_ON,d.GetAllocator());
node.AddMember("power_rx",POWER_RX,d.GetAllocator());
node.AddMember("power_tx",POWER_TX,d.GetAllocator());
node.AddMember("use_hint",hint,d.GetAllocator());
node.AddMember("power_off",poff,d.GetAllocator());
node.AddMember("power_on",pon,d.GetAllocator());
node.AddMember("power_rx",prx,d.GetAllocator());
node.AddMember("power_tx",ptx,d.GetAllocator());
node.AddMember("is_sender",i==0,d.GetAllocator());
node.AddMember("data_size",DATA_SIZE,d.GetAllocator());
node.AddMember("data_size",datasize,d.GetAllocator());
// Setup ts and durations
Value ts(kArrayType);
Value duration(kArrayType);
for(unsigned int i=(RAND(0,MAX_STARTUP_DELAY));(i+WAKE_UP_FOR)<SIMULATION_DURATION;i+=WAKE_UP_EVERY){
for(unsigned int i=maxstartupdelay;(i+wakeupfor)<simtime;i+=wakeupevery){
ts.PushBack(Value().SetDouble(i),d.GetAllocator());
duration.PushBack(Value().SetDouble(WAKE_UP_FOR),d.GetAllocator());
duration.PushBack(Value().SetDouble(wakeupfor),d.GetAllocator());
}
node.AddMember("wake_ts",ts,d.GetAllocator());
node.AddMember("wake_duration",duration,d.GetAllocator());
@ -74,7 +88,7 @@ int main(int argc, char **argv){
// Write to stdout
StringBuffer buffer;
Writer<StringBuffer> writer(buffer);
PrettyWriter<StringBuffer> writer(buffer);
d.Accept(writer);
cout << buffer.GetString();

View file

@ -174,5 +174,5 @@ static void obs_node(std::vector<std::string> 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);
}