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"
15 XBT_LOG_NEW_DEFAULT_CATEGORY(test_wifi, "Wifi energy demo");
19 // start sending after 5 seconds
20 simgrid::s4u::this_actor::sleep_until(5);
22 std::string mbName = "MailBoxRCV";
23 simgrid::s4u::Mailbox *dst = simgrid::s4u::Mailbox::by_name(mbName);
27 XBT_INFO("SENDING 1 msg of size %d to %s", size, mbName.c_str());
28 static std::string message = "message";
29 dst->put(&message, size);
30 XBT_INFO("finished sending");
33 static void receiver()
35 std::string mbName = "MailBoxRCV";
36 XBT_INFO("RECEIVING on mb %s", mbName.c_str());
37 simgrid::s4u::Mailbox *myBox = simgrid::s4u::Mailbox::by_name(mbName);
40 XBT_INFO("received all messages");
43 int main(int argc, char** argv)
45 simgrid::s4u::Engine engine(&argc, argv);
46 sg_wifi_energy_plugin_init();
47 engine.load_platform(argv[1]);
49 // setup WiFi bandwidths
50 const auto* l = simgrid::s4u::Link::by_name("AP1");
51 l->set_host_wifi_rate(simgrid::s4u::Host::by_name("Station 1"), 0);
52 l->set_host_wifi_rate(simgrid::s4u::Host::by_name("Station 2"), 0);
54 // create the two actors for the test
55 simgrid::s4u::Actor::create("act0", simgrid::s4u::Host::by_name("Station 1"), sender);
56 simgrid::s4u::Actor::create("act1", simgrid::s4u::Host::by_name("Station 2"), receiver);