From 5f7bdb8f3cdb6a1e1f9eae7e0fbab34e2d1e5070 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Thu, 6 May 2021 11:57:50 +0200 Subject: Debugging --- src/simulator.cc | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) (limited to 'src/simulator.cc') 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 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;iget_host_count(); + for(u32 i=0;i args; std::ostringstream ss; ss<< "on" < 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;iput(&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(effective_wake_duration); - if(p->isHint){ + else if (!isObserver){ + Payload* p=m->get(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 (...) { -- cgit v1.2.3