FdNetDevice working with PlanetLab TAPs
[nepi.git] / src / nepi / resources / linux / ns3 / fdtunnel.py
index a934e8d..e968ea3 100644 (file)
@@ -185,17 +185,16 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel):
 
         # execute the tunnel creation script
         node = self.endpoint_node(remote_endpoint) 
-        remote_ip = node.get("ip")
-        port = self.initiate(endpoint, address, remote_ip, cipher, 
+        port = self.initiate(endpoint, remote_endpoint, address, cipher, 
                 cipher_key, bwlimit, txqueuelen)
 
         return port
 
     def establish_connection(self, endpoint, remote_endpoint, port):
-        self.establish(remote_endpoint, port)
+        self.establish(endpoint, remote_endpoint, port)
 
     def verify_connection(self, endpoint, remote_endpoint):
-        self.verify()
+        self.verify(endpoint)
 
     def terminate_connection(self, endpoint, remote_endpoint):
         # Nothing to do
@@ -267,10 +266,11 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel):
 
         return result
 
-    def initiate(self, endpoint, address, remote_ip, cipher, cipher_key, 
+    def initiate(self, endpoint, remote_endpoint, address, cipher, cipher_key, 
             bwlimit, txqueuelen):
-        command = self._initiate_command(endpoint, address, remote_ip, 
-                cipher, cipher_key, bwlimit, txqueuelen)
+
+        command = self._initiate_command(endpoint, remote_endpoint, 
+                address, cipher, cipher_key, bwlimit, txqueuelen)
 
         node = self.endpoint_node(endpoint) 
         run_home = self.run_home(endpoint)
@@ -310,15 +310,19 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel):
 
         return port
 
-    def _initiate_command(self, endpoint, address, remote_ip, 
+    def _initiate_command(self, endpoint, remote_endpoint, address,
             cipher, cipher_key, bwlimit, txqueuelen):
-        node = self.endpoint_node(endpoint) 
-        run_home = self.run_home(endpoint)
-        app_home = self.app_home(endpoint)
+        local_node = self.endpoint_node(endpoint) 
+        local_run_home = self.run_home(endpoint)
+        local_app_home = self.app_home(endpoint)
+        remote_node = self.endpoint_node(remote_endpoint) 
+
+        local_ip = local_node.get("ip")
+        remote_ip = remote_node.get("ip")
 
-        local_port_file = os.path.join(run_home, "local_port")
-        remote_port_file = os.path.join(run_home,  "remote_port")
-        ret_file = os.path.join(run_home, "ret_file")
+        local_port_file = os.path.join(local_run_home, "local_port")
+        remote_port_file = os.path.join(local_run_home,  "remote_port")
+        ret_file = os.path.join(local_run_home, "ret_file")
 
         address = base64.b64encode(address)
         
@@ -327,9 +331,10 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel):
         command.append("PYTHONPATH=$PYTHONPATH:${SRC}")
         command.append("python ${SRC}/linux-ns3-fd-udp-connect.py")
         command.append("-a %s" % address)
-        command.append("-l %s " % local_port_file)
-        command.append("-r %s " % remote_port_file)
-        command.append("-H %s " % remote_ip)
+        command.append("-p %s " % local_port_file)
+        command.append("-P %s " % remote_port_file)
+        command.append("-o %s " % local_ip)
+        command.append("-O %s " % remote_ip)
         command.append("-R %s " % ret_file)
         if cipher:
             command.append("-c %s " % cipher)
@@ -341,12 +346,12 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel):
             command.append("-b %s " % bwlimit)
 
         command = " ".join(command)
-        command = self.replace_paths(command, node=node, app_home=app_home, 
-                run_home=run_home)
+        command = self.replace_paths(command, node=local_node, 
+                app_home=local_app_home, run_home=local_run_home)
 
         return command
 
-    def establish(self, remote_endpoint, port):
+    def establish(self, endpoint, remote_endpoint, port):
         node = self.endpoint_node(endpoint) 
         run_home = self.run_home(endpoint)
 
@@ -357,6 +362,6 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel):
                 text = True, 
                 overwrite = False)
 
-    def verify(self):
-        self.wait_result()
+    def verify(self, endpoint):
+        self.wait_result(endpoint)