2 * Test the wifi energy plugin
3 * Desactivate cross-factor to get round values
4 * Launch with: ./test test_platform_2STA.xml --cfg=plugin:link_energy_wifi --cfg=network/crosstraffic:0
7 #include "simgrid/plugins/energy.h"
8 #include "simgrid/s4u/Activity.hpp"
9 #include "simgrid/s4u/Actor.hpp"
10 #include "simgrid/s4u/Engine.hpp"
11 #include "simgrid/s4u/Host.hpp"
12 #include "simgrid/s4u/Link.hpp"
13 #include "simgrid/s4u/Mailbox.hpp"
16 //#include <exception>
22 XBT_LOG_NEW_DEFAULT_CATEGORY(test_wifi, "Wifi energy demo");
26 // start sending after 5 seconds
27 simgrid::s4u::this_actor::sleep_until(5);
29 std::string mbName = "MailBoxRCV";
30 simgrid::s4u::Mailbox *dst = simgrid::s4u::Mailbox::by_name(mbName);
34 XBT_INFO("SENDING 1 msg of size %d to %s", size, mbName.c_str());
35 static char message[] = "message";
36 dst->put(message, size);
37 XBT_INFO("finished sending");
40 static void receiver()
42 std::string mbName = "MailBoxRCV";
43 XBT_INFO("RECEIVING on mb %s", mbName.c_str());
44 simgrid::s4u::Mailbox *myBox = simgrid::s4u::Mailbox::by_name(mbName);
47 XBT_INFO("received all messages");
50 int main(int argc, char** argv)
53 simgrid::s4u::Engine engine(&argc, argv);
54 XBT_INFO("Activating the SimGrid link energy plugin");
55 sg_wifi_energy_plugin_init();
56 engine.load_platform(argv[1]);
58 // setup WiFi bandwidths
59 auto* l = simgrid::s4u::Link::by_name("AP1");
60 l->set_host_wifi_rate(simgrid::s4u::Host::by_name("Station 1"), 0);
61 l->set_host_wifi_rate(simgrid::s4u::Host::by_name("Station 2"), 0);
63 // create the two actors for the test
64 simgrid::s4u::Actor::create("act0", simgrid::s4u::Host::by_name("Station 1"), sender);
65 simgrid::s4u::Actor::create("act1", simgrid::s4u::Host::by_name("Station 2"), receiver);