Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
968eb041a2ea0945f078770be11ad5e0f283f46f
[simgrid.git] / teshsuite / s4u / comm-fault-scenarios / comm-fault-scenarios.cpp
1 /* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 /* This example shows how to simulate a non-linear resource sharing for
7  * network links.
8  */
9
10 #include <algorithm>
11 #include <random>
12 #include <simgrid/kernel/ProfileBuilder.hpp>
13 #include <simgrid/s4u.hpp>
14 #include <sstream>
15 #include <time.h>
16 #include <vector>
17
18
19 //#include "../../src/kernel/activity/ActivityImpl.hpp"
20
21 namespace sg4 = simgrid::s4u;
22 namespace pr  = simgrid::kernel::profile;
23
24 XBT_LOG_NEW_DEFAULT_CATEGORY(comm_fault_scenarios, "Messages specific for this s4u example");
25
26 /*************************************************************************************************/
27
28 // Constants for platform configuration
29
30 constexpr double HostComputePower = 1e9;  // FLOPs
31 constexpr double LinkBandwidth    = 1e9;  // Bytes/second
32 constexpr double LinkLatency      = 1e-6; // Seconds
33
34 // Constants for application behaviour
35
36 constexpr uint64_t MsgSize = LinkBandwidth / 2;
37
38 /*************************************************************************************************/
39
40 enum class CommType {
41   EAGER_SYNC,
42   EAGER_ASYNC,
43   EAGER_INIT,
44   RDV_SYNC,
45   RDV_ASYNC,
46   RDV_INIT,
47   ONESIDE_SYNC,
48   ONESIDE_ASYNC,
49   ONESIDE_INIT
50 };
51
52 enum class Action { SLEEP, PUT, GET, START, WAIT, DIE, END };
53
54 static const char* to_string(const Action x)
55 {
56
57   switch (x) {
58     case Action::END:
59       return "Success";
60     case Action::SLEEP:
61       return "Sleep";
62     case Action::PUT:
63       return "Put";
64     case Action::GET:
65       return "Get";
66     case Action::START:
67       return "Start";
68     case Action::WAIT:
69       return "Wait";
70     case Action::DIE:
71       return "Die!";
72   };
73   return "";
74 }
75
76 struct Step {
77   double rel_time; // Time relative to Scenario startTime
78   enum { STATE, ACTION } type;
79   enum { LNK, SND, RCV } entity;
80   Action action_type;
81   bool new_state;
82 };
83
84 struct Scenario {
85   CommType type;
86   double start_time;
87   double duration;
88   Action snd_expected;
89   Action rcv_expected;
90   std::vector<Step> steps;
91   int index;
92 };
93
94 static std::string to_string(const Scenario& s)
95 {
96
97   std::stringstream ss;
98   ss <<"#"<< s.index << "[" << s.start_time << "s," << s.start_time + s.duration << "s[: (";
99   switch (s.type) {
100     case CommType::EAGER_SYNC:
101       ss << "EAGER_SYNC";
102       break;
103     case CommType::EAGER_ASYNC:
104       ss << "EAGER_ASYNC";
105       break;
106     case CommType::EAGER_INIT:
107       ss << "EAGER_INIT";
108       break;
109     case CommType::RDV_SYNC:
110       ss << "RDV_SYNC";
111       break;
112     case CommType::RDV_ASYNC:
113       ss << "RDV_ASYNC";
114       break;
115     case CommType::RDV_INIT:
116       ss << "RDV_INIT";
117       break;
118     case CommType::ONESIDE_SYNC:
119       ss << "ONESIDE_SYNC";
120       break;
121     case CommType::ONESIDE_ASYNC:
122       ss << "ONESIDE_ASYNC";
123       break;
124     case CommType::ONESIDE_INIT:
125       ss << "ONESIDE_INIT";
126       break;
127   }
128   ss << ") Expected: S:" << to_string(s.snd_expected) << " R:" << to_string(s.rcv_expected) << " Steps: ";
129   for (const Step& step : s.steps) {
130     ss << "+" << step.rel_time << "s:";
131     switch (step.entity) {
132       case Step::LNK:
133         ss << "LNK";
134         break;
135       case Step::SND:
136         ss << "SND";
137         break;
138       case Step::RCV:
139         ss << "RCV";
140         break;
141     }
142
143     if (step.type == Step::STATE) {
144       ss << "->";
145       if (step.new_state)
146         ss << "ON";
147       else
148         ss << "OFF";
149     } else {
150       ss << "." << to_string(step.action_type);
151     }
152     ss << " ";
153   }
154
155   return ss.str().c_str();
156 }
157
158 std::vector<Scenario> scenarios;
159
160 sg4::Mailbox* mbox_eager = nullptr;
161 sg4::Mailbox* mbox_rdv   = nullptr;
162
163 class SendAgent {
164
165   static int run;
166   static size_t scenario;
167
168   int id;
169   sg4::Host* other_host;
170
171   sg4::CommPtr do_put(CommType type, double& send_value)
172   {
173     switch (type) {
174       case CommType::EAGER_SYNC:
175         mbox_eager->put(&send_value, MsgSize);
176         return nullptr;
177       case CommType::EAGER_ASYNC:
178         return mbox_eager->put_async(&send_value, MsgSize);
179       case CommType::EAGER_INIT:
180         return mbox_eager->put_init(&send_value, MsgSize);
181       case CommType::RDV_SYNC:
182         mbox_rdv->put(&send_value, MsgSize);
183         return nullptr;
184       case CommType::RDV_ASYNC:
185         return mbox_rdv->put_async(&send_value, MsgSize);
186       case CommType::RDV_INIT:
187         return mbox_rdv->put_init(&send_value, MsgSize);
188       case CommType::ONESIDE_SYNC:
189         sg4::Comm::sendto(sg4::this_actor::get_host(), other_host, MsgSize);
190         return nullptr;
191       case CommType::ONESIDE_ASYNC:
192         return sg4::Comm::sendto_async(sg4::this_actor::get_host(), other_host, MsgSize);
193       case CommType::ONESIDE_INIT:
194         return sg4::Comm::sendto_init()->set_payload_size(MsgSize);
195         // FIXME: how to set hosts? sg4::this_actor::get_host(),other_host
196     }
197     return nullptr;
198   }
199
200   void send_message(const Scenario& s)
201   {
202     double send_value;
203     sg4::CommPtr comm = nullptr;
204     // CommType type=s.type;
205     Action expected = s.snd_expected;
206     double end_time = s.start_time + s.duration;
207     // double curr_rel_time=0;
208     send_value        = end_time;
209     size_t step_index = 0;
210
211     sg4::this_actor::sleep_until(s.start_time);
212     for (; step_index < s.steps.size(); step_index++) {
213       const Step& step = s.steps[step_index];
214       if (step.entity != Step::SND || step.type != Step::ACTION)
215         continue;
216
217       try {
218         sg4::this_actor::sleep_until(s.start_time + step.rel_time);
219       } catch (std::exception& e) {
220         XBT_DEBUG("During Sleep, failed to send message because of a %s exception (%s)", typeid(e).name(), e.what());
221         break;
222       }
223
224       // Check if the other host is still OK.
225       if (not other_host->is_on())
226         break;
227
228       // Perform the action
229       try {
230         switch (step.action_type) {
231           case Action::PUT:
232             comm=do_put(s.type, send_value);
233             break;
234           case Action::START:
235             comm->start();
236             break;
237           case Action::WAIT:
238             comm->wait();
239             break;
240           default:
241             xbt_die("Not a valid action for SND");
242         }
243       } catch (std::exception& e) {
244         XBT_DEBUG("During %s, failed to send message because of a %s exception (%s)", to_string(step.action_type),
245                   typeid(e).name(), e.what());
246         break;
247       }
248
249       //xbt_assert(comm->get_impl()->get_refcount()==1);
250     }
251
252     try {
253       sg4::this_actor::sleep_until(end_time);
254     } catch (std::exception& e) {
255       XBT_DEBUG("During Sleep, failed to send message because of a %s exception (%s)", typeid(e).name(), e.what());
256     }
257
258     Action outcome              = Action::END;
259     std::string scenario_string = to_string(s);
260     if (step_index < s.steps.size()) {
261       const Step& step = s.steps[step_index];
262       assert(step.entity == Step::SND && step.type == Step::ACTION);
263       outcome = step.action_type;
264     }
265
266     if (outcome != expected) {
267       XBT_ERROR("Expected %s but got %s in %s", to_string(expected), to_string(outcome), scenario_string.c_str());
268     } else {
269       XBT_INFO("OK: %s", scenario_string.c_str());
270     }
271     sg4::this_actor::sleep_until(end_time);
272
273     xbt_assert(not mbox_eager->listen(), "Mailbox should not have ongoing communication!");
274     xbt_assert(not mbox_rdv->listen(), "Mailbox should not have ongoing communication!");
275
276   }
277
278 public:
279   explicit SendAgent(int id, sg4::Host* other_host) : id(id), other_host(other_host) {}
280
281   void operator()()
282   {
283     run++;
284     XBT_DEBUG("Host %i starts run %i and scenario %lu.", id, run, scenario);
285     while (scenario < scenarios.size()) {
286       Scenario& s = scenarios[scenario];
287       scenario++;
288       send_message(s);
289     }
290   }
291 };
292
293 int SendAgent::run         = 0;
294 size_t SendAgent::scenario = 0;
295
296 /*************************************************************************************************/
297
298 class ReceiveAgent {
299
300   static int run;
301   static size_t scenario;
302
303   int id;
304   sg4::Host* other_host;
305
306   sg4::CommPtr do_get(CommType type, double*& receive_ptr)
307   {
308     switch (type) {
309       case CommType::EAGER_SYNC:
310         receive_ptr = mbox_eager->get<double>();
311         return nullptr;
312       case CommType::EAGER_ASYNC:
313         return mbox_eager->get_async(&receive_ptr);
314       case CommType::EAGER_INIT:
315         return mbox_eager->get_init()->set_dst_data((void**)(&receive_ptr));
316
317       case CommType::RDV_SYNC:
318         receive_ptr = mbox_rdv->get<double>();
319         return nullptr;
320       case CommType::RDV_ASYNC:
321         return mbox_rdv->get_async(&receive_ptr);
322       case CommType::RDV_INIT:
323         return mbox_rdv->get_init()->set_dst_data((void**)(&receive_ptr));
324
325       case CommType::ONESIDE_SYNC:
326       case CommType::ONESIDE_ASYNC:
327       case CommType::ONESIDE_INIT:
328         xbt_die("No get in One Sided comunications!");
329     }
330     return nullptr;
331   }
332
333   void receive_message(const Scenario& s)
334   {
335     sg4::CommPtr comm = nullptr;
336     CommType type     = s.type;
337     Action expected   = s.rcv_expected;
338     double end_time   = s.start_time + s.duration;
339     // double curr_rel_time=0;
340     double* receive_ptr = nullptr;
341     size_t step_index   = 0;
342     sg4::this_actor::sleep_until(s.start_time);
343     for (; step_index < s.steps.size(); step_index++) {
344       const Step& step = s.steps[step_index];
345       if (step.entity != Step::RCV || step.type != Step::ACTION)
346         continue;
347
348       try {
349         sg4::this_actor::sleep_until(s.start_time + step.rel_time);
350       } catch (std::exception& e) {
351         XBT_DEBUG("During Sleep, failed to receive message because of a %s exception (%s)", typeid(e).name(), e.what());
352         break;
353       }
354
355       // Check if the other host is still OK.
356       if (not other_host->is_on())
357         break;
358
359       // Perform the action
360       try {
361         switch (step.action_type) {
362           case Action::GET:
363             comm = do_get(type, receive_ptr);
364             break;
365           case Action::START:
366             comm->start();
367             break;
368           case Action::WAIT:
369             comm->wait();
370             break;
371           default:
372             xbt_die("Not a valid action for RCV");
373         }
374       } catch (std::exception& e) {
375         XBT_DEBUG("During %s, failed to receive message because of a %s exception (%s)", to_string(step.action_type),
376                   typeid(e).name(), e.what());
377         break;
378       }
379     }
380
381     try {
382       sg4::this_actor::sleep_until(end_time - .1);
383     } catch (std::exception& e) {
384       XBT_DEBUG("During Sleep, failed to send message because of a %s exception (%s)", typeid(e).name(), e.what());
385     }
386
387     Action outcome              = Action::END;
388     std::string scenario_string = to_string(s);
389     if (step_index < s.steps.size()) {
390       const Step& step = s.steps[step_index];
391       assert(step.entity == Step::RCV && step.type == Step::ACTION);
392       outcome = step.action_type;
393     } else if (receive_ptr == nullptr) {
394       XBT_ERROR("Received address is NULL in %s", scenario_string.c_str());
395     } else if (*receive_ptr != end_time) {
396       XBT_ERROR("Received value invalid: expected %f but got %f in %s", end_time, *receive_ptr,
397                 scenario_string.c_str());
398     }
399
400     if (outcome != expected) {
401       XBT_ERROR("Expected %s but got %s in %s", to_string(expected), to_string(outcome), scenario_string.c_str());
402     } else {
403       XBT_INFO("OK: %s", scenario_string.c_str());
404     }
405     sg4::this_actor::sleep_until(end_time);
406
407     xbt_assert(not mbox_eager->listen(), "Mailbox should not have ongoing communication!");
408     xbt_assert(not mbox_rdv->listen(), "Mailbox should not have ongoing communication!");
409
410   }
411
412 public:
413   explicit ReceiveAgent(int id, sg4::Host* other_host) : id(id), other_host(other_host) {}
414
415   void operator()()
416   {
417     run++;
418     XBT_DEBUG("Host %i starts run %i and scenario %lu.", id, run, scenario);
419     mbox_eager->set_receiver(sg4::Actor::self());
420     while (scenario < scenarios.size()) {
421       Scenario& s = scenarios[scenario];
422       scenario++;
423       receive_message(s);
424     }
425   }
426 };
427
428 int ReceiveAgent::run         = 0;
429 size_t ReceiveAgent::scenario = 0;
430
431 /*************************************************************************************************/
432
433 static void on_host_state_change(sg4::Host const& host)
434 {
435   XBT_DEBUG("Host %s is now %s", host.get_cname(), host.is_on() ? "ON " : "OFF");
436   if(host.is_on()) {
437     mbox_eager->clear();
438     mbox_rdv->clear();
439   }
440 }
441
442 static void on_link_state_change(sg4::Link const& link)
443 {
444   XBT_DEBUG("Link %s is now %s", link.get_cname(), link.is_on() ? "ON " : "OFF");
445 }
446
447 static void addStateEvent(std::ostream& out, double date, bool isOn)
448 {
449   if (isOn)
450     out << date << " 1\n";
451   else
452     out << date << " 0\n";
453 }
454
455 static int prepareScenario(CommType type, int& index, double& start_time, double duration, std::ostream& sndP, std::ostream& rcvP,
456                             std::ostream& lnkP, Action snd_expected, Action rcv_expected, std::vector<Step> steps, std::vector<int> active_indices)
457 {
458
459   int ret=0;
460   if(std::find(active_indices.begin(),active_indices.end(),index)!=active_indices.end()) {
461     // Update fault profiles
462     for (Step& step : steps) {
463       assert(step.rel_time < duration);
464       if (step.type != Step::STATE)
465         continue;
466       int val = step.new_state ? 1 : 0;
467       switch (step.entity) {
468         case Step::SND:
469           sndP << start_time + step.rel_time << " " << val << std::endl;
470           break;
471         case Step::RCV:
472           rcvP << start_time + step.rel_time << " " << val << std::endl;
473           break;
474         case Step::LNK:
475           lnkP << start_time + step.rel_time << " " << val << std::endl;
476           break;
477       }
478     }
479     scenarios.push_back({type, start_time, duration, snd_expected, rcv_expected, steps, index}); 
480     ret=1;
481   }
482   index++;
483   start_time += duration;
484   return ret;
485 }
486
487 /*************************************************************************************************/
488
489 // State profiles for the resources
490 std::string SndStateProfile;
491 std::string RcvStateProfile;
492 std::string LnkStateProfile;
493
494 /*************************************************************************************************/
495
496 double build_scenarios(std::vector<int>& active_indices );
497
498 int main(int argc, char* argv[])
499 {
500
501   sg4::Engine e(&argc, argv);
502
503   std::vector<int> active_indices;
504   //Parse index of tests that need to be run
505
506   int previous_index=-1;
507   bool is_range_last=false;
508   for(int i=1; i<argc; i++) {
509     if(not strcmp(argv[i],"-"))
510       is_range_last=true;
511     else {
512       int index=atoi(argv[i]);
513       xbt_assert(index>previous_index);
514       if(is_range_last) 
515         for(int j=previous_index+1;j<=index;j++)
516           active_indices.push_back(j);
517       else
518          active_indices.push_back(index);
519        is_range_last=false;
520        previous_index=index;
521     }
522   }
523
524   double end_time = build_scenarios(active_indices);
525
526   XBT_INFO("Will run for %f seconds", end_time);
527
528
529   mbox_eager = e.mailbox_by_name_or_create("eager");
530   mbox_rdv   = e.mailbox_by_name_or_create("rdv");
531
532   sg4::NetZone* zone = sg4::create_full_zone("Top");
533
534   pr::Profile* profile_sender = pr::ProfileBuilder::from_string("sender_profile", SndStateProfile, 0);
535   sg4::Host* sender_host = zone->create_host("senderHost", HostComputePower)->set_state_profile(profile_sender)->seal();
536   pr::Profile* profile_receiver = pr::ProfileBuilder::from_string("receiver_profile", RcvStateProfile, 0);
537   sg4::Host* receiver_host = zone->create_host("receiverHost", HostComputePower)->set_state_profile(profile_receiver)->seal();
538
539   sg4::ActorPtr sender = sg4::Actor::create("sender", sender_host, SendAgent(0, receiver_host));
540   sender->set_auto_restart(true);
541
542   sg4::ActorPtr receiver = sg4::Actor::create("receiver", receiver_host, ReceiveAgent(1, sender_host));
543   receiver->set_auto_restart(true);
544
545   pr::Profile* profile_link = pr::ProfileBuilder::from_string("link_profile", LnkStateProfile, 0);
546   sg4::Link* link =
547       zone->create_link("link", LinkBandwidth)->set_latency(LinkLatency)->set_state_profile(profile_link)->seal();
548
549   zone->add_route(sender_host->get_netpoint(), receiver_host->get_netpoint(), nullptr, nullptr,
550                   {sg4::LinkInRoute{link}}, false);
551   zone->seal();
552
553   sg4::Host::on_state_change.connect(on_host_state_change);
554   sg4::Link::on_state_change_cb(on_link_state_change);
555
556   e.run_until(end_time);
557
558   return 0;
559 }
560
561 /*************************************************************************************************/
562
563 // A bunch of dirty macros to help readability (supposedly)
564 #define _MK(type, duration, snd_expected, rcv_expected, steps...)                                                      \
565   active+=prepareScenario(CommType::type, index, start_time, duration, sndP, rcvP, lnkP, Action::snd_expected, Action::rcv_expected,  \
566                   {steps}, active_indices )
567 // Link
568 #define LOFF(relTime)                                                                                                  \
569   {                                                                                                                    \
570     relTime, Step::STATE, Step::LNK, Action::END, false                                                                \
571   }
572 #define LON(relTime)                                                                                                   \
573   {                                                                                                                    \
574     relTime, Step::STATE, Step::LNK, Action::END, true                                                                 \
575   }
576 // Sender
577 #define SOFF(relTime)                                                                                                  \
578   {                                                                                                                    \
579     relTime, Step::STATE, Step::SND, Action::END, false                                                                \
580   }
581 #define SON(relTime)                                                                                                   \
582   {                                                                                                                    \
583     relTime, Step::STATE, Step::SND, Action::END, true                                                                 \
584   }
585 #define SPUT(relTime)                                                                                                  \
586   {                                                                                                                    \
587     relTime, Step::ACTION, Step::SND, Action::PUT, false                                                               \
588   }
589 #define SWAT(relTime)                                                                                                  \
590   {                                                                                                                    \
591     relTime, Step::ACTION, Step::SND, Action::WAIT, false                                                              \
592   }
593 // Receiver
594 #define ROFF(relTime)                                                                                                  \
595   {                                                                                                                    \
596     relTime, Step::STATE, Step::RCV, Action::END, false                                                                \
597   }
598 #define RON(relTime)                                                                                                   \
599   {                                                                                                                    \
600     relTime, Step::STATE, Step::RCV, Action::END, true                                                                 \
601   }
602 #define RGET(relTime)                                                                                                  \
603   {                                                                                                                    \
604     relTime, Step::ACTION, Step::RCV, Action::GET, false                                                               \
605   }
606 #define RWAT(relTime)                                                                                                  \
607   {                                                                                                                    \
608     relTime, Step::ACTION, Step::RCV, Action::WAIT, false                                                              \
609   }
610
611 double build_scenarios(std::vector<int>& active_indices )
612 {
613
614   // Build the set of simulation stages
615   std::stringstream sndP;
616   std::stringstream rcvP;
617   std::stringstream lnkP;
618
619   double start_time = 0;
620   int index=0;
621   int active=0;
622
623   // EAGER SYNC use cases
624   // All good
625   _MK(EAGER_SYNC, 1, END, END, SPUT(.2), RGET(.4));
626   _MK(EAGER_SYNC, 1, END, END, RGET(.2), SPUT(.4));
627   // Receiver off
628   _MK(EAGER_SYNC, 2, PUT, DIE, ROFF(.1), SPUT(.2), RON(1));
629   _MK(EAGER_SYNC, 2, PUT, DIE, SPUT(.2), ROFF(.3), RON(1));
630   _MK(EAGER_SYNC, 2, PUT, DIE, SPUT(.2), RGET(.4), ROFF(.5), RON(1));
631   _MK(EAGER_SYNC, 2, PUT, DIE, RGET(.2), SPUT(.4), ROFF(.5), RON(1));
632   // Sender off
633   _MK(EAGER_SYNC, 2, DIE, GET, SPUT(.2), SOFF(.3), RGET(.4), SON(1));
634   _MK(EAGER_SYNC, 2, DIE, GET, SPUT(.2), RGET(.4), SOFF(.5), SON(1));
635   // Link off
636   _MK(EAGER_SYNC, 2, PUT, GET, LOFF(.1), SPUT(.2), RGET(.4), LON(1));
637   _MK(EAGER_SYNC, 2, PUT, GET, SPUT(.2), LOFF(.3), RGET(.4), LON(1));
638   _MK(EAGER_SYNC, 2, PUT, GET, SPUT(.2), RGET(.4), LOFF(.5), LON(1));
639   _MK(EAGER_SYNC, 2, PUT, GET, LOFF(.1), RGET(.2), SPUT(.4), LON(1));
640   _MK(EAGER_SYNC, 2, PUT, GET, RGET(.2), LOFF(.3), SPUT(.4), LON(1));
641   _MK(EAGER_SYNC, 2, PUT, GET, RGET(.2), SPUT(.4), LOFF(.5), LON(1));
642
643   // EAGER ASYNC use cases
644   // All good
645   _MK(EAGER_ASYNC, 2, END, END, SPUT(.2), SWAT(.4), RGET(.6), RWAT(.8));
646   _MK(EAGER_ASYNC, 2, END, END, SPUT(.2), RGET(.4), SWAT(.6), RWAT(.8));
647   _MK(EAGER_ASYNC, 2, END, END, SPUT(.2), RGET(.4), RWAT(.6), SWAT(.8));
648   _MK(EAGER_ASYNC, 2, END, END, RGET(.2), SPUT(.4), SWAT(.6), RWAT(.8));
649   _MK(EAGER_ASYNC, 2, END, END, RGET(.2), SPUT(.4), RWAT(.6), SWAT(.8));
650   _MK(EAGER_ASYNC, 2, END, END, RGET(.2), RWAT(.4), SPUT(.6), SWAT(.8));
651   
652   // Receiver off
653   _MK(EAGER_ASYNC, 2, PUT, DIE, ROFF(.1), SPUT(.2), SWAT(.4), RON(1));
654   _MK(EAGER_ASYNC, 2, WAIT, DIE, SPUT(.2), ROFF(.3), SWAT(.4), RON(1));
655   _MK(EAGER_ASYNC, 2, PUT, DIE, RGET(.2), ROFF(.3), SPUT(.4), SWAT(.6), RON(1));
656   _MK(EAGER_ASYNC, 2, WAIT, DIE, SPUT(.2), SWAT(.4), ROFF(.5), RON(1));
657   _MK(EAGER_ASYNC, 2, WAIT, DIE, SPUT(.2), RGET(.4), ROFF(.5), SWAT(.6), RON(1));
658   _MK(EAGER_ASYNC, 2, WAIT, DIE, RGET(.2), SPUT(.4), ROFF(.5), SWAT(.6), RON(1));
659   _MK(EAGER_ASYNC, 2, PUT , DIE, RGET(.2), RWAT(.4), ROFF(.5), SPUT(.6), SWAT(.8), RON(1));
660   _MK(EAGER_ASYNC, 2, WAIT, DIE, SPUT(.2), SWAT(.4), RGET(.6), ROFF(.7), RON(1));
661   _MK(EAGER_ASYNC, 2, WAIT, DIE, SPUT(.2), RGET(.4), SWAT(.6), ROFF(.7), RON(1));
662   _MK(EAGER_ASYNC, 2, WAIT, DIE, SPUT(.2), RGET(.4), RWAT(.6), ROFF(.7), SWAT(.8), RON(1));
663   _MK(EAGER_ASYNC, 2, WAIT, DIE, RGET(.2), SPUT(.4), SWAT(.6), ROFF(.7), RON(1));
664   _MK(EAGER_ASYNC, 2, WAIT, DIE, RGET(.2), SPUT(.4), RWAT(.6), ROFF(.7), SWAT(.8), RON(1));
665   _MK(EAGER_ASYNC, 2, WAIT, DIE, RGET(.2), RWAT(.4), SPUT(.6), ROFF(.7), SWAT(.8), RON(1));
666   // Sender off (only cases where sender did put, because otherwise receiver cannot find out there was a fault)
667   _MK(EAGER_ASYNC, 2, DIE, GET, SPUT(.2), SOFF(.3), RGET(.4), RWAT(.6), SON(1));
668   _MK(EAGER_ASYNC, 2, DIE, WAIT, RGET(.2), SPUT(.4), SOFF(.5), RWAT(.6), SON(1));
669   _MK(EAGER_ASYNC, 2, DIE, WAIT, SPUT(.2), RGET(.4), SOFF(.5), RWAT(.6), SON(1));
670   _MK(EAGER_ASYNC, 2, DIE, GET, SPUT(.2), SWAT(.4), SOFF(.5), RGET(.6), RWAT(.8), SON(1));
671   _MK(EAGER_ASYNC, 2, DIE, WAIT, RGET(.2), RWAT(.4), SPUT(.6), SOFF(.7), SON(1));
672   _MK(EAGER_ASYNC, 2, DIE, WAIT, RGET(.2), SPUT(.4), RWAT(.6), SOFF(.7), SON(1));
673   _MK(EAGER_ASYNC, 2, DIE, WAIT, RGET(.2), SPUT(.4), SWAT(.6), SOFF(.7), RWAT(.8), SON(1));
674   _MK(EAGER_ASYNC, 2, DIE, WAIT, SPUT(.2), RGET(.4), RWAT(.6), SOFF(.7), SON(1));
675   _MK(EAGER_ASYNC, 2, DIE, WAIT, SPUT(.2), RGET(.4), SWAT(.6), SOFF(.7), RWAT(.8), SON(1));
676   _MK(EAGER_ASYNC, 2, DIE, WAIT, SPUT(.2), SWAT(.4), RGET(.6), SOFF(.7), RWAT(.8), SON(1));
677   // Link off
678   _MK(EAGER_ASYNC, 2, WAIT, WAIT, LOFF(.1), SPUT(.2), SWAT(.4), RGET(.6), RWAT(.8), LON(1));
679   _MK(EAGER_ASYNC, 2, WAIT, WAIT, LOFF(.1), SPUT(.2), RGET(.4), SWAT(.6), RWAT(.8), LON(1));
680   _MK(EAGER_ASYNC, 2, WAIT, WAIT, LOFF(.1), SPUT(.2), RGET(.4), RWAT(.6), SWAT(.8), LON(1));
681   _MK(EAGER_ASYNC, 2, WAIT, WAIT, LOFF(.1), RGET(.2), SPUT(.4), SWAT(.6), RWAT(.8), LON(1));
682   _MK(EAGER_ASYNC, 2, WAIT, WAIT, LOFF(.1), RGET(.2), SPUT(.4), RWAT(.6), SWAT(.8), LON(1));
683   _MK(EAGER_ASYNC, 2, WAIT, WAIT, LOFF(.1), RGET(.2), RWAT(.4), SPUT(.6), SWAT(.8), LON(1));
684   _MK(EAGER_ASYNC, 2, WAIT, WAIT, SPUT(.2), LOFF(.3), SWAT(.4), RGET(.6), RWAT(.8), LON(1));
685   _MK(EAGER_ASYNC, 2, WAIT, WAIT, SPUT(.2), LOFF(.3), RGET(.4), SWAT(.6), RWAT(.8), LON(1));
686   _MK(EAGER_ASYNC, 2, WAIT, WAIT, SPUT(.2), LOFF(.3), RGET(.4), RWAT(.6), SWAT(.8), LON(1));
687   _MK(EAGER_ASYNC, 2, WAIT, WAIT, RGET(.2), LOFF(.3), SPUT(.4), SWAT(.6), RWAT(.8), LON(1));
688   _MK(EAGER_ASYNC, 2, WAIT, WAIT, RGET(.2), LOFF(.3), SPUT(.4), RWAT(.6), SWAT(.8), LON(1));
689   _MK(EAGER_ASYNC, 2, WAIT, WAIT, RGET(.2), LOFF(.3), RWAT(.4), SPUT(.6), SWAT(.8), LON(1));
690   _MK(EAGER_ASYNC, 2, WAIT, WAIT, SPUT(.2), SWAT(.4), LOFF(.5), RGET(.6), RWAT(.8), LON(1));
691   _MK(EAGER_ASYNC, 2, WAIT, WAIT, SPUT(.2), RGET(.4), LOFF(.5), SWAT(.6), RWAT(.8), LON(1));
692   _MK(EAGER_ASYNC, 2, WAIT, WAIT, SPUT(.2), RGET(.4), LOFF(.5), RWAT(.6), SWAT(.8), LON(1));
693   _MK(EAGER_ASYNC, 2, WAIT, WAIT, RGET(.2), SPUT(.4), LOFF(.5), SWAT(.6), RWAT(.8), LON(1));
694   _MK(EAGER_ASYNC, 2, WAIT, WAIT, RGET(.2), SPUT(.4), LOFF(.5), RWAT(.6), SWAT(.8), LON(1));
695   _MK(EAGER_ASYNC, 2, WAIT, WAIT, RGET(.2), RWAT(.4), LOFF(.5), SPUT(.6), SWAT(.8), LON(1));
696   _MK(EAGER_ASYNC, 2, WAIT, WAIT, SPUT(.2), SWAT(.4), RGET(.6), LOFF(.7), RWAT(.8), LON(1));
697   _MK(EAGER_ASYNC, 2, WAIT, WAIT, SPUT(.2), RGET(.4), SWAT(.6), LOFF(.7), RWAT(.8), LON(1));
698   _MK(EAGER_ASYNC, 2, WAIT, WAIT, SPUT(.2), RGET(.4), RWAT(.6), LOFF(.7), SWAT(.8), LON(1));
699   _MK(EAGER_ASYNC, 2, WAIT, WAIT, RGET(.2), SPUT(.4), SWAT(.6), LOFF(.7), RWAT(.8), LON(1));
700   _MK(EAGER_ASYNC, 2, WAIT, WAIT, RGET(.2), SPUT(.4), RWAT(.6), LOFF(.7), SWAT(.8), LON(1));
701   _MK(EAGER_ASYNC, 2, WAIT, WAIT, RGET(.2), RWAT(.4), SPUT(.6), LOFF(.7), SWAT(.8), LON(1));
702
703   // RDV SYNC use cases
704
705   // All good
706   _MK(RDV_SYNC, 1, END, END, SPUT(.2), RGET(.4));
707   _MK(RDV_SYNC, 1, END, END, RGET(.2), SPUT(.4));
708   
709   // Receiver off
710   _MK(RDV_SYNC, 2, PUT, DIE, ROFF(.1), SPUT(.2), RON(1));
711   _MK(RDV_SYNC, 2, PUT, DIE, SPUT(.2), ROFF(.3), RON(1));
712   _MK(RDV_SYNC, 2, PUT, DIE, SPUT(.2), RGET(.4), ROFF(.5), RON(1));
713   _MK(RDV_SYNC, 2, PUT, DIE, RGET(.2), SPUT(.4), ROFF(.5), RON(1));
714   // Sender off
715   _MK(RDV_SYNC, 2, DIE, GET, SPUT(.2), RGET(.4), SOFF(.5), SON(1));
716   // Link off
717   _MK(RDV_SYNC, 2, PUT, GET, LOFF(.1), SPUT(.2), RGET(.4), LON(1));
718   _MK(RDV_SYNC, 2, PUT, GET, SPUT(.2), LOFF(.3), RGET(.4), LON(1));
719   _MK(RDV_SYNC, 2, PUT, GET, SPUT(.2), RGET(.4), LOFF(.5), LON(1));
720   _MK(RDV_SYNC, 2, PUT, GET, LOFF(.1), RGET(.2), SPUT(.4), LON(1));
721   _MK(RDV_SYNC, 2, PUT, GET, RGET(.2), LOFF(.3), SPUT(.4), LON(1));
722   _MK(RDV_SYNC, 2, PUT, GET, RGET(.2), SPUT(.4), LOFF(.5), LON(1));
723
724   // RDV ASYNC use cases
725   // All good
726   _MK(RDV_ASYNC, 2, END, END, SPUT(.2), SWAT(.4), RGET(.6), RWAT(.8));
727   _MK(RDV_ASYNC, 2, END, END, SPUT(.2), RGET(.4), SWAT(.6), RWAT(.8));
728   _MK(RDV_ASYNC, 2, END, END, SPUT(.2), RGET(.4), RWAT(.6), SWAT(.8));
729   _MK(RDV_ASYNC, 2, END, END, RGET(.2), SPUT(.4), SWAT(.6), RWAT(.8));
730   _MK(RDV_ASYNC, 2, END, END, RGET(.2), SPUT(.4), RWAT(.6), SWAT(.8));
731   _MK(RDV_ASYNC, 2, END, END, RGET(.2), RWAT(.4), SPUT(.6), SWAT(.8));
732   // Receiver off
733   _MK(RDV_ASYNC, 2, PUT, DIE, ROFF(.1), SPUT(.2), SWAT(.4), RON(1));
734   _MK(RDV_ASYNC, 2, WAIT, DIE, SPUT(.2), ROFF(.3), SWAT(.4), RON(1));
735   _MK(RDV_ASYNC, 2, PUT, DIE, RGET(.2), ROFF(.3), SPUT(.4), SWAT(.6), RON(1));
736   _MK(RDV_ASYNC, 2, WAIT, DIE, SPUT(.2), SWAT(.4), ROFF(.5), RON(1));
737   _MK(RDV_ASYNC, 2, WAIT, DIE, SPUT(.2), RGET(.4), ROFF(.5), SWAT(.6), RON(1));
738   _MK(RDV_ASYNC, 2, WAIT, DIE, RGET(.2), SPUT(.4), ROFF(.5), SWAT(.6), RON(1));
739   _MK(RDV_ASYNC, 2, PUT , DIE, RGET(.2), RWAT(.4), ROFF(.5), SPUT(.6), SWAT(.8), RON(1));
740   _MK(RDV_ASYNC, 2, WAIT, DIE, SPUT(.2), SWAT(.4), RGET(.6), ROFF(.7), RON(1));
741   _MK(RDV_ASYNC, 2, WAIT, DIE, SPUT(.2), RGET(.4), SWAT(.6), ROFF(.7), RON(1));
742   _MK(RDV_ASYNC, 2, WAIT, DIE, SPUT(.2), RGET(.4), RWAT(.6), ROFF(.7), SWAT(.8), RON(1));
743   _MK(RDV_ASYNC, 2, WAIT, DIE, RGET(.2), SPUT(.4), SWAT(.6), ROFF(.7), RON(1));
744   _MK(RDV_ASYNC, 2, WAIT, DIE, RGET(.2), SPUT(.4), RWAT(.6), ROFF(.7), SWAT(.8), RON(1));
745   _MK(RDV_ASYNC, 2, WAIT, DIE, RGET(.2), RWAT(.4), SPUT(.6), ROFF(.7), SWAT(.8), RON(1));
746   // Sender off (only cases where sender did put, because otherwise receiver cannot find out there was a fault)
747   _MK(RDV_ASYNC, 2, DIE, GET, SPUT(.2), SOFF(.3), RGET(.4), RWAT(.6), SON(1));
748   _MK(RDV_ASYNC, 2, DIE, WAIT, RGET(.2), SPUT(.4), SOFF(.5), RWAT(.6), SON(1));
749   _MK(RDV_ASYNC, 2, DIE, WAIT, SPUT(.2), RGET(.4), SOFF(.5), RWAT(.6), SON(1));
750   _MK(RDV_ASYNC, 2, DIE, GET, SPUT(.2), SWAT(.4), SOFF(.5), RGET(.6), RWAT(.8), SON(1));
751   _MK(RDV_ASYNC, 2, DIE, WAIT, RGET(.2), RWAT(.4), SPUT(.6), SOFF(.7), SON(1));
752   _MK(RDV_ASYNC, 2, DIE, WAIT, RGET(.2), SPUT(.4), RWAT(.6), SOFF(.7), SON(1));
753   _MK(RDV_ASYNC, 2, DIE, WAIT, RGET(.2), SPUT(.4), SWAT(.6), SOFF(.7), RWAT(.8), SON(1));
754   _MK(RDV_ASYNC, 2, DIE, WAIT, SPUT(.2), RGET(.4), RWAT(.6), SOFF(.7), SON(1));
755   _MK(RDV_ASYNC, 2, DIE, WAIT, SPUT(.2), RGET(.4), SWAT(.6), SOFF(.7), RWAT(.8), SON(1));
756   _MK(RDV_ASYNC, 2, DIE, WAIT, SPUT(.2), SWAT(.4), RGET(.6), SOFF(.7), RWAT(.8), SON(1));
757   // Link off
758   _MK(RDV_ASYNC, 2, WAIT, WAIT, LOFF(.1), SPUT(.2), SWAT(.4), RGET(.6), RWAT(.8), LON(1));
759   _MK(RDV_ASYNC, 2, WAIT, WAIT, LOFF(.1), SPUT(.2), RGET(.4), SWAT(.6), RWAT(.8), LON(1));
760   _MK(RDV_ASYNC, 2, WAIT, WAIT, LOFF(.1), SPUT(.2), RGET(.4), RWAT(.6), SWAT(.8), LON(1));
761   _MK(RDV_ASYNC, 2, WAIT, WAIT, LOFF(.1), RGET(.2), SPUT(.4), SWAT(.6), RWAT(.8), LON(1));
762   _MK(RDV_ASYNC, 2, WAIT, WAIT, LOFF(.1), RGET(.2), SPUT(.4), RWAT(.6), SWAT(.8), LON(1));
763   _MK(RDV_ASYNC, 2, WAIT, WAIT, LOFF(.1), RGET(.2), RWAT(.4), SPUT(.6), SWAT(.8), LON(1));
764   _MK(RDV_ASYNC, 2, WAIT, WAIT, SPUT(.2), LOFF(.3), SWAT(.4), RGET(.6), RWAT(.8), LON(1));
765   _MK(RDV_ASYNC, 2, WAIT, WAIT, SPUT(.2), LOFF(.3), RGET(.4), SWAT(.6), RWAT(.8), LON(1));
766   _MK(RDV_ASYNC, 2, WAIT, WAIT, SPUT(.2), LOFF(.3), RGET(.4), RWAT(.6), SWAT(.8), LON(1));
767   _MK(RDV_ASYNC, 2, WAIT, WAIT, RGET(.2), LOFF(.3), SPUT(.4), SWAT(.6), RWAT(.8), LON(1));
768   _MK(RDV_ASYNC, 2, WAIT, WAIT, RGET(.2), LOFF(.3), SPUT(.4), RWAT(.6), SWAT(.8), LON(1));
769   _MK(RDV_ASYNC, 2, WAIT, WAIT, RGET(.2), LOFF(.3), RWAT(.4), SPUT(.6), SWAT(.8), LON(1));
770   _MK(RDV_ASYNC, 2, WAIT, WAIT, SPUT(.2), SWAT(.4), LOFF(.5), RGET(.6), RWAT(.8), LON(1));
771   _MK(RDV_ASYNC, 2, WAIT, WAIT, SPUT(.2), RGET(.4), LOFF(.5), SWAT(.6), RWAT(.8), LON(1));
772   _MK(RDV_ASYNC, 2, WAIT, WAIT, SPUT(.2), RGET(.4), LOFF(.5), RWAT(.6), SWAT(.8), LON(1));
773   _MK(RDV_ASYNC, 2, WAIT, WAIT, RGET(.2), SPUT(.4), LOFF(.5), SWAT(.6), RWAT(.8), LON(1));
774   _MK(RDV_ASYNC, 2, WAIT, WAIT, RGET(.2), SPUT(.4), LOFF(.5), RWAT(.6), SWAT(.8), LON(1));
775   _MK(RDV_ASYNC, 2, WAIT, WAIT, RGET(.2), RWAT(.4), LOFF(.5), SPUT(.6), SWAT(.8), LON(1));
776   _MK(RDV_ASYNC, 2, WAIT, WAIT, SPUT(.2), SWAT(.4), RGET(.6), LOFF(.7), RWAT(.8), LON(1));
777   _MK(RDV_ASYNC, 2, WAIT, WAIT, SPUT(.2), RGET(.4), SWAT(.6), LOFF(.7), RWAT(.8), LON(1));
778   _MK(RDV_ASYNC, 2, WAIT, WAIT, SPUT(.2), RGET(.4), RWAT(.6), LOFF(.7), SWAT(.8), LON(1));
779   _MK(RDV_ASYNC, 2, WAIT, WAIT, RGET(.2), SPUT(.4), SWAT(.6), LOFF(.7), RWAT(.8), LON(1));
780   _MK(RDV_ASYNC, 2, WAIT, WAIT, RGET(.2), SPUT(.4), RWAT(.6), LOFF(.7), SWAT(.8), LON(1));
781   _MK(RDV_ASYNC, 2, WAIT, WAIT, RGET(.2), RWAT(.4), SPUT(.6), LOFF(.7), SWAT(.8), LON(1));
782
783   // ONESIDE SYNC use cases
784
785   // All good
786   _MK(ONESIDE_SYNC, 1, END, END, SPUT(.2));
787   // Receiver off
788   _MK(ONESIDE_SYNC, 2, PUT, DIE, ROFF(.1), SPUT(.2), RON(1));
789   _MK(ONESIDE_SYNC, 2, PUT, DIE, SPUT(.2), ROFF(.3), RON(1));
790   // Link off
791   _MK(ONESIDE_SYNC, 2, PUT, GET, LOFF(.1), SPUT(.2), LON(1));
792   _MK(ONESIDE_SYNC, 2, PUT, GET, SPUT(.2), LOFF(.3), LON(1));
793
794   // ONESIDE ASYNC use cases
795   // All good
796   _MK(ONESIDE_ASYNC, 2, END, END, SPUT(.2), SWAT(.4));
797   // Receiver off
798   _MK(ONESIDE_ASYNC, 2, PUT, DIE, ROFF(.1), SPUT(.2), SWAT(.4), RON(1));
799   _MK(ONESIDE_ASYNC, 2, WAIT, DIE, SPUT(.2), ROFF(.3), SWAT(.4), RON(1));
800   _MK(ONESIDE_ASYNC, 2, WAIT, DIE, SPUT(.2), SWAT(.4), ROFF(.5), RON(1));
801   // Link off
802   _MK(ONESIDE_ASYNC, 2, WAIT, WAIT, LOFF(.1), SPUT(.2), SWAT(.4), LON(1));
803   _MK(ONESIDE_ASYNC, 2, WAIT, WAIT, SPUT(.2), LOFF(.3), SWAT(.4), LON(1));
804   _MK(ONESIDE_ASYNC, 2, WAIT, WAIT, SPUT(.2), SWAT(.4), LOFF(.5), LON(1));
805
806
807   SndStateProfile = sndP.str();
808   RcvStateProfile = rcvP.str();
809   LnkStateProfile = lnkP.str();
810
811   XBT_INFO("Will execute %i active scenarios out of %i.",active,index);
812   return start_time + 1;
813 }