Extend simulator

This commit is contained in:
Loic Guegan 2021-06-30 15:41:03 +02:00
parent 9ed3712789
commit 4d10786320
8 changed files with 56696 additions and 41623 deletions

56399
results/backup.org Normal file

File diff suppressed because it is too large Load diff

View file

@ -12,12 +12,12 @@ results="${wai}/results.csv"
aheaders="simkey,wireless,wakeupfor" aheaders="simkey,wireless,wakeupfor"
avalues="none,none,none" avalues="none,none,none"
log_file="${wai}/logs/$(date +%s).org" && mkdir -p "${wai}/logs/" log_file="${wai}/logs/$(date +%s).org" && mkdir -p "${wai}/logs/"
gen_log=0 # Should we generate logs ? gen_log=1 # Should we generate logs ?
run-simulation () { run-simulation () {
# Generate inputs # Generate inputs
$scenarios $seed $simtime $wakeupevery $wakeupfor $n_nodes $extended $hint $poff $pon $prx $ptx $datasize $bitrate $hintsize $latency > "$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 # 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}" [ $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}"
@ -51,14 +51,18 @@ prx=0.16
ptx=0.16 ptx=0.16
datasize=1000000 # 1Mb datasize=1000000 # 1Mb
hintsize=8 # Integer hintsize=8 # Integer
hintdist=$wakeupevery # Hint distance while using farhint
latency=0 # in Seconds latency=0 # in Seconds
shutdown_on_rcv="false"
unschedule_on_rcv="false"
farhint="false"
bitrate="100kbps" bitrate="100kbps"
run-scenarios() { run-scenarios() {
# Configure number of seed per scenarios # Configure number of seed per scenarios
nseed=200 nseed=1
# Baseline # Baseline
avalues="baseline,$wireless,$wakeupfor" avalues="baseline,$wireless,$wakeupfor"

File diff suppressed because it is too large Load diff

BIN
scenarios

Binary file not shown.

View file

@ -21,15 +21,21 @@ Inputs::Inputs(std::string node_name){
hint_size=d["hint_size"].GetInt(); hint_size=d["hint_size"].GetInt();
n_nodes=d["nodes"].MemberCount(); n_nodes=d["nodes"].MemberCount();
latency=d["latency"].GetDouble(); latency=d["latency"].GetDouble();
unschedule_on_rcv=d["unschedule_on_rcv"].GetBool();
shutdown_on_rcv=d["shutdown_on_rcv"].GetBool();
farhint=d["farhint"].GetBool();
hintdist=d["hintdist"].GetDouble();
// Instantiate wake_ts // Instantiate wake_ts
for(auto& v:d["nodes"][node_name.c_str()]["wake_ts"].GetArray()){ for(auto& v:d["nodes"][node_name.c_str()]["wake_ts"].GetArray()){
wake_ts.push_back(v.GetDouble()); wake_ts.push_back(v.GetDouble());
wake_ts_backup.push_back(v.GetDouble());
} }
// Instantiate wake_duration // Instantiate wake_duration
for(auto& v:d["nodes"][node_name.c_str()]["wake_duration"].GetArray()){ for(auto& v:d["nodes"][node_name.c_str()]["wake_duration"].GetArray()){
wake_duration.push_back(v.GetDouble()); wake_duration.push_back(v.GetDouble());
wake_duration_backup.push_back(v.GetDouble());
} }
// Identity check // Identity check
@ -89,11 +95,40 @@ double Inputs::GetNextDuration(){
return wake_duration[1]; return wake_duration[1];
} }
double Inputs::GetHintTS(double clock){
if(farhint){
for(int i=0;i<wake_ts.size();i++){
if(wake_ts[i]>=(clock+hintdist))
return(wake_ts[i]);
}
}
return(GetNextTS());
}
double Inputs::GetHintDuration(double clock){
if(farhint){
for(int i=0;i<wake_ts.size();i++){
if(wake_ts[i]>=(clock+hintdist))
return(wake_duration[i]);
}
}
return GetNextDuration();
}
void Inputs::GotoNextEvent(){ void Inputs::GotoNextEvent(){
wake_ts.erase(wake_ts.begin()); wake_ts.erase(wake_ts.begin());
wake_duration.erase(wake_duration.begin()); wake_duration.erase(wake_duration.begin());
} }
void Inputs::ResetEvents(double clock){
wake_ts=wake_ts_backup;
wake_duration=wake_duration_backup;;
// Restore current event
while(HasNext() && (GetTS()+GetNextDuration()) < clock){
GotoNextEvent();
}
}
void Inputs::DumpEvents(){ void Inputs::DumpEvents(){
std::cout << "Timestamps: "; std::cout << "Timestamps: ";
for(auto a:wake_ts){ for(auto a:wake_ts){

View file

@ -21,6 +21,10 @@ class Inputs {
std::vector<double> wake_ts; std::vector<double> wake_ts;
/// @brief Wake up time durations /// @brief Wake up time durations
std::vector<double> wake_duration; std::vector<double> wake_duration;
/// @brief To handle unschedule_on_rcv
std::vector<double> wake_ts_backup;
std::vector<double> wake_duration_backup;
/** /**
* Recursively merge overlapping events * Recursively merge overlapping events
*/ */
@ -46,10 +50,12 @@ public:
* Get current event timestamp * Get current event timestamp
*/ */
double GetTS(){return wake_ts.front();} double GetTS(){return wake_ts.front();}
double GetHintTS(double clock);
/** /**
* Get current event duration * Get current event duration
*/ */
double GetDuration(){return wake_duration.front();} double GetDuration(){return wake_duration.front();}
double GetHintDuration(double clock);
/** /**
* Get next event timestamp * Get next event timestamp
*/ */
@ -63,6 +69,10 @@ public:
* of thermodynamics) * of thermodynamics)
*/ */
void GotoNextEvent(); void GotoNextEvent();
/**
* Reset the initial event list
*/
void ResetEvents(double clock);
/** /**
* Allows to add a *FUTURE* event and merge overlapping events * Allows to add a *FUTURE* event and merge overlapping events
*/ */
@ -76,9 +86,13 @@ public:
bool is_sender; bool is_sender;
bool use_hint; bool use_hint;
bool extended; bool extended;
bool farhint;
bool unschedule_on_rcv;
bool shutdown_on_rcv;
int data_size; int data_size;
int hint_size; int hint_size;
int seed; int seed;
int n_nodes; int n_nodes;
double latency; double latency;
double hintdist;
}; };

View file

@ -17,10 +17,10 @@ using namespace rapidjson;
int main(int argc, char **argv){ int main(int argc, char **argv){
// Setup seed // Setup seed
if(argc!=16){ if(argc!=20){
cerr << "Usage: " << argv[0] << cerr << "Usage: " << argv[0] <<
" <seed> <simtime> <wakeupevery> <wakeupfor> <n_nodes>" << " <seed> <simtime> <wakeupevery> <wakeupfor> <n_nodes>" <<
" <extended> <hint> <poff> <pon> <prx> <ptx> <datasize> <bitrate> <hintsize> <latency>" << " <extended> <hint> <poff> <pon> <prx> <ptx> <datasize> <bitrate> <hintsize> <latency> <shutdown_on_rcv> <unschedule_on_rcv> <farhint>" <<
endl; endl;
exit(1); exit(1);
} }
@ -41,6 +41,10 @@ int main(int argc, char **argv){
string bitrate(argv[13]); string bitrate(argv[13]);
unsigned int hintsize=atoi(argv[14]); unsigned int hintsize=atoi(argv[14]);
double latency=stod(argv[15]); double latency=stod(argv[15]);
bool shutdown_on_rcv=!strcmp("true",argv[16]);
bool unschedule_on_rcv=!strcmp("true",argv[17]);
bool farhint=!strcmp("true",argv[18]);
double hintdist=stod(argv[19]);
// Setup seed // Setup seed
@ -56,6 +60,10 @@ int main(int argc, char **argv){
d.AddMember("latency",latency,d.GetAllocator()); d.AddMember("latency",latency,d.GetAllocator());
d.AddMember("extended",extended,d.GetAllocator()); d.AddMember("extended",extended,d.GetAllocator());
d.AddMember("hint_size",hintsize,d.GetAllocator()); d.AddMember("hint_size",hintsize,d.GetAllocator());
d.AddMember("shutdown_on_rcv",shutdown_on_rcv,d.GetAllocator());
d.AddMember("unschedule_on_rcv",unschedule_on_rcv,d.GetAllocator());
d.AddMember("farhint",farhint,d.GetAllocator());
d.AddMember("hintdist",hintdist,d.GetAllocator());
// Create nodes // Create nodes
Value nodes(kObjectType); Value nodes(kObjectType);

View file

@ -188,8 +188,8 @@ static void obs_node(std::vector<std::string> args) {
// Add hint to the data if possible // Add hint to the data if possible
if(i.use_hint && i.HasNext()){ if(i.use_hint && i.HasNext()){
p->HasHint=true; p->HasHint=true;
p->duration=i.GetNextDuration(); p->duration=i.GetHintDuration(CLOCK);
p->hint=i.GetNextTS(); p->hint=i.GetHintTS(CLOCK);
p->DataSize+=i.hint_size; // Don't forget!! p->DataSize+=i.hint_size; // Don't forget!!
} }
// Send the data // Send the data
@ -283,6 +283,8 @@ static void obs_node(std::vector<std::string> args) {
XBT_INFO("%s received a hint along with data successfully",CNAME); XBT_INFO("%s received a hint along with data successfully",CNAME);
hint_forward=new Payload(*p); // Enable hint forwarding hint_forward=new Payload(*p); // Enable hint forwarding
} }
if(i.shutdown_on_rcv)
upuntil=CLOCK;
nDataRcv++; nDataRcv++;
isObserver=true; isObserver=true;
is_sender=false; is_sender=false;
@ -342,6 +344,9 @@ static void obs_node(std::vector<std::string> args) {
uptime=upuntil-CLOCK; // Note that uptime can be < 0 in extended mode uptime=upuntil-CLOCK; // Note that uptime can be < 0 in extended mode
uptime=uptime > 0 ? uptime : 0; // Just in case uptime=uptime > 0 ? uptime : 0; // Just in case
} }
// Check if we use unschedule_on_rcv
if(i.unschedule_on_rcv)
i.ResetEvents(CLOCK);
// Load next event // Load next event
i.GotoNextEvent(); i.GotoNextEvent();
nWakeUp++; // Increase the number of wake up nWakeUp++; // Increase the number of wake up
@ -349,5 +354,5 @@ static void obs_node(std::vector<std::string> args) {
} }
// Done // Done
MODE_OFF() MODE_OFF()
XBT_INFO("Observation node %s finished [LOG2PARSE](node:%s|isSender:%d|nSend:%d|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d|totalUptime:%f|seed:%d|hint_added:%d|timeDataRcv:%f)",CNAME,CNAME,i.is_sender,nSend,nWakeUp,nDataRcv,nSendFail,nRcvFail,totalUptime,i.seed,hint_added,timeDataRcv); XBT_INFO("Observation node %s finished [LOG2PARSE](node:%s|isSender:%d|nSend:%d|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d|totalUptime:%f|seed:%d|hint_added:%d|timeDataRcv:%f|shutdown_on_rcv:%d|unschedule_on_rcv:%d|farhint:%d|hintdist:%f)",CNAME,CNAME,i.is_sender,nSend,nWakeUp,nDataRcv,nSendFail,nRcvFail,totalUptime,i.seed,hint_added,timeDataRcv,i.shutdown_on_rcv,i.unschedule_on_rcv,i.farhint,i.hintdist);
} }