aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2021-05-12 12:07:00 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2021-05-12 12:07:00 +0200
commit9365501740d04d7b8251ef73046f013f5bcf9f76 (patch)
treef494467ce06bcfbe43d41c80086f26a82f2a4536
parent95fc03c7e0bcc12f90d48e3756166df69ade0806 (diff)
Debug/Cleaning
-rw-r--r--results/analysis.R14
-rw-r--r--results/energy.pngbin185318 -> 231638 bytes
-rw-r--r--results/success.pngbin129291 -> 159584 bytes
-rw-r--r--src/simulator.cc43
4 files changed, 31 insertions, 26 deletions
diff --git a/results/analysis.R b/results/analysis.R
index 60ee966..bdc95a4 100644
--- a/results/analysis.R
+++ b/results/analysis.R
@@ -3,6 +3,8 @@ library("knitr")
data=read_csv("results.csv")
+r_=function(x){round(x,digits=2)}
+
finalEnergy=data%>%group_by(simkey,wireless,wakeupfor)%>%summarize(wireless=first(wireless),sd=sd(energy),wakeupfor=first(wakeupfor),energy=mean(energy))
finalStats=data%>%group_by(simkey,wireless,wakeupfor,seed)%>%
summarise(success=sum(nSend))%>%
@@ -32,9 +34,9 @@ ggplot(finalEnergy,aes(x=simkey,y=energy,fill=wireless))+
xlab("Scenarios")+ylab("Energy (J)")+
geom_errorbar(position=position_dodge(0.9),aes(ymin=energy-sd, ymax=energy+sd),width=0.5,size=1.5,) +
facet_wrap(~ wakeupfor) +
- geom_text(aes(label = round(energy+sd), y= energy+sd),vjust=-0.4,position=position_dodge(0.9))+
- geom_text(aes(label = round(energy-sd), y= energy-sd),vjust=+1.5,position=position_dodge(0.9))+
- geom_text(aes(label = round(energy), y= energy/2),fontface="bold",colour="white",position=position_dodge(0.9))
+ geom_text(aes(label = r_(energy+sd), y= energy+sd),vjust=-0.4,position=position_dodge(0.9))+
+ geom_text(aes(label = r_(energy-sd), y= energy-sd),vjust=+1.5,position=position_dodge(0.9))+
+ geom_text(aes(label = r_(energy), y= energy/2),fontface="bold",colour="white",position=position_dodge(0.9))
ggsave("energy.png")
@@ -42,9 +44,9 @@ ggplot(finalStats,aes(x=simkey,y=success,fill=wireless))+
geom_bar(stat="identity",position=position_dodge())+
xlab("Scenarios")+ylab("Energy (J)")+
geom_errorbar(position=position_dodge(0.9),aes(ymin=success-sd_success, ymax=success+sd_success),width=0.5,size=1.5,) +
- geom_text(aes(label = round(success+sd_success,digits=1), y= success+sd_success),vjust=-0.4,position=position_dodge(0.9))+
- geom_text(aes(label = round(success-sd_success,digits=1), y= success-sd_success),vjust=+1.5,position=position_dodge(0.9))+
- geom_text(aes(label = round(success,digits=1), y= success/2),fontface="bold",colour="white",position=position_dodge(0.9))+
+ geom_text(aes(label = r_(success+sd_success), y= success+sd_success),vjust=-0.4,position=position_dodge(0.9))+
+ geom_text(aes(label = r_(success-sd_success), y= success-sd_success),vjust=+1.5,position=position_dodge(0.9))+
+ geom_text(aes(label = r_(success), y= success/2),fontface="bold",colour="white",position=position_dodge(0.9))+
facet_wrap(~ wakeupfor) +
ggsave("success.png")
diff --git a/results/energy.png b/results/energy.png
index 612b75b..487c8aa 100644
--- a/results/energy.png
+++ b/results/energy.png
Binary files differ
diff --git a/results/success.png b/results/success.png
index 4033967..00f4d28 100644
--- a/results/success.png
+++ b/results/success.png
Binary files differ
diff --git a/src/simulator.cc b/src/simulator.cc
index de22a6b..d27de1b 100644
--- a/src/simulator.cc
+++ b/src/simulator.cc
@@ -16,6 +16,7 @@
#define MODE_RX() simgrid::s4u::this_actor::get_host()->set_pstate(2);
#define MODE_TX() simgrid::s4u::this_actor::get_host()->set_pstate(3);
#define CLOCK (simgrid::s4u::Engine::get_clock())
+#define CNAME (selfName.c_str())
#define TRACK_UPTIME(instruction) \
{ \
double uptimeTrack=CLOCK; \
@@ -26,7 +27,7 @@
}
/// @brief Required by SimGrid
-XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[DAO]");
+XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[DAO] Loosely Coupled DSS");
/// @brief For convenience sake
typedef unsigned int u32;
@@ -37,10 +38,11 @@ typedef unsigned int u32;
class Payload{
public:
Payload():hint(0),duration(0),HasHint(false){}
- double hint;
- double duration;
+ Payload(Payload &p):hint(p.hint),duration(p.duration),HasHint(p.HasHint),DedicatedMailbox(p.DedicatedMailbox){}
+ double hint; // The timestamp that should be used by the receiver
+ double duration; // The duration that should be used by the receiver
bool HasHint;
- std::string DedicatedMailbox;
+ std::string DedicatedMailbox; // Dedicated mailbox used by the sender/receiver
};
/// @brief Observation node code
@@ -88,7 +90,7 @@ static void obs_node(std::vector<std::string> args) {
simgrid::s4u::this_actor::get_host()->turn_on();
Inputs i(selfName);
simgrid::s4u::Mailbox *m = simgrid::s4u::Mailbox::by_name("medium");
- XBT_INFO("Deploying observation node %s",selfName.c_str());
+ XBT_INFO("Deploying observation node %s",CNAME);
// Starting node
bool isObserver=false;
@@ -100,24 +102,24 @@ static void obs_node(std::vector<std::string> args) {
double totalUptime=0;
while(i.ShouldContinue()){
// Start by sleeping
- XBT_INFO("%s is spleeping",selfName.c_str());
+ XBT_INFO("%s is spleeping",CNAME);
MODE_OFF();
simgrid::s4u::this_actor::sleep_until(i.GetTS());
MODE_ON();
- XBT_INFO("%s wakes up",selfName.c_str());
+ XBT_INFO("%s wakes up",CNAME);
// Doing wake up stuff
double uptime=i.GetDuration();
double upsince=simgrid::s4u::Engine::get_clock();
double upuntil=i.GetTS()+i.GetDuration();
- while(uptime>0.0000001)
+ while(uptime>0)
{
if(i.is_sender){
Payload *p=new Payload();
p->DedicatedMailbox="dedicated"+selfName;
// Add hint informations to the payload
if(i.use_hint && i.HasNext()){
- p->HasHint=i.use_hint;
+ p->HasHint=true;
p->duration=i.GetNextDuration();
p->hint=i.GetNextTS();
}
@@ -133,7 +135,7 @@ static void obs_node(std::vector<std::string> args) {
MODE_TX();
if(p->HasHint){
TRACK_UPTIME(m_ded->put(p,i.hint_size,uptime));
- XBT_INFO("%s sent a hint successfully",selfName.c_str());
+ XBT_INFO("%s sent a hint successfully",CNAME);
}
// Then try sending the data
if(i.extended)
@@ -141,20 +143,20 @@ static void obs_node(std::vector<std::string> args) {
else
m_ded->put(p,i.data_size,uptime);
// If we reach here, data has been sent successfully
- XBT_INFO("%s sent data successfully",selfName.c_str());
+ XBT_INFO("%s sent data successfully",CNAME);
nSend++;
i.is_sender=(nSend<(i.n_nodes-1));
isObserver=!i.is_sender;
}
catch(...){
- XBT_INFO("%s could not send any data",selfName.c_str());
+ XBT_INFO("%s could not send any data",CNAME);
nSendFail++;
}
}
else if(!isObserver){
- Payload *p;
+ Payload *p; // Received data
Payload *hint; // To Save the received hint
- bool hintReceived=false;
+ bool hintReceived=false; // In case of error during data rx this will be use to check if we could use the *hint Payload object
MODE_ON();
try {
// Get the instantaneous message
@@ -164,7 +166,8 @@ static void obs_node(std::vector<std::string> args) {
MODE_RX();
if(p->HasHint){
TRACK_UPTIME(p=m_ded->get<Payload>(uptime));
- XBT_INFO("%s received a hint successfully",selfName.c_str());
+ XBT_INFO("%s received a hint successfully",CNAME);
+ hint=new Payload(*p); // Save hint
hintReceived=true;
}
if(i.extended)
@@ -172,20 +175,20 @@ static void obs_node(std::vector<std::string> args) {
else
p=m_ded->get<Payload>(uptime); // Fetch data until sended or uptime expire
// If we reach here, data has been received successfully
- XBT_INFO("%s received data successfully",selfName.c_str());
+ XBT_INFO("%s received data successfully",CNAME);
nDataRcv++;
isObserver=true;
i.is_sender=false;
}catch(...){
- XBT_INFO("%s could not receive any data",selfName.c_str());
+ XBT_INFO("%s could not receive any data",CNAME);
nRcvFail++;
if(hintReceived)
- i.AddEvent(p->hint, p->duration); // Add the hint to the event list
+ i.AddEvent(hint->hint, hint->duration); // Add the hint to the event list
}
}
else {
- XBT_INFO("%s is observing his environment...",selfName.c_str());
+ XBT_INFO("%s is observing his environment...",CNAME);
MODE_ON();
simgrid::s4u::this_actor::sleep_for(uptime);
}
@@ -198,5 +201,5 @@ static void obs_node(std::vector<std::string> args) {
}
// Done
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)",selfName.c_str(),selfName.c_str(),i.is_sender,nSend,nWakeUp,nDataRcv,nSendFail,nRcvFail,totalUptime,i.seed);
+ 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)",CNAME,CNAME,i.is_sender,nSend,nWakeUp,nDataRcv,nSendFail,nRcvFail,totalUptime,i.seed);
} \ No newline at end of file