mirror of
https://gitlab.com/manzerbredes/loosely-coupled-dss.git
synced 2025-04-05 11:06:25 +02:00
Cleaning code
This commit is contained in:
parent
00dfd87c85
commit
1124887d0f
6 changed files with 490 additions and 500 deletions
Binary file not shown.
Before Width: | Height: | Size: 244 KiB After Width: | Height: | Size: 244 KiB |
File diff suppressed because it is too large
Load diff
Binary file not shown.
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 151 KiB |
|
@ -4,23 +4,23 @@
|
|||
|baseline |lora | 60| 15.27504| 584.4667|
|
||||
|extended |lora | 60| 101.64624| 637.2433|
|
||||
|hint |lora | 60| 23.81539| 590.4819|
|
||||
|hintandextended |lora | 60| 114.57070| 647.3435|
|
||||
|hintandextended |lora | 60| 114.57174| 647.3442|
|
||||
|
||||
|
||||
|simkey |wireless | wakeupfor| sd| energy|
|
||||
|:---------------|:--------|---------:|---------:|--------:|
|
||||
|baseline |nbiot | 60| 58.67243| 607.8669|
|
||||
|extended |nbiot | 60| 56.56835| 606.4526|
|
||||
|hint |nbiot | 60| 103.98686| 644.1689|
|
||||
|hintandextended |nbiot | 60| 90.73827| 636.3234|
|
||||
|hint |nbiot | 60| 103.98681| 644.1689|
|
||||
|hintandextended |nbiot | 60| 90.73858| 636.3236|
|
||||
|
||||
|
||||
|simkey |wireless | wakeupfor| sd| energy|
|
||||
|:---------------|:--------|---------:|---------:|--------:|
|
||||
|baseline |lora | 180| 93.38861| 1788.865|
|
||||
|extended |lora | 180| 110.07750| 1793.727|
|
||||
|hint |lora | 180| 213.29502| 2056.414|
|
||||
|hintandextended |lora | 180| 162.90229| 1912.699|
|
||||
|hint |lora | 180| 213.29475| 2056.413|
|
||||
|hintandextended |lora | 180| 162.90313| 1912.700|
|
||||
|
||||
|
||||
|simkey |wireless | wakeupfor| sd| energy|
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
|
||||
|simkey |wireless | wakeupfor| sd_success| success| senderEnergy| receiverEnergy| senderUptime| receiverUptime| nSendFail|
|
||||
|:---------------|:--------|---------:|----------:|-------:|------------:|--------------:|------------:|--------------:|---------:|
|
||||
|baseline |lora | 60| 0.000000| 0.0| 627.1360| 580.5876| 1440.000| 1440.000| 0|
|
||||
|extended |lora | 60| 1.523884| 5.1| 935.9200| 610.0909| 2013.400| 1495.555| 0|
|
||||
|hint |lora | 60| 0.000000| 0.0| 635.4400| 586.3948| 1440.000| 1451.391| 0|
|
||||
|hintandextended |lora | 60| 1.505545| 5.4| 988.2212| 616.3547| 2071.081| 1503.998| 0|
|
||||
|baseline |lora | 60| 0.000000| 0.0| 627.136| 580.5876| 1440.000| 1440.000| 0|
|
||||
|extended |lora | 60| 1.523884| 5.1| 935.920| 610.0909| 2013.400| 1495.555| 0|
|
||||
|hint |lora | 60| 0.000000| 0.0| 635.440| 586.3948| 1440.000| 1451.391| 0|
|
||||
|hintandextended |lora | 60| 1.505545| 5.4| 988.225| 616.3550| 2071.087| 1503.999| 0|
|
||||
|
||||
|
||||
|simkey |wireless | wakeupfor| sd_success| success| senderEnergy| receiverEnergy| senderUptime| receiverUptime| nSendFail|
|
||||
|:---------------|:--------|---------:|----------:|-------:|------------:|--------------:|------------:|--------------:|---------:|
|
||||
|baseline |nbiot | 60| 1.418136| 1.3| 773.9900| 592.7648| 1440.000| 1440.000| 0|
|
||||
|extended |nbiot | 60| 1.837873| 5.6| 776.6612| 590.9791| 1480.925| 1444.349| 0|
|
||||
|hint |nbiot | 60| 3.645393| 4.2| 871.7506| 623.4797| 1440.000| 1473.591| 0|
|
||||
|hintandextended |nbiot | 60| 2.299758| 8.2| 900.6119| 612.2971| 1499.986| 1459.351| 0|
|
||||
|hint |nbiot | 60| 3.645393| 4.2| 871.7507| 623.4796| 1440.000| 1473.591| 0|
|
||||
|hintandextended |nbiot | 60| 2.299758| 8.2| 900.6131| 612.2973| 1499.987| 1459.351| 0|
|
||||
|
||||
|
||||
|simkey |wireless | wakeupfor| sd_success| success| senderEnergy| receiverEnergy| senderUptime| receiverUptime| nSendFail|
|
||||
|
@ -20,7 +20,7 @@
|
|||
|baseline |lora | 180| 1.100505| 0.9| 2079.000| 1762.489| 4319.300| 4317.609| 0|
|
||||
|extended |lora | 180| 1.349897| 9.4| 2145.360| 1761.760| 4733.400| 4349.709| 0|
|
||||
|hint |lora | 180| 2.626785| 9.3| 2182.152| 2044.983| 4319.300| 4875.818| 0|
|
||||
|hintandextended |lora | 180| 0.000000| 11.0| 2275.506| 1879.717| 4842.804| 4561.617| 0|
|
||||
|hintandextended |lora | 180| 0.000000| 11.0| 2275.511| 1879.717| 4842.812| 4561.617| 0|
|
||||
|
||||
|
||||
|simkey |wireless | wakeupfor| sd_success| success| senderEnergy| receiverEnergy| senderUptime| receiverUptime| nSendFail|
|
||||
|
@ -28,6 +28,6 @@
|
|||
|baseline |nbiot | 180| 1.595131| 9.1| 2511.166| 1760.766| 4319.300| 4317.609| 0|
|
||||
|extended |nbiot | 180| 1.264911| 9.6| 2393.062| 1750.373| 4331.310| 4319.192| 0|
|
||||
|hint |nbiot | 180| 0.000000| 11.0| 2209.184| 1920.554| 4319.300| 4465.173| 0|
|
||||
|hintandextended |nbiot | 180| 0.000000| 11.0| 2176.211| 1881.577| 4341.277| 4438.185| 0|
|
||||
|hintandextended |nbiot | 180| 0.000000| 11.0| 2176.212| 1881.578| 4341.278| 4438.185| 0|
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#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 FOR(t) (t<uptime?t:uptime)
|
||||
#define TRACK_UPTIME(instruction) \
|
||||
{ \
|
||||
double uptimeTrack=CLOCK; \
|
||||
|
@ -62,13 +63,14 @@ typedef unsigned int u32;
|
|||
*/
|
||||
class Payload{
|
||||
public:
|
||||
Payload():hint(0),duration(0),HasHint(false),HisForward(false),HasData(false){}
|
||||
Payload(Payload &p):hint(p.hint),duration(p.duration),HasHint(p.HasHint),DedicatedMailbox(p.DedicatedMailbox),HisForward(p.HisForward){}
|
||||
Payload():hint(0),duration(0),HasHint(false),HisForward(false),HasData(false),DataSize(0){}
|
||||
Payload(Payload &p):hint(p.hint),duration(p.duration),HasHint(p.HasHint),DedicatedMailbox(p.DedicatedMailbox),HisForward(p.HisForward),HasData(p.HasData),DataSize(p.DataSize){}
|
||||
double hint; // The timestamp that should be used by the receiver
|
||||
double duration; // The duration that should be used by the receiver
|
||||
bool HasHint;
|
||||
bool HasData;
|
||||
bool HisForward;
|
||||
u32 DataSize;
|
||||
std::string DedicatedMailbox; // Dedicated mailbox used by the sender/receiver
|
||||
};
|
||||
|
||||
|
@ -120,7 +122,6 @@ static void obs_node(std::vector<std::string> args) {
|
|||
XBT_INFO("Deploying observation node %s",CNAME);
|
||||
|
||||
// Starting node
|
||||
bool isObserver=false;
|
||||
u32 nWakeUp=0;
|
||||
u32 nDataRcv=0;
|
||||
u32 nSendFail=0;
|
||||
|
@ -128,8 +129,9 @@ static void obs_node(std::vector<std::string> args) {
|
|||
u32 nSend=0;
|
||||
u32 hint_added=0;
|
||||
double totalUptime=0;
|
||||
Payload *hint_forward=NULL;
|
||||
bool init_issender=i.is_sender;
|
||||
Payload *hint_forward=NULL; // Contains the hint to forward
|
||||
bool is_sender=i.is_sender; // This variable might change if all receiver have received the data
|
||||
bool isObserver=false;
|
||||
while(i.ShouldContinue()){
|
||||
// Start by sleeping
|
||||
XBT_INFO("%s is spleeping",CNAME);
|
||||
|
@ -139,82 +141,82 @@ static void obs_node(std::vector<std::string> args) {
|
|||
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();
|
||||
bool forward_mode=false;
|
||||
bool onlyf=false;
|
||||
bool sendhint_mode=false;
|
||||
double uptime=i.GetDuration(); // Store the remaining wake up duration (updated during the node uptime)
|
||||
double upsince=CLOCK; // Store the time at which the node woke up
|
||||
double upuntil=i.GetTS()+i.GetDuration(); // Store the time at which the node should sleep
|
||||
bool forward_mode=false; // Turned on and off every x seconds by the receiver (to switch between forward hint mode and receiving data mode)
|
||||
bool forward_only=false; // When observer receive a hint it switch to forward only up to the next wake up time
|
||||
bool sendhint_mode=false; // Turned on and off every x seconds by the sender (to switch between send hint and send data)
|
||||
while(uptime>0)
|
||||
{
|
||||
if(i.is_sender){
|
||||
double try_for=sendhint_mode ? 0.3 : 1;
|
||||
try_for=try_for>uptime ? uptime : try_for; // Ensure we do not exceed uptime
|
||||
try_for=(i.use_hint && i.HasNext()) ? try_for: uptime; // Ensure we shoud use hint otherwise only send data
|
||||
// Send hint
|
||||
// ---------- SENDER ----------
|
||||
if(is_sender){
|
||||
// Send hint if send hint mode is enable
|
||||
if(i.use_hint && sendhint_mode && i.HasNext()){
|
||||
Payload *p=new Payload();
|
||||
p->DedicatedMailbox="hintmailbox"+selfName;
|
||||
p->DedicatedMailbox="hintmailbox"+selfName; // Use a dedicated mailbox
|
||||
p->HasHint=true;
|
||||
p->duration=i.GetNextDuration();
|
||||
p->hint=i.GetNextTS();
|
||||
p->DataSize=i.hint_size;
|
||||
try {
|
||||
TRACK_UPTIME(m->put(p,0,try_for));
|
||||
TRACK_UPTIME(m->put(p,0,FOR(0.3))); // Init connection with a receiver
|
||||
simgrid::s4u::Mailbox *m_ded= simgrid::s4u::Mailbox::by_name(p->DedicatedMailbox);
|
||||
MODE_TX();
|
||||
SEND(m_ded->put(p,i.hint_size,uptime));
|
||||
SEND(m_ded->put(p,p->DataSize,uptime)); // Send the actual hint
|
||||
XBT_INFO("%s sent a hint successfully",CNAME);
|
||||
}
|
||||
catch(...){}
|
||||
|
||||
}
|
||||
else{ // Send data
|
||||
// Send data if send hint mode is disable
|
||||
else{
|
||||
Payload *p=new Payload();
|
||||
p->DedicatedMailbox="datamailbox"+selfName;
|
||||
p->HasData=true;
|
||||
p->HasHint=false;
|
||||
p->DataSize=i.data_size;
|
||||
// Add hint to the data if possible
|
||||
if(i.use_hint && i.HasNext()){
|
||||
p->HasHint=true;
|
||||
p->duration=i.GetNextDuration();
|
||||
p->hint=i.GetNextTS();
|
||||
p->DataSize+=i.hint_size; // Don't forget!!
|
||||
}
|
||||
// Send the data
|
||||
try {
|
||||
TRACK_UPTIME(m->put(p,0,try_for));
|
||||
TRACK_UPTIME(m->put(p,0,FOR(1)));
|
||||
simgrid::s4u::Mailbox *m_ded= simgrid::s4u::Mailbox::by_name(p->DedicatedMailbox);
|
||||
MODE_TX();
|
||||
if(i.extended){
|
||||
SEND(m_ded->put(p,i.data_size));
|
||||
SEND(m_ded->put(p,p->DataSize));
|
||||
}
|
||||
else{
|
||||
SEND(m_ded->put(p,i.data_size,uptime));
|
||||
SEND(m_ded->put(p,p->DataSize,uptime));
|
||||
}
|
||||
XBT_INFO("%s sent data successfully",CNAME);
|
||||
nSend++;
|
||||
i.is_sender=(nSend<(i.n_nodes-1));
|
||||
isObserver=!i.is_sender;
|
||||
is_sender=(nSend<(i.n_nodes-1)); // Stop sending if all nodes received
|
||||
isObserver=!is_sender; // Switch to observer mode if all nodes received the data
|
||||
}
|
||||
catch(...){}
|
||||
}
|
||||
sendhint_mode=!sendhint_mode; // Switch to send hint mode
|
||||
sendhint_mode=!sendhint_mode; // Switch back and forth between sending hint and data
|
||||
}
|
||||
// ---------- RECEIVER ----------
|
||||
else if(!isObserver){
|
||||
// Here we try to forward hint for 1 sec and try to receive data for 5 secs
|
||||
double try_for=forward_mode ? 0.3 : 1;
|
||||
try_for=try_for>uptime ? uptime : try_for; // Ensure we do not exceed uptime
|
||||
// Forward hint mode
|
||||
if(forward_mode){
|
||||
if(hint_forward!=NULL && CLOCK < hint_forward->hint){
|
||||
FORWARD_HINT(try_for); // Try forward for 5 seconds then switch to received mode
|
||||
FORWARD_HINT(FOR(0.3)); // Try forward for 5 seconds then switch to received mode
|
||||
}
|
||||
}
|
||||
else { // Receiving mode
|
||||
Payload *p; // Received data
|
||||
Payload *hint; // To Save the received hint
|
||||
bool hintReceived=false; // In case of error during data rx this will be use to check if we could use the *hint Payload object
|
||||
try {
|
||||
// Get the instantaneous message
|
||||
do {
|
||||
TRACK_UPTIME(p=m->get<Payload>(try_for));
|
||||
TRACK_UPTIME(p=m->get<Payload>(FOR(1)));
|
||||
if(p->HisForward){
|
||||
if(hint_forward==NULL || (hint_forward !=NULL && p->hint!=hint_forward->hint)){
|
||||
simgrid::s4u::Mailbox *m_ded=simgrid::s4u::Mailbox::by_name(p->DedicatedMailbox);
|
||||
|
@ -236,9 +238,7 @@ static void obs_node(std::vector<std::string> args) {
|
|||
if(p->HasHint && !p->HasData){
|
||||
TRACK_UPTIME(p=m_ded->get<Payload>(uptime));
|
||||
XBT_INFO("%s received a hint successfully",CNAME);
|
||||
hint=new Payload(*p); // Save hint
|
||||
hint_forward=new Payload(*p); // Enable hint forwarding
|
||||
hintReceived=true;
|
||||
if(CLOCK < p->hint){
|
||||
i.AddEvent(p->hint, p->duration);
|
||||
hint_forward=new Payload(*p);
|
||||
|
@ -255,55 +255,45 @@ static void obs_node(std::vector<std::string> args) {
|
|||
XBT_INFO("%s received data successfully",CNAME);
|
||||
if(p->HasHint){
|
||||
XBT_INFO("%s received a hint along with data successfully",CNAME);
|
||||
hint=new Payload(*p); // Save hint
|
||||
hint_forward=new Payload(*p); // Enable hint forwarding
|
||||
hintReceived=true;
|
||||
}
|
||||
nDataRcv++;
|
||||
isObserver=true;
|
||||
i.is_sender=false;
|
||||
is_sender=false;
|
||||
}
|
||||
|
||||
}catch(...){
|
||||
XBT_INFO("%s could not receive any data",CNAME);
|
||||
nRcvFail++;
|
||||
if(hintReceived){
|
||||
i.AddEvent(hint->hint, hint->duration); // Add the hint to the event list
|
||||
hint_added++;
|
||||
}
|
||||
}
|
||||
}
|
||||
forward_mode=!forward_mode; // Toggle mode (go back and forth between receiving and forwarding)
|
||||
}
|
||||
// ---------- OBSERVER ----------
|
||||
else {
|
||||
XBT_INFO("%s is observing his environment...",CNAME);
|
||||
MODE_ON();
|
||||
if(i.use_hint){
|
||||
double try_for=forward_mode ? 1 : 1;
|
||||
try_for=try_for>uptime ? uptime : try_for;
|
||||
if(onlyf)
|
||||
forward_mode=true;
|
||||
if(forward_mode && hint_forward!=NULL && CLOCK < hint_forward->hint){
|
||||
FORWARD_HINT(try_for);
|
||||
if((forward_mode|forward_only) && hint_forward!=NULL && CLOCK < hint_forward->hint){
|
||||
FORWARD_HINT(FOR(1));
|
||||
}
|
||||
else {
|
||||
Payload *p;
|
||||
try {
|
||||
do {
|
||||
TRACK_UPTIME(p=m->get<Payload>(try_for));
|
||||
TRACK_UPTIME(p=m->get<Payload>(FOR(1)));
|
||||
} while(p->HisForward); // Ignore forwarded hint
|
||||
simgrid::s4u::Mailbox *m_ded= simgrid::s4u::Mailbox::by_name(p->DedicatedMailbox);
|
||||
// Start receiving hint from sender
|
||||
onlyf=true;
|
||||
forward_only=true;
|
||||
MODE_RX();
|
||||
if(p->HasHint){
|
||||
TRACK_UPTIME(p=m_ded->get<Payload>(uptime));
|
||||
XBT_INFO("%s received a hint successfully",CNAME);
|
||||
hint_forward=new Payload(*p); // Enable hint forwarding
|
||||
//simgrid::s4u::this_actor::sleep_for(uptime); // Now sleep until the end
|
||||
}
|
||||
else {
|
||||
simgrid::s4u::this_actor::sleep_for(try_for);
|
||||
simgrid::s4u::this_actor::sleep_for(FOR(1));
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
|
@ -325,5 +315,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|hint_added:%d)",CNAME,CNAME,init_issender,nSend,nWakeUp,nDataRcv,nSendFail,nRcvFail,totalUptime,i.seed,hint_added);
|
||||
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)",CNAME,CNAME,i.is_sender,nSend,nWakeUp,nDataRcv,nSendFail,nRcvFail,totalUptime,i.seed,hint_added);
|
||||
}
|
Loading…
Add table
Reference in a new issue