diff options
Diffstat (limited to 'src/simulator.cc')
| -rw-r--r-- | src/simulator.cc | 43 |
1 files changed, 23 insertions, 20 deletions
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 |
