ns-3 simulator synchronizing start
[nepi.git] / src / nepi / resources / linux / ns3 / ns3simulation.py
index 308b777..94029a1 100644 (file)
@@ -97,6 +97,7 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation):
 
         pybindgen_version = Attribute("pybindgenVersion",
             "Version of pybindgen to install from bazar repo",
+            #default = "864", 
             default = "868", 
             flags = Flags.Design)
 
@@ -274,7 +275,22 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation):
             if self.get("populateRoutingTables") == True:
                 self.invoke(IPV4_GLOBAL_ROUTING_HELPER_UUID, "PopulateRoutingTables")
 
-            self._client.start() 
+            self._client.start()
+
+            # Wait until the Simulation starts...
+            is_running = False
+            for i in xrange(100):
+                is_running = self.invoke(SIMULATOR_UUID, "isRunning")
+            
+                if is_running:
+                    break
+                else:
+                    time.sleep(1)
+            else:
+                if not is_running:
+                    msg = " Simulation did not start"
+                    self.error(msg)
+                    raise RuntimeError
 
             self.set_started()
         else:
@@ -407,7 +423,6 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation):
                             'dce_repo': self.dce_repo
                          }
 
-
         return (
                 # NS3 installation
                 "( "
@@ -484,6 +499,7 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation):
                         " (   "
                          # If not, copy ns-3 build to bin
                         "  cd ${SRC}/dce/ns-3-dce && "
+                        "  rm -rf ${SRC}/dce/ns-3-dce/build && "
                         "  ./waf configure %(enable_opt)s --with-pybindgen=${SRC}/pybindgen/%(pybindgen_version)s "
                         "  --prefix=%(ns3_build_home)s --with-ns3=%(ns3_build_home)s && "
                         "  ./waf build && "
@@ -511,6 +527,7 @@ class LinuxNS3Simulation(LinuxApplication, NS3Simulation):
                  # If not, copy ns-3 build to bin
                 "  mkdir -p %(ns3_build_home)s && "
                 "  cd ${SRC}/ns-3/%(ns3_version)s && "
+                "  rm -rf ${SRC}/ns-3/%(ns3_version)s/build && "
                 "  ./waf configure -d %(build_mode)s --with-pybindgen=${SRC}/pybindgen/%(pybindgen_version)s "
                 "  --prefix=%(ns3_build_home)s && "
                 "  ./waf build && "