Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / teshsuite / surf / wifi_usage / wifi_usage.cpp
index a081c0b..a2ffa54 100644 (file)
@@ -1,17 +1,13 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/s4u.hpp"
+#include "xbt/config.hpp"
 #include "xbt/log.h"
 
-#include "simgrid/msg.h"
-#include "src/surf/network_cm02.hpp"
-#include <exception>
-#include <iostream>
-#include <random>
-#include <string>
+#include "src/surf/network_interface.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[usage] wifi_usage <platform-file>");
 
@@ -36,7 +32,7 @@ static void main_dispatcher()
     XBT_INFO("  mu = 1 / [ 1/1 * 1/54Mbps ] = 5.4e+07");
     XBT_INFO("  simulation_time = 1000*8 / mu = 0.0001481481s");
   }
-  run_ping_test("Station 1", "NODE1", 1000);
+  run_ping_test("Station 1", "node1", 1000);
 
   XBT_INFO("TEST: Send from a station to another station on the same AP.");
   XBT_INFO("------------------------------------------------------------");
@@ -57,7 +53,7 @@ int main(int argc, char** argv)
 {
   simgrid::s4u::Engine engine(&argc, argv);
   engine.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("dispatcher", simgrid::s4u::Host::by_name("NODE1"), main_dispatcher);
+  simgrid::s4u::Actor::create("dispatcher", simgrid::s4u::Host::by_name("node1"), main_dispatcher);
   engine.run();
 
   return 0;
@@ -69,15 +65,17 @@ void run_ping_test(const char* src, const char* dest, int data_size)
 
   simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name(src), [mailbox, dest, data_size]() {
     double start_time = simgrid::s4u::Engine::get_clock();
-    static char message[] = "message";
-    mailbox->put(message, data_size);
+    static std::string message = "message";
+    mailbox->put(&message, data_size);
     double end_time = simgrid::s4u::Engine::get_clock();
     XBT_INFO("Actual result: Sending %d bytes from '%s' to '%s' takes %f seconds.", data_size,
              simgrid::s4u::this_actor::get_host()->get_cname(), dest, end_time - start_time);
   });
-  simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name(dest), [mailbox]() { mailbox->get(); });
-  auto* l = (simgrid::kernel::resource::NetworkWifiLink*)simgrid::s4u::Link::by_name("AP1")->get_impl();
-  l->set_host_rate(simgrid::s4u::Host::by_name(src), 0);
+  simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name(dest),
+                              [mailbox]() { mailbox->get<std::string>(); });
+  const auto* ap1 = simgrid::s4u::Link::by_name("AP1");
+  ap1->set_host_wifi_rate(simgrid::s4u::Host::by_name(src), 0);
+  ap1->set_host_wifi_rate(simgrid::s4u::Host::by_name(dest), 0);
   simgrid::s4u::this_actor::sleep_for(10);
   XBT_INFO("\n");
 }