Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make this test more verbose to improve debuggability
[simgrid.git] / teshsuite / surf / wifi_usage / wifi_usage.cpp
index e06ebe3..ea2a0b2 100644 (file)
@@ -20,33 +20,37 @@ 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)
-   */
+  bool crosstraffic = simgrid::kernel::resource::NetworkModel::cfg_crosstraffic;
+
+  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("We should thus have:");
+    XBT_INFO("  mu = 1 / [ 1/1 * 1.05/54Mbps ] = 51428571");
+    XBT_INFO("  simulation_time = 1000*8 / mu = 0.0001555556s (rounded to 0.000156s in SimGrid)");
+  } else {
+    XBT_INFO("1/r_STA1 * rho_STA1 <= 1  (there is no cross-traffic)");
+    XBT_INFO("We should thus have:");
+    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);
 
-  /* 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
-   */
+  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("We should thus have:");
+    XBT_INFO("  mu = 1 / [ 1/2 * 1.05/54Mbps + 1.05/54Mbps ] =  51428571");
+    XBT_INFO("  simulation_time = 1000*8 / [ mu / 2 ] = 0.0003111111s");
+  } else {
+    XBT_INFO("1/r_STA1 * rho_STA1 +    1/r_STA2 * rho_2 <= 1   (there is no cross-traffic)");
+    XBT_INFO("  mu = 1 / [ 1/2 * 1/54Mbps + 1/54Mbps ] = 5.4e+07");
+    XBT_INFO("  simulation_time = 1000*8 / [ mu / 2 ] = 0.0002962963s");
+  }
   run_ping_test("Station 1", "Station 2", 1000);
 }
 int main(int argc, char** argv)
@@ -61,20 +65,18 @@ int main(int argc, char** argv)
 
 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,
+    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::this_actor::sleep_for(10);
+  XBT_INFO("\n");
 }