X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/76d4849864c227687e17bdd93c5b1338e9b4cb50..8be89720f55b4ceeb2877531ae1602cc7ed947d6:/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp diff --git a/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp b/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp index ea39344486..04057bc587 100644 --- a/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp +++ b/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2019-2021. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2019-2023. 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. */ @@ -11,48 +11,46 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[usage] wifi_usage "); -void run_ping_test(const char* src, const char* dest, int data_size); +void run_ping_test(const std::vector>& mboxes, int data_size); /* We need a separate actor so that it can sleep after each test */ static void main_dispatcher() { - bool crosstraffic = simgrid::kernel::resource::NetworkModel::cfg_crosstraffic; + const std::vector> flows = { + {"Station 1", "Station 2"}, + {"Station 3", "Station 4"}, + {"Station 5", "Station 6"}, + {"Station 7", "Station 8"}, + {"Station 9", "Station 10"}, + {"Station 11", "Station 12"}, + {"Station 13", "Station 14"}, + {"Station 15", "Station 16"}, + {"Station 17", "Station 18"}, + {"Station 19", "Station 20"}, + {"Station 21", "Station 22"}, + }; - XBT_INFO("TEST: Send from a station to a node on the wired network after the AP."); - XBT_INFO("----------------------------------------------------------------------"); - XBT_INFO("Since AP1 is the limiting link, we have the following constraint for AP1:"); - if (crosstraffic) { - XBT_INFO("1.05/r_STA1 * rho_STA1 <= 1 (1.05 instead of 1 because of cross-traffic)"); - XBT_INFO("However, decay model specify that for 2 stations, we have 54Mbps become 49.00487"); - XBT_INFO("We should thus have:"); - XBT_INFO(" mu = 1 / [ 1/1 * 1.05/49.00487Mbps ] = 46671305"); - XBT_INFO(" simulation_time = 1000*8 / mu = 0.0001714115 (rounded to 0.000171s in SimGrid)"); - } else { - XBT_INFO("1/r_STA1 * rho_STA1 <= 1 (there is no cross-traffic)"); - XBT_INFO("However, decay model specify that for 2 stations, we have 54Mbps become 49.00487"); - XBT_INFO("We should thus have:"); - XBT_INFO(" mu = 1 / [ 1/1 * 1/49.00487Mbps ] = 49004870"); - XBT_INFO(" simulation_time = 1000*8 / mu = 0.0001632491s (rounded to 0.000163s in SimGrid)"); - } - run_ping_test("Station 1", "node1", 1000); + XBT_INFO("1/r_STA1 * rho_STA1 <= 1 (there is no cross-traffic)"); + XBT_INFO("22 concurrent flows, decay model deactivated, we have 54Mbps to share between the flows"); + XBT_INFO("We should thus have:"); + XBT_INFO(" mu = 1 / [ 1/22 * (1/54Mbps)*22 ] = 54000000"); + XBT_INFO(" simulation_time = 100000*8 / (mu/22) = 0.3259259259259259 (rounded to 0.325926s in SimGrid)"); - XBT_INFO("TEST: Send from a station to another station on the same AP."); - XBT_INFO("------------------------------------------------------------"); - XBT_INFO("We have the following constraint for AP1:"); - if (crosstraffic) { - XBT_INFO("1.05/r_STA1 * rho_STA1 + 1.05/r_STA2 * rho_2 <= 1 (1.05 instead of 1 because of cross-traffic)"); - XBT_INFO("However, decay model specify that for 2 stations, we have 54Mbps become 49.00487"); - XBT_INFO("We should thus have:"); - XBT_INFO(" mu = 1 / [ 1/2 * 1.05/49.00487Mbps + 1.05/49.00487Mbps ] = 46671305"); - XBT_INFO(" simulation_time = 1000*8 / [ mu / 2 ] = 0.0003428231s (rounded to 0.000343s in SimGrid)"); - } else { - XBT_INFO("1/r_STA1 * rho_STA1 + 1/r_STA2 * rho_2 <= 1 (there is no cross-traffic)"); - XBT_INFO("However, decay model specify that for 2 stations, we have 54Mbps become 49.00487"); - XBT_INFO(" mu = 1 / [ 1/2 * 1/49.00487Mbps + 1/49.00487Mbps ] = 49004870"); - XBT_INFO(" simulation_time = 1000*8 / [ mu / 2 ] = 0.0003264982s (rounded to 0.000326s in SimGrid)"); - } - run_ping_test("Station 1", "Station 2", 1000); + run_ping_test(flows, 100000); + + XBT_INFO("1/r_STA1 * rho_STA1 <= 1 (there is no cross-traffic)"); + XBT_INFO("22 concurrent flows, decay model activated, we have 54Mbps to share between the flows, but the number of concurrent flows is above the limit (20)"); + XBT_INFO("We should thus have:"); + XBT_INFO("Maximum throughput of the link reduced by:"); + XBT_INFO("updated link capacity = ( 5678270 + (22-20) * -5424 ) / 5678270 =~ 0.998086"); + XBT_INFO(" mu = 1 / [ 1/22 * (1/54Mbps*0.998086)*22 ] = 53896644"); + XBT_INFO(" simulation_time = 100000*8 / (mu/22) = 0.3265509444335718 (rounded to 0.326550 in SimGrid)"); + + auto* l = (simgrid::kernel::resource::WifiLinkImpl*)simgrid::s4u::Link::by_name("AP1")->get_impl(); + l->toggle_callback(); + run_ping_test(flows, 100000); } + int main(int argc, char** argv) { simgrid::s4u::Engine engine(&argc, argv); @@ -63,25 +61,25 @@ int main(int argc, char** argv) return 0; } -void run_ping_test(const char* src, const char* dest, int data_size) +void run_ping_test(const std::vector>& mboxes, int data_size) { 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(); - 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::WifiLinkImpl*)simgrid::s4u::Link::by_name("AP1")->get_impl(); - if (not l->toggle_decay_model()) - l->toggle_decay_model(); - l->set_host_rate(simgrid::s4u::Host::by_name("Station 1"), 0); - l->set_host_rate(simgrid::s4u::Host::by_name("Station 2"), 0); + for (auto const& pair : mboxes) { + simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name(pair.first.c_str()), [mailbox, pair, data_size]() { + double start_time = simgrid::s4u::Engine::get_clock(); + 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(), pair.second.c_str(), end_time - start_time); + }); + simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name(pair.second.c_str()), + [mailbox]() { mailbox->get(); }); + auto* l = (simgrid::kernel::resource::WifiLinkImpl*)simgrid::s4u::Link::by_name("AP1")->get_impl(); + for(auto i=1; i<=22; i++) { + l->set_host_rate(simgrid::s4u::Host::by_name("Station "+std::to_string(i)), 0); + } + } simgrid::s4u::this_actor::sleep_for(10); XBT_INFO("\n"); }