Synchronization fix for cross connections: wait for tunnels to be up before starting...
authorClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Tue, 10 May 2011 12:58:32 +0000 (14:58 +0200)
committerClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Tue, 10 May 2011 12:58:32 +0000 (14:58 +0200)
src/nepi/testbeds/planetlab/interfaces.py
src/nepi/testbeds/planetlab/metadata_v01.py
src/nepi/testbeds/planetlab/scripts/tun_connect.py
src/nepi/testbeds/planetlab/tunproto.py
test/testbeds/planetlab/integration_ns3.py

index 47e9585..127b8a8 100644 (file)
@@ -196,6 +196,10 @@ class TunIface(object):
             self.peer_proto_impl.shutdown()
             self.peer_proto_impl = None
 
+    def async_launch_wait(self):
+        if self.peer_proto_impl:
+            self.peer_proto_impl.async_launch_wait()
+
     def sync_trace(self, local_dir, whichtrace):
         if self.peer_proto_impl:
             return self.peer_proto_impl.sync_trace(local_dir, whichtrace)
index e1ffe08..79d1956 100644 (file)
@@ -336,6 +336,12 @@ def postconfigure_tuniface(testbed_instance, guid):
     # Second-phase setup
     element.setup()
     
+def wait_tuniface(testbed_instance, guid):
+    element = testbed_instance._elements[guid]
+    
+    # Second-phase setup
+    element.async_launch_wait()
+    
 
 def configure_node(testbed_instance, guid):
     node = testbed_instance._elements[guid]
@@ -925,6 +931,7 @@ factories_info = dict({
             "create_function": create_tuniface,
             "preconfigure_function": preconfigure_tuniface,
             "configure_function": postconfigure_tuniface,
+            "start_function": wait_tuniface,
             "box_attributes": [
                 "up", "device_name", "mtu", "snat",
                 "txqueuelen",
@@ -940,6 +947,7 @@ factories_info = dict({
             "create_function": create_tapiface,
             "preconfigure_function": preconfigure_tuniface,
             "configure_function": postconfigure_tuniface,
+            "start_function": wait_tuniface,
             "box_attributes": [
                 "up", "device_name", "mtu", "snat",
                 "txqueuelen",
index 9918fc3..01f32af 100644 (file)
@@ -16,6 +16,9 @@ import functools
 import time
 import base64
 
+import time
+print >>sys.stderr, time.time()
+
 tun_name = 'tun0'
 tun_path = '/dev/net/tun'
 hostaddr = socket.gethostbyname(socket.gethostname())
@@ -553,6 +556,7 @@ try:
             sock.connect(options.pass_fd)
         except socket.error:
             # wait a while, retry
+            print >>sys.stderr, "Could not connect. Retrying in a sec..."
             time.sleep(1)
             sock.connect(options.pass_fd)
         passfd.sendfd(sock, tun.fileno(), '0')
@@ -562,6 +566,10 @@ try:
             while True:
                 time.sleep(1)
         remote = None
+        
+        import time
+        print >>sys.stderr, time.time()
+        
     elif options.udp:
         # connect to remote endpoint
         if remaining_args and not remaining_args[0].startswith('-'):
index 411d5e9..6427253 100644 (file)
@@ -379,7 +379,8 @@ class TunProtoTCP(TunProtoBase):
             if peer and peer.peer_proto_impl:
                 peer.peer_proto_impl.async_launch_wait()
             
-            self.launch('tcp', False)
+            if not self._started:
+                self.launch('tcp', False)
         else:
             # make sure WE are ready
             self.async_launch_wait()
index e0969a1..ca7b420 100755 (executable)
@@ -173,7 +173,7 @@ class PlanetLabCrossIntegrationTestCase(unittest.TestCase):
         comp_result = r"""PING .* \(.*\) \d*\(\d*\) bytes of data.
 
 --- .* ping statistics ---
-1 packets transmitted, 1 received, 0% packet loss, time \d*ms.*
+10 packets transmitted, 10 received, 0% packet loss, time \d*ms.*
 """
 
         xml = exp.to_xml()