bug fix: work arround to the problem of RealtimeSimulatorImpl not finishing with...
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Tue, 31 May 2011 16:36:35 +0000 (18:36 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Tue, 31 May 2011 16:36:35 +0000 (18:36 +0200)
examples/vlc_wireless_netns_ns3.py
src/nepi/testbeds/netns/execute.py
src/nepi/testbeds/netns/metadata_v01.py
src/nepi/testbeds/ns3/execute.py

index 066e1c3..5c78868 100644 (file)
@@ -152,7 +152,7 @@ class VlcWirelessNetnsNs3Example(object):
         netns_provider = FactoriesProvider(testbed_id, testbed_version)
         netns_desc1 = exp_desc.add_testbed_description(netns_provider)
         netns_desc1.set_attribute_value("homeDirectory", self.root_dir)
-        #netns_desc1.set_attribute_value("enableDebug", True
+        #netns_desc1.set_attribute_value("enableDebug", True)
         # create node 3
         node3 = netns_desc1.create("Node")
         node3.set_attribute_value("forward_X11", True)
@@ -161,7 +161,7 @@ class VlcWirelessNetnsNs3Example(object):
         # create vlc server
         # DEBUG!! target = "{#[vlc_client].addr[0].[Address]#}"
         target = "10.0.2.2" 
-        command = "vlc -I dummy -vvv %s --sout '#rtp{dst=%s,port=5004,mux=ts}' vlc://quit" \
+        command = "vlc -I dummy %s --sout '#rtp{dst=%s,port=5004,mux=ts}' vlc://quit" \
                 % (self.movie, target)
         vlc_server = netns_desc1.create("Application")
         vlc_server.set_attribute_value("command", command)
@@ -212,7 +212,8 @@ class VlcWirelessNetnsNs3Example(object):
         xml = exp_desc.to_xml()
         controller = ExperimentController(xml, self.root_dir)
         controller.start()
-        while not controller.is_finished(vlc_server.guid):
+        while not controller.is_finished(vlc_server.guid) and \
+                not controller.is_finished(vlc_client.guid):
             time.sleep(0.5)
         controller.stop()
         controller.shutdown()
index db99bed..2ec1a72 100644 (file)
@@ -55,11 +55,14 @@ class TestbedController(testbed_impl.TestbedController):
     def shutdown(self):
         for trace in self._traces.values():
             trace.close()
-        for element in self._elements.values():
+        for guid, element in self._elements.iteritems():
             if isinstance(element, self.TunChannel):
                 element.Cleanup()
             else:
-                element.destroy()
+                factory_id = self._create[guid]
+                if factory_id == "Node":
+                    element.destroy()
+        self._elements.clear()
 
     def trace_filename(self, guid, trace_id):
         # TODO: Need to be defined inside a home!!!! with and experiment id_code
index 2f0472b..9c2ee37 100644 (file)
@@ -75,7 +75,6 @@ def connect_tunchannel_tap(testbed_instance, chan_guid, tap_guid):
         pass
     chan.with_pi = with_pi
 
-
 ### Creation functions ###
 
 def create_node(testbed_instance, guid):
@@ -197,7 +196,6 @@ def configure_node(testbed_instance, guid):
         (destination, netprefix, nexthop) = route
         element.add_route(prefix = destination, prefix_len = netprefix,
             nexthop = nexthop)
-    
 
 ### Factory information ###
 
index 15a8c26..1e5a8b9 100644 (file)
@@ -55,13 +55,12 @@ class TestbedController(testbed_impl.TestbedController):
         self._condition = threading.Condition()
         self._simulator_thread = threading.Thread(target = self._simulator_run,
                 args = [self._condition])
-        self._simulator_thread.isDaemon()
+        self._simulator_thread.setDaemon(True)
         self._simulator_thread.start()
 
     def stop(self, time = TIME_NOW):
         super(TestbedController, self).stop(time)
-        # BUG!!!!
-        # TODO!! This is not working!!!
+        # BUG!!!! RealtimeSimulatorImpl never stops simulation with Stop()!!!
         self.ns3.Simulator.Stop()
         #self._stop_simulation(time)
 
@@ -135,13 +134,13 @@ class TestbedController(testbed_impl.TestbedController):
         self._elements.clear()
         if self.ns3:
             self.ns3.Simulator.Stop()
-            # BUG!!!!
-            # TODO!! This is not working!!! NEVER STOPS THE SIMULATION!!!
-            #self._stop_simulation("0s")
-            #if self._simulator_thread:
+            ##################################################
+            # BUG!!!! RealtimeSimulatorImpl never stops simulation with Stop()!!!
+            # self._stop_simulation("0s")
+            # if self._simulator_thread:
             #    print "Joining thread"
             #    self._simulator_thread.join()
-            #print "destroying"
+            #################################################
             self.ns3.Simulator.Destroy()
         self._ns3 = None
         sys.stdout.flush()