Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make sure that NS3 simulation advance if there are active flows even if NS3 returns...
authorLucas Schnorr <Lucas.Schnorr@imag.fr>
Wed, 7 Sep 2011 08:14:22 +0000 (10:14 +0200)
committerLucas Schnorr <Lucas.Schnorr@imag.fr>
Thu, 8 Sep 2011 14:56:11 +0000 (16:56 +0200)
This could be caused by a pause event introduced by a previous "run NS3 for no more than xxx seconds".
Return -1.0 as expected when there are no flows to handle.

src/surf/network_ns3.c

index b9f2de5..86c1aa1 100644 (file)
@@ -417,20 +417,19 @@ static double ns3_share_resources(double min)
          surf_network_model->states.running_action_set;
 
        //get the first relevant value from the running_actions list
          surf_network_model->states.running_action_set;
 
        //get the first relevant value from the running_actions list
-       if (!xbt_swag_size(running_actions))
-       return -1.0;
+       if (!xbt_swag_size(running_actions) || min == 0.0)
+         return -1.0;
+       else
+        do {
+          ns3_simulator(min);
+          time_to_next_flow_completion = ns3_time() - surf_get_clock();
+        } while(time_to_next_flow_completion==0.0);
+
+       XBT_DEBUG("min       : %f",min);
+       XBT_DEBUG("ns3  time : %f",ns3_time());
+       XBT_DEBUG("surf time : %f",surf_get_clock());
+       XBT_DEBUG("Next completion %f :",time_to_next_flow_completion);
 
 
-       ns3_simulator(min);
-       time_to_next_flow_completion = ns3_time() - surf_get_clock();
-
-//     XBT_INFO("min       : %f",min);
-//     XBT_INFO("ns3  time : %f",ns3_time());
-//     XBT_INFO("surf time : %f",surf_get_clock());
-
-       xbt_assert(time_to_next_flow_completion,
-                         "Time to next flow completion not initialized!\n");
-
-       XBT_DEBUG("ns3_share_resources return %f",time_to_next_flow_completion);
        return time_to_next_flow_completion;
 }
 
        return time_to_next_flow_completion;
 }