-foreach(x lmm_usage surf_usage surf_usage2)
+foreach(x lmm_usage surf_usage surf_usage2 wifi_usage)
add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.cpp)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
ADD_TESH(tesh-surf-${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/surf/${x} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/${x} ${x}.tesh)
endforeach()
-foreach(x 1STA-1LINK-1NODE 2STA)
- add_executable (${x} EXCLUDE_FROM_ALL wifi_usage/${x}.cpp)
- target_link_libraries(${x} simgrid)
- set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/wifi_usage)
- set_property(TARGET ${x} APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
- add_dependencies(tests ${x})
-
- set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/wifi_usage/${x}.tesh)
- set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/wifi_usage/${x}.cpp)
-
- ADD_TESH(tesh-surf-wifi-${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/surf/wifi_usage --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/wifi_usage ${x}.tesh)
-endforeach()
-
add_executable (maxmin_bench EXCLUDE_FROM_ALL maxmin_bench/maxmin_bench.cpp)
target_link_libraries(maxmin_bench simgrid)
set_target_properties(maxmin_bench PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/maxmin_bench)
+++ /dev/null
-/* Copyright (c) 2017-2018. 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/log.h"
-
-#include "simgrid/msg.h"
-#include "src/surf/network_cm02.hpp"
-#include <exception>
-#include <iostream>
-#include <random>
-#include <string>
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[wifi_usage] 1STA-1LINK-1NODE");
-
-void setup_simulation();
-static void flowActor(std::vector<std::string> args);
-
-/**
- * Theory says:
- * - AP1 is the limiting constraint
- * - When two STA communicates on the same AP we have the following AP constraint:
- * w/o cross-traffic: 1/r_STA1 * rho_STA1 <= 1
- * with cross-traffic: 1.05/r_STA1 * rho_STA1 <= 1
- * - Thus without cross-traffic:
- * mu = 1 / [ 1/1 * 1/54Mbps ] = 5.4e+07
- * simulation_time = 1000*8 / mu = 0.0001481481s
- * - Thus with cross-traffic:
- * mu = 1 / [ 1/1 * 1.05/54Mbps ] = 51428571
- * simulation_time = 1000*8 / mu = 0.0001555556s (rounded to 0.000156s in SimGrid)
- */
-int main(int argc, char** argv)
-{
-
- // Build engine
- simgrid::s4u::Engine engine(&argc, argv);
- engine.load_platform(argv[1]);
- setup_simulation();
- engine.run();
- XBT_INFO("Simulation took %fs", simgrid::s4u::Engine::get_clock());
-
- return (0);
-}
-
-void setup_simulation()
-{
-
- std::vector<std::string> args, noArgs;
- args.push_back("NODE1");
- args.push_back("1000");
- simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name("Station 1"), flowActor, args);
- simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name("NODE1"), flowActor, noArgs);
- simgrid::kernel::resource::NetworkWifiLink* l =
- (simgrid::kernel::resource::NetworkWifiLink*)simgrid::s4u::Link::by_name("AP1")->get_impl();
- l->set_host_rate(simgrid::s4u::Host::by_name("Station 1"), 0);
-}
-
-static void flowActor(std::vector<std::string> args)
-{
- std::string selfName = simgrid::s4u::this_actor::get_host()->get_name();
- simgrid::s4u::Mailbox* selfMailbox = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_host()->get_name());
-
- if (args.size() > 0) { // We should send
- simgrid::s4u::Mailbox* dstMailbox = simgrid::s4u::Mailbox::by_name(args.at(0));
-
- int dataSize = std::atoi(args.at(1).c_str());
- double comStartTime = simgrid::s4u::Engine::get_clock();
- dstMailbox->put(const_cast<char*>("message"), dataSize);
- double comEndTime = simgrid::s4u::Engine::get_clock();
- XBT_INFO("%s sent %d bytes to %s in %f seconds from %f to %f", selfName.c_str(), dataSize, args.at(0).c_str(),
- comEndTime - comStartTime, comStartTime, comEndTime);
- } else { // We should receive
- selfMailbox->get();
- }
-}
+++ /dev/null
-#!/usr/bin/env tesh
-
-p Test WITH crosstraffic
-$ ${bindir:=.}/1STA-1LINK-1NODE ${platfdir}/wifi.xml
-> [Station 1:sender:(1) 0.000156] [simulator/INFO] Station 1 sent 1000 bytes to NODE1 in 0.000156 seconds from 0.000000 to 0.000156
-> [0.000156] [simulator/INFO] Simulation took 0.000156s
-
-p Test WITHOUT crosstraffic
-$ ${bindir:=.}/1STA-1LINK-1NODE ${platfdir}/wifi.xml --cfg=network/crosstraffic:0
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/crosstraffic' to '0'
-> [Station 1:sender:(1) 0.000148] [simulator/INFO] Station 1 sent 1000 bytes to NODE1 in 0.000148 seconds from 0.000000 to 0.000148
-> [0.000148] [simulator/INFO] Simulation took 0.000148s
+++ /dev/null
-/* Copyright (c) 2017-2018. 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/msg.h"
-#include "simgrid/s4u.hpp"
-#include "src/surf/network_cm02.hpp"
-#include "xbt/log.h"
-#include <exception>
-#include <iostream>
-#include <random>
-#include <string>
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[wifi_usage] 2STA-1NODE");
-
-void setup_simulation();
-static void flowActor(std::vector<std::string> args);
-
-/**
- * Theory says:
- * - When two STA communicates on the same AP we have the following AP constraint:
- * w/o cross-traffic: 1/r_STA1 * rho_STA1 + 1/r_STA2 * rho_2 <= 1
- * with cross-traffic: 1.05/r_STA1 * rho_STA1 + 1.05/r_STA2 * rho_2 <= 1
- * - Thus without cross-traffic:
- * mu = 1 / [ 1/2 * 1/54Mbps + 1/54Mbps ] = 5.4e+07
- * simulation_time = 1000*8 / [ mu / 2 ] = 0.0002962963s
- * - Thus with cross-traffic:
- * mu = 1 / [ 1/2 * 1.05/54Mbps + 1.05/54Mbps ] = 51428571
- * simulation_time = 1000*8 / [ mu / 2 ] = 0.0003111111s
- */
-int main(int argc, char** argv)
-{
-
- // Build engine
- simgrid::s4u::Engine engine(&argc, argv);
- engine.load_platform(argv[1]);
- setup_simulation();
- engine.run();
- XBT_INFO("Simulation took %fs", simgrid::s4u::Engine::get_clock());
-
- return (0);
-}
-
-void setup_simulation()
-{
-
- std::vector<std::string> args, noArgs;
- args.push_back("Station 2");
- args.push_back("1000");
- simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name("Station 1"), flowActor, args);
- simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name("Station 2"), flowActor, noArgs);
- simgrid::kernel::resource::NetworkWifiLink* l =
- (simgrid::kernel::resource::NetworkWifiLink*)simgrid::s4u::Link::by_name("AP1")->get_impl();
- l->set_host_rate(simgrid::s4u::Host::by_name("Station 1"), 0);
- l->set_host_rate(simgrid::s4u::Host::by_name("Station 2"), 0);
-}
-
-static void flowActor(std::vector<std::string> args)
-{
- std::string selfName = simgrid::s4u::this_actor::get_host()->get_name();
- simgrid::s4u::Mailbox* selfMailbox = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_host()->get_name());
-
- if (args.size() > 0) { // We should send
- simgrid::s4u::Mailbox* dstMailbox = simgrid::s4u::Mailbox::by_name(args.at(0));
-
- int dataSize = std::atoi(args.at(1).c_str());
- double comStartTime = simgrid::s4u::Engine::get_clock();
- dstMailbox->put(const_cast<char*>("message"), dataSize);
- double comEndTime = simgrid::s4u::Engine::get_clock();
- XBT_INFO("%s sent %d bytes to %s in %f seconds from %f to %f", selfName.c_str(), dataSize, args.at(0).c_str(),
- comEndTime - comStartTime, comStartTime, comEndTime);
- } else { // We should receive
- selfMailbox->get();
- }
-}
+++ /dev/null
-#!/usr/bin/env tesh
-
-$ ${bindir:=.}/2STA ${platfdir}/wifi.xml --cfg=network/crosstraffic:0
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/crosstraffic' to '0'
-> [Station 1:sender:(1) 0.000296] [simulator/INFO] Station 1 sent 1000 bytes to Station 2 in 0.000296 seconds from 0.000000 to 0.000296
-> [0.000296] [simulator/INFO] Simulation took 0.000296s
-
-$ ${bindir:=.}/2STA ${platfdir}/wifi.xml
-> [Station 1:sender:(1) 0.000311] [simulator/INFO] Station 1 sent 1000 bytes to Station 2 in 0.000311 seconds from 0.000000 to 0.000311
-> [0.000311] [simulator/INFO] Simulation took 0.000311s
--- /dev/null
+/* Copyright (c) 2019. 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/log.h"
+
+#include "simgrid/msg.h"
+#include "src/surf/network_cm02.hpp"
+#include <exception>
+#include <iostream>
+#include <random>
+#include <string>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[usage] wifi_usage <platform-file>");
+
+void run_ping_test(const char* src, const char* dest, int data_size);
+
+/* We need a separate actor so that it can sleep after each test */
+static void main_dispatcher()
+{
+ /* Send from a station to a node on the wired network after the AP
+ * The theory says:
+ * - AP1 is the limiting constraint
+ * - When two STA communicates on the same AP we have the following AP constraint:
+ * w/o cross-traffic: 1/r_STA1 * rho_STA1 <= 1
+ * with cross-traffic: 1.05/r_STA1 * rho_STA1 <= 1
+ * - Thus without cross-traffic:
+ * mu = 1 / [ 1/1 * 1/54Mbps ] = 5.4e+07
+ * simulation_time = 1000*8 / mu = 0.0001481481s
+ * - Thus with cross-traffic:
+ * mu = 1 / [ 1/1 * 1.05/54Mbps ] = 51428571
+ * simulation_time = 1000*8 / mu = 0.0001555556s (rounded to 0.000156s in SimGrid)
+ */
+ run_ping_test("Station 1", "NODE1", 1000);
+
+ /* Send from a station to another station of the same AP
+ * The theory says:
+ * - When two STA communicates on the same AP we have the following AP constraint:
+ * w/o cross-traffic: 1/r_STA1 * rho_STA1 + 1/r_STA2 * rho_2 <= 1
+ * with cross-traffic: 1.05/r_STA1 * rho_STA1 + 1.05/r_STA2 * rho_2 <= 1
+ * - Thus without cross-traffic:
+ * mu = 1 / [ 1/2 * 1/54Mbps + 1/54Mbps ] = 5.4e+07
+ * simulation_time = 1000*8 / [ mu / 2 ] = 0.0002962963s
+ * - Thus with cross-traffic:
+ * mu = 1 / [ 1/2 * 1.05/54Mbps + 1.05/54Mbps ] = 51428571
+ * simulation_time = 1000*8 / [ mu / 2 ] = 0.0003111111s
+ */
+ run_ping_test("Station 1", "Station 2", 1000);
+}
+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);
+ engine.run();
+
+ return 0;
+}
+
+void run_ping_test(const char* src, const char* dest, int data_size)
+{
+ static int test_count = 0;
+ simgrid::s4u::this_actor::sleep_until(10 * test_count);
+ test_count++;
+
+ auto* mailbox = simgrid::s4u::Mailbox::by_name("Test");
+
+ simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name(src), [mailbox, dest, data_size]() {
+ double start_time = simgrid::s4u::Engine::get_clock();
+ mailbox->put(const_cast<char*>("message"), data_size);
+ double end_time = simgrid::s4u::Engine::get_clock();
+ XBT_INFO("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);
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+p Test WITH crosstraffic
+$ ${bindir:=.}/wifi_usage ${platfdir}/wifi.xml --log=root.fmt=%m%n
+> Sending 1000 bytes from 'Station 1' to 'NODE1' takes 0.000156 seconds.
+> Sending 1000 bytes from 'Station 1' to 'Station 2' takes 0.000311 seconds.
+
+p Test WITHOUT crosstraffic
+$ ${bindir:=.}/wifi_usage ${platfdir}/wifi.xml --log=root.fmt=%m%n --cfg=network/crosstraffic:0
+> Configuration change: Set 'network/crosstraffic' to '0'
+> Sending 1000 bytes from 'Station 1' to 'NODE1' takes 0.000148 seconds.
+> Sending 1000 bytes from 'Station 1' to 'Station 2' takes 0.000296 seconds.