aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2021-05-06 11:57:50 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2021-05-06 11:57:50 +0200
commit5f7bdb8f3cdb6a1e1f9eae7e0fbab34e2d1e5070 (patch)
tree491e1a81f356278f01bc88653b4d20508526e014 /src
parent0ec9b3f334707ad2981d2c48d0f75fd880b2bad4 (diff)
Debugging
Diffstat (limited to 'src')
-rw-r--r--src/inputs.cc3
-rw-r--r--src/inputs.hpp2
-rw-r--r--src/simulator.cc51
3 files changed, 41 insertions, 15 deletions
diff --git a/src/inputs.cc b/src/inputs.cc
index 066dcb0..0cba7b6 100644
--- a/src/inputs.cc
+++ b/src/inputs.cc
@@ -14,8 +14,9 @@ Inputs::Inputs(std::string node_name){
wake_interval=d[node_name.c_str()]["wake_interval"].GetDouble();
startup_delay=d[node_name.c_str()]["startup_delay"].GetDouble();
is_sender=d[node_name.c_str()]["is_sender"].GetBool();
+ use_hint=d[node_name.c_str()]["use_hint"].GetBool();
max_attempts=d[node_name.c_str()]["max_attemps"].GetInt();
-
+ data_size=d[node_name.c_str()]["data_size"].GetInt();
}
void Inputs::GeneratePlatform(std::string p){
diff --git a/src/inputs.hpp b/src/inputs.hpp
index 92b9005..fa8af17 100644
--- a/src/inputs.hpp
+++ b/src/inputs.hpp
@@ -18,5 +18,7 @@ public:
double wake_interval;
double startup_delay;
bool is_sender;
+ bool use_hint;
int max_attempts;
+ int data_size;
}; \ No newline at end of file
diff --git a/src/simulator.cc b/src/simulator.cc
index b1461d5..922cd15 100644
--- a/src/simulator.cc
+++ b/src/simulator.cc
@@ -15,10 +15,12 @@
XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[DAO]");
typedef unsigned int u32;
-typedef struct{
+class Payload{
+ public:
+ Payload():hint(0),containsHint(false){}
double hint;
- bool isHint;
-} Payload;
+ bool containsHint;
+};
/// @brief Observation unit code
static void obs_node(std::vector<std::string> args);
@@ -36,8 +38,8 @@ int main(int argc, char **argv) {
XBT_INFO("Sarting loosely coupled data dissemination experiments");
XBT_INFO("-------------------------------------------------");
- u32 nObsUnit=simgrid::s4u::Engine::get_instance()->get_host_count();
- for(u32 i=0;i<nObsUnit;i++){
+ u32 nON=simgrid::s4u::Engine::get_instance()->get_host_count();
+ for(u32 i=0;i<nON;i++){
std::vector<std::string> args;
std::ostringstream ss;
ss<< "on" <<i;
@@ -60,42 +62,63 @@ static void obs_node(std::vector<std::string> args) {
simgrid::s4u::Mailbox *m = simgrid::s4u::Mailbox::by_name("medium");
XBT_INFO("Deploying observation node %s",selfName.c_str());
+ // Init convenien variables
double wake_interval=i.wake_interval;
double wake_duration=i.wake_duration;
double startup_delay=i.startup_delay;
int max_attempts=i.max_attempts;
bool isSender=i.is_sender;
+ bool useHint=i.use_hint;
+ bool isObserver=false;
+ u32 data_size=i.data_size;
// Starting node
u32 effectiveAttemps=0;
double effective_wake_duration=wake_duration;
double effective_wake_interval=wake_interval;
+ TURN_OFF();
simgrid::s4u::this_actor::sleep_for(startup_delay);
- Payload p;
for(u32 i=0;i<max_attempts;i++){
+
+ // Sleeping
XBT_INFO("%s is spleeping",selfName.c_str());
+ TURN_OFF();
simgrid::s4u::this_actor::sleep_for(effective_wake_interval);
+ effective_wake_interval=wake_interval; // Restore wake interval
+ TURN_ON();
XBT_INFO("%s wakes up",selfName.c_str());
+ // Wake up: try to send/receive
try
{
if(isSender){
- p.isHint=false;
- p.hint=500;
- m->put(&p,0,effective_wake_duration);
+ Payload *p=new Payload();
+ p->containsHint=true;
+ p->hint=5;
+ if(useHint){
+ p->containsHint=i<(max_attempts-1); // Ensure that we will wake up again
+ p->hint=wake_interval;
+ }
+ m->put(p,data_size,effective_wake_duration);
XBT_INFO("%s send data successfully",selfName.c_str());
- effective_wake_interval=wake_interval;
+ isObserver=true; // Do one send for now...
+ isSender=false;
}
- else {
- Payload *p=m->get<Payload>(effective_wake_duration);
- if(p->isHint){
+ else if (!isObserver){
+ Payload* p=m->get<Payload>(effective_wake_duration);
+ if(p->containsHint){
XBT_INFO("%s received and hint of %f",selfName.c_str(),p->hint);
effective_wake_interval=p->hint;
+ i--; // Add new attempt
}
else{
- XBT_INFO("%s received data successfully",selfName.c_str());
+ XBT_INFO("%s received data successfully and switch to forwarding mode",selfName.c_str());
+ isSender=!isSender;
}
}
+ else {
+ XBT_INFO("%s is observing is environment...",selfName.c_str());
+ }
}
catch (...)
{