1 /* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved. */
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. */
6 #include "simgrid/s4u.hpp"
8 /* This example demonstrates how to use wifi links in SimGrid. Most of the interesting things happen in the
9 * corresponding XML file.
12 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_network_wifi, "Messages specific for this s4u example");
14 static void sender(simgrid::s4u::Mailbox* mailbox, int data_size)
16 XBT_INFO("Send a message to the other station.");
17 static char message[] = "message";
18 mailbox->put(message, data_size);
21 static void receiver(simgrid::s4u::Mailbox* mailbox)
23 XBT_INFO("Wait for a message.");
28 int main(int argc, char* argv[])
30 simgrid::s4u::Engine e(&argc, argv);
32 xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s platform.xml deployment.xml\n", argv[0], argv[0]);
34 e.load_platform(argv[1]);
36 auto mailbox = simgrid::s4u::Mailbox::by_name("mailbox");
37 auto station1 = simgrid::s4u::Host::by_name("Station 1");
38 auto station2 = simgrid::s4u::Host::by_name("Station 2");
39 simgrid::s4u::Actor::create("sender", station1, sender, mailbox, 1e7);
40 simgrid::s4u::Actor::create("receiver", station2, receiver, mailbox);
42 auto ap = simgrid::s4u::Link::by_name("AP1");
43 ap->set_host_wifi_rate(station1, 1); // The host "Station 1" uses the second level of bandwidths on that AP
44 ap->set_host_wifi_rate(station2, 0); // This is perfectly useless as level 0 is used by default