2 * Test the wifi energy plugin
3 * Desactivate cross-factor to get round values
4 * Launche with: ./test test_platform_2STA.xml --cfg=plugin:link_energy_wifi --cfg=network/crosstraffic:0
7 #include "simgrid/s4u.hpp"
9 #include "simgrid/msg.h"
10 #include "simgrid/s4u/Activity.hpp"
11 #include "simgrid/plugins/energy.h"
12 #include "src/surf/network_wifi.hpp"
20 XBT_LOG_NEW_DEFAULT_CATEGORY(experience, "Wifi exp");
22 static void receiver();
24 int main(int argc, char **argv)
27 simgrid::s4u::Engine engine(&argc, argv);
28 XBT_INFO("Activating the SimGrid link energy plugin");
29 sg_wifi_energy_plugin_init();
30 engine.load_platform(argv[1]);
32 // setup WiFi bandwidths
33 simgrid::kernel::resource::NetworkWifiLink *l = (simgrid::kernel::resource::NetworkWifiLink *)simgrid::s4u::Link::by_name(
36 l->set_host_rate(simgrid::s4u::Host::by_name("Station 1"), 0);
37 l->set_host_rate(simgrid::s4u::Host::by_name("Station 2"), 0);
39 // create the two actors for the test
40 simgrid::s4u::Actor::create("act0", simgrid::s4u::Host::by_name("Station 1"), sender);
41 simgrid::s4u::Actor::create("act1", simgrid::s4u::Host::by_name("Station 2"), receiver);
50 // start sending after 5 seconds
51 simgrid::s4u::this_actor::sleep_until(5);
53 std::string mbName = "MailBoxRCV";
54 simgrid::s4u::Mailbox *dst = simgrid::s4u::Mailbox::by_name(mbName);
58 XBT_INFO("SENDING 1 msg of size %d to %s", size, mbName.c_str());
59 static char message[] = "message";
60 dst->put(message, size);
61 XBT_INFO("finished sending");
64 static void receiver()
66 std::string mbName = "MailBoxRCV";
67 XBT_INFO("RECEIVING on mb %s", mbName.c_str());
68 simgrid::s4u::Mailbox *myBox = simgrid::s4u::Mailbox::by_name(mbName);
71 XBT_INFO("received all messages");