From fcd1c3103783d4f8525eac715374c1d955649af7 Mon Sep 17 00:00:00 2001 From: Alina Quereilhac Date: Wed, 21 Jan 2015 01:47:09 +0100 Subject: [PATCH] Tunnel between 2 ns-3s in remote PL hosts --- .../ns3/{p2pfdudptunnel.py => fdudptunnel.py} | 26 +- .../scripts/fd-udp-connect.py} | 31 +- .../linux/scripts/linux-ns3-fd-udp-connect.py | 170 -------- .../resources/planetlab/ns3/fdudptunnel.py | 75 ++++ .../resources/planetlab/ns3/p2pfdudptunnel.py | 379 ------------------ .../ns3/cross_ns3_planetlab_fdtunnel_ping.py | 2 +- 6 files changed, 114 insertions(+), 569 deletions(-) rename src/nepi/resources/linux/ns3/{p2pfdudptunnel.py => fdudptunnel.py} (95%) rename src/nepi/resources/{planetlab/scripts/pl-fd-udp-connect.py => linux/scripts/fd-udp-connect.py} (82%) delete mode 100644 src/nepi/resources/linux/scripts/linux-ns3-fd-udp-connect.py create mode 100644 src/nepi/resources/planetlab/ns3/fdudptunnel.py delete mode 100644 src/nepi/resources/planetlab/ns3/p2pfdudptunnel.py diff --git a/src/nepi/resources/linux/ns3/p2pfdudptunnel.py b/src/nepi/resources/linux/ns3/fdudptunnel.py similarity index 95% rename from src/nepi/resources/linux/ns3/p2pfdudptunnel.py rename to src/nepi/resources/linux/ns3/fdudptunnel.py index 72662b15..7183325b 100644 --- a/src/nepi/resources/linux/ns3/p2pfdudptunnel.py +++ b/src/nepi/resources/linux/ns3/fdudptunnel.py @@ -76,10 +76,11 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel): self._fd1node = None self._fd2 = None self._fd2node = None + self._pi = False def log_message(self, msg): self.get_endpoints() - return " guid %d - fd-udptunnel %s - %s - %s " % (self.guid, + return " guid %d - %s - %s - %s " % (self.guid, self.node1.get("hostname"), self.node2.get("hostname"), msg) @@ -116,6 +117,10 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel): return [self._fd1, self._fd2] + @property + def pi(self): + return self._pi + @property def endpoint1(self): return self._fd1 @@ -155,7 +160,7 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel): linux_passfd = os.path.join(os.path.dirname(__file__), "..", "scripts", - "linux-ns3-fd-udp-connect.py") + "fd-udp-connect.py") scripts.append(linux_passfd) @@ -337,15 +342,18 @@ class LinuxNs3FdUdpTunnel(LinuxUdpTunnel): command = [""] command.append("PYTHONPATH=$PYTHONPATH:${SRC}") - command.append("python ${SRC}/linux-ns3-fd-udp-connect.py") + command.append("python ${SRC}/fd-udp-connect.py") command.append("-a %s" % address) - 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) + 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) + command.append("-t %s" % "IFF_TAP") + if self.pi: + command.append("-n") if cipher: - command.append("-c %s " % cipher) + command.append("-c %s" % cipher) if cipher_key: command.append("-k %s " % cipher_key) if txqueuelen: diff --git a/src/nepi/resources/planetlab/scripts/pl-fd-udp-connect.py b/src/nepi/resources/linux/scripts/fd-udp-connect.py similarity index 82% rename from src/nepi/resources/planetlab/scripts/pl-fd-udp-connect.py rename to src/nepi/resources/linux/scripts/fd-udp-connect.py index b576813f..83bd845b 100644 --- a/src/nepi/resources/planetlab/scripts/pl-fd-udp-connect.py +++ b/src/nepi/resources/linux/scripts/fd-udp-connect.py @@ -43,15 +43,20 @@ def _resume(sig,frame): signal.signal(signal.SIGUSR2, _resume) def get_options(): - usage = ("usage: %prog -a
-b -c " - "- k -q -p " - "-P -o -O " - "-r ") + usage = ("usage: %prog -a
-t -n " + "-b -c -k " + "-q -p -P " + "-o -O -r ") parser = OptionParser(usage = usage) parser.add_option("-a", "--address", dest="address", help="Socket address to send file descriptor to", type="str") + parser.add_option("-t", "--vif-type", dest="vif_type", + help="Virtual interface type. Either IFF_TAP or IFF_TUN. " + "Defaults to IFF_TAP. ", default=IFF_TAP, type="str") + parser.add_option("-n", "--pi", dest="pi", action="store_true", + default=False, help="Enable PI header") parser.add_option("-b", "--bwlimit", dest="bwlimit", help="Specifies the interface's emulated bandwidth in bytes ", @@ -84,18 +89,24 @@ def get_options(): default = "ret_file", type="str") (options, args) = parser.parse_args() - + + vif_type = IFF_TAP + if options.vif_type and options.vif_type == "IFF_TUN": + vif_type = IFF_TUN + address = base64.b64decode(options.address) - return (address, options.local_port_file, options.remote_port_file, + return (address, vif_type, options.pi, + options.local_port_file, options.remote_port_file, options.local_ip, options.remote_ip, options.ret_file, options.bwlimit, options.cipher, options.cipher_key, options.txqueuelen) if __name__ == '__main__': - (address, local_port_file, remote_port_file, local_ip, remote_ip, - ret_file, bwlimit, cipher, cipher_key, txqueuelen) = get_options() + (address, vif_type, pi, local_port_file, remote_port_file, + local_ip, remote_ip, ret_file, bwlimit, cipher, cipher_key, + txqueuelen) = get_options() # Create a local socket to stablish the tunnel connection rsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0) @@ -154,8 +165,8 @@ if __name__ == '__main__': # Establish tunnel tunchannel.tun_fwd(tun, remote, - with_pi = True, # No PI headers - ether_mode = IFF_TAP, # Ns-3 generates ethernet pkts + with_pi = pi, + ether_mode = (vif_type == IFF_TAP), udp = True, cipher_key = cipher_key, cipher = cipher, diff --git a/src/nepi/resources/linux/scripts/linux-ns3-fd-udp-connect.py b/src/nepi/resources/linux/scripts/linux-ns3-fd-udp-connect.py deleted file mode 100644 index c1141221..00000000 --- a/src/nepi/resources/linux/scripts/linux-ns3-fd-udp-connect.py +++ /dev/null @@ -1,170 +0,0 @@ -import base64 -import errno -import os -import passfd -import signal -import socket -import time -import tunchannel - -from optparse import OptionParser - -IFF_TAP = 0x0002 - -# Trak SIGTERM, and set global termination flag instead of dying -TERMINATE = [] -STARTED = False - -def _finalize(sig,frame): - global TERMINATE - global STARTED - - if STARTED: - TERMINATE.append(None) - else: - signal.signal(signal.SIGTERM, signal.SIG_DFL) - os.kill(os.getpid(), signal.SIGTERM) - -signal.signal(signal.SIGTERM, _finalize) - -# SIGUSR1 suspends forwading, SIGUSR2 resumes forwarding -SUSPEND = [] -def _suspend(sig,frame): - global SUSPEND - if not SUSPEND: - SUSPEND.append(None) -signal.signal(signal.SIGUSR1, _suspend) - -def _resume(sig,frame): - global SUSPEND - if SUSPEND: - SUSPEND.remove(None) -signal.signal(signal.SIGUSR2, _resume) - -def get_options(): - usage = ("usage: %prog -a
-b -c " - "- k -q -p " - "-P -o -O " - "-r ") - - parser = OptionParser(usage = usage) - - parser.add_option("-a", "--address", dest="address", - help="Socket address to send file descriptor to", type="str") - - parser.add_option("-b", "--bwlimit", dest="bwlimit", - help="Specifies the interface's emulated bandwidth in bytes ", - default=None, type="int") - parser.add_option("-q", "--txqueuelen", dest="txqueuelen", - help="Specifies the interface's transmission queue length. ", - default=1000, type="int") - parser.add_option("-c", "--cipher", dest="cipher", - help="Cipher to encript communication. " - "One of PLAIN, AES, Blowfish, DES, DES3. ", - default=None, type="str") - parser.add_option("-k", "--cipher-key", dest="cipher_key", - help="Specify a symmetric encryption key with which to protect " - "packets across the tunnel. python-crypto must be installed " - "on the system." , - default=None, type="str") - - parser.add_option("-p", "--local-port-file", dest="local_port_file", - help = "File where to store the local binded UDP port number ", - default = "local_port_file", type="str") - parser.add_option("-P", "--remote-port-file", dest="remote_port_file", - help = "File where to read the remote UDP port number to connect to", - default = "remote_port_file", type="str") - parser.add_option("-o", "--local-ip", dest="local_ip", - help = "Local host IP", type="str") - parser.add_option("-O", "--remote-ip", dest="remote_ip", - help = "Remote host IP", type="str") - parser.add_option("-R", "--ret-file", dest="ret_file", - help = "File where to store return code (success of connection) ", - default = "ret_file", type="str") - - (options, args) = parser.parse_args() - - address = base64.b64decode(options.address) - - return (address, options.local_port_file, options.remote_port_file, - options.local_ip, options.remote_ip, options.ret_file, - options.bwlimit, options.cipher, options.cipher_key, - options.txqueuelen) - -if __name__ == '__main__': - - (address, local_port_file, remote_port_file, local_ip, remote_ip, - ret_file, bwlimit, cipher, cipher_key, txqueuelen) = get_options() - - # Create a local socket to stablish the tunnel connection - rsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0) - rsock.bind((local_ip, 0)) - (local_host, local_port) = rsock.getsockname() - - # Save local port information to file - f = open(local_port_file, 'w') - f.write("%d\n" % local_port) - f.close() - - # Wait until remote port information is available - while not os.path.exists(remote_port_file): - time.sleep(2) - - remote_port = '' - # Read remote port from file - # Try until something is read... - # xxx: There seems to be a weird behavior where - # even if the file exists and had the port number, - # the read operation returns empty string! - # Maybe a race condition? - for i in xrange(10): - f = open(remote_port_file, 'r') - remote_port = f.read() - f.close() - - if remote_port: - break - - time.sleep(2) - - remote_port = remote_port.strip() - remote_port = int(remote_port) - - # Connect local socket to remote port - rsock.connect((remote_ip, remote_port)) - remote = os.fdopen(rsock.fileno(), 'r+b', 0) - - # create local socket to pass to fd-net-device - lsock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - lsock.bind("") - lsock.getsockname() - local = os.fdopen(lsock.fileno(), 'r+b', 0) - - # pass local socket to fd-net-device - sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) - sock.connect(address) - passfd.sendfd(sock, local, '0') - - # TODO: Test connectivity! - - # Create a ret_file to indicate success - f = open(ret_file, 'w') - f.write("0") - f.close() - - STARTED = True - - # Establish tunnel - tunchannel.tun_fwd(local, remote, - with_pi = False, # No PI headers - ether_mode = IFF_TAP, # Ns-3 generates ethernet pkts - udp = True, - cipher_key = cipher_key, - cipher = cipher, - TERMINATE = TERMINATE, - SUSPEND = SUSPEND, - tunqueue = txqueuelen, - tunkqueue = 500, - bwlimit = bwlimit - ) - diff --git a/src/nepi/resources/planetlab/ns3/fdudptunnel.py b/src/nepi/resources/planetlab/ns3/fdudptunnel.py new file mode 100644 index 00000000..0ce26f80 --- /dev/null +++ b/src/nepi/resources/planetlab/ns3/fdudptunnel.py @@ -0,0 +1,75 @@ +# +# NEPI, a framework to manage network experiments +# Copyright (C) 2013 INRIA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Author: Alina Quereilhac + +from nepi.execution.attribute import Attribute, Flags, Types +from nepi.execution.resource import clsinit_copy, ResourceState +from nepi.resources.linux.ns3.fdudptunnel import LinuxNs3FdUdpTunnel +from nepi.util.sshfuncs import ProcStatus +from nepi.util.timefuncs import tnow, tdiffsec + +import base64 +import os +import socket +import time + +@clsinit_copy +class PlanetlabNs3FdUdpTunnel(LinuxNs3FdUdpTunnel): + _rtype = "planetlab::ns3::FdUdpTunnel" + _help = "Constructs a tunnel between two Ns-3 FdNetdevices " \ + "located in remote PlanetLab nodes using a UDP connection " + _platform = "planetlab::ns3" + + def get_endpoints(self): + """ Returns the list of RM that are endpoints to the tunnel + """ + if not self._fd2 or not self._fd1: + from nepi.resources.ns3.ns3fdnetdevice import NS3BaseFdNetDevice + devices = self.get_connected(NS3BaseFdNetDevice.get_rtype()) + if not devices or len(devices) != 2: + msg = "Tunnel must be connected to exactly two FdNetDevices" + self.error(msg) + raise RuntimeError, msg + + self._fd1 = devices[0] + self._fd2 = devices[1] + self._pi = True + + # Set PI headers on + self._fd1.set("EncapsulationMode", "DixPi") + self._fd2.set("EncapsulationMode", "DixPi") + + simu = self._fd1.simulation + from nepi.resources.linux.node import LinuxNode + nodes = simu.get_connected(LinuxNode.get_rtype()) + self._fd1node = nodes[0] + + simu = self._fd2.simulation + from nepi.resources.linux.node import LinuxNode + nodes = simu.get_connected(LinuxNode.get_rtype()) + self._fd2node = nodes[0] + + if self._fd1node.get("hostname") == \ + self._fd2node.get("hostname"): + msg = "Tunnel requires endpoints on different hosts" + self.error(msg) + raise RuntimeError, msg + + return [self._fd1, self._fd2] + + diff --git a/src/nepi/resources/planetlab/ns3/p2pfdudptunnel.py b/src/nepi/resources/planetlab/ns3/p2pfdudptunnel.py deleted file mode 100644 index 5e63b0dc..00000000 --- a/src/nepi/resources/planetlab/ns3/p2pfdudptunnel.py +++ /dev/null @@ -1,379 +0,0 @@ -# -# NEPI, a framework to manage network experiments -# Copyright (C) 2013 INRIA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Author: Alina Quereilhac - -from nepi.execution.attribute import Attribute, Flags, Types -from nepi.execution.resource import clsinit_copy, ResourceState -from nepi.resources.linux.ns3.p2pfdudptunnel import LinuxNs3P2PFdUdpTunnel -from nepi.util.sshfuncs import ProcStatus -from nepi.util.timefuncs import tnow, tdiffsec - -import base64 -import os -import socket -import time - -@clsinit_copy -class PlanetlabNs3P2PFdUdpTunnel(LinuxUdpTunnel): - _rtype = "planetlab::ns3::P2PFdUdpTunnel" - _help = "Constructs a tunnel between two Ns-3 FdNetdevices " \ - "located in remote PlanetLab nodes using a UDP connection " - _platform = "planetlab::ns3" - - @classmethod - def _register_attributes(cls): - cipher = Attribute("cipher", - "Cipher to encript communication. " - "One of PLAIN, AES, Blowfish, DES, DES3. ", - default = None, - allowed = ["PLAIN", "AES", "Blowfish", "DES", "DES3"], - type = Types.Enumerate, - flags = Flags.Design) - - cipher_key = Attribute("cipherKey", - "Specify a symmetric encryption key with which to protect " - "packets across the tunnel. python-crypto must be installed " - "on the system." , - flags = Flags.Design) - - txqueuelen = Attribute("txQueueLen", - "Specifies the interface's transmission queue length. " - "Defaults to 1000. ", - type = Types.Integer, - flags = Flags.Design) - - bwlimit = Attribute("bwLimit", - "Specifies the interface's emulated bandwidth in bytes " - "per second.", - type = Types.Integer, - flags = Flags.Design) - - cls._register_attribute(cipher) - cls._register_attribute(cipher_key) - cls._register_attribute(txqueuelen) - cls._register_attribute(bwlimit) - - def __init__(self, ec, guid): - super(PlanetlabNs3P2PFdUdpTunnel, self).__init__(ec, guid) - self._home = "p2p-fd-udp-tunnel-%s" % self.guid - self._pids = dict() - self._fd1 = None - self._fd1node = None - self._fd2 = None - self._fd2node = None - - def log_message(self, msg): - self.get_endpoints() - return " guid %d - PlanetlabNs3P2PFdUdpTunnel - %s - %s - %s " % (self.guid, - self.node1.get("hostname"), - self.node2.get("hostname"), - msg) - - def get_endpoints(self): - """ Returns the list of RM that are endpoints to the tunnel - """ - if not self._fd2 or not self._fd1: - from nepi.resources.ns3.ns3fdnetdevice import NS3BaseFdNetDevice - devices = self.get_connected(NS3BaseFdNetDevice.get_rtype()) - if not devices or len(devices) != 2: - msg = "Tunnel must be connected to exactly two FdNetDevices" - self.error(msg) - raise RuntimeError, msg - - self._fd1 = devices[0] - self._fd2 = devices[1] - - # Set PI headers on - self._fd1.set("EncapsulationMode", "DixPi") - self._fd2.set("EncapsulationMode", "DixPi") - - simu = self._fd1.simulation - from nepi.resources.linux.node import LinuxNode - nodes = simu.get_connected(LinuxNode.get_rtype()) - self._fd1node = nodes[0] - - simu = self._fd2.simulation - from nepi.resources.linux.node import LinuxNode - nodes = simu.get_connected(LinuxNode.get_rtype()) - self._fd2node = nodes[0] - - if self._fd1node.get("hostname") == \ - self._fd2node.get("hostname"): - msg = "Tunnel requires endpoints on different hosts" - self.error(msg) - raise RuntimeError, msg - - return [self._fd1, self._fd2] - - @property - def endpoint1(self): - return self._fd1 - - @property - def endpoint2(self): - return self._fd2 - - @property - def node1(self): - return self._fd1node - - @property - def node2(self): - return self._fd2node - - def endpoint_node(self, endpoint): - node = None - if endpoint == self.endpoint1: - node = self.node1 - else: - node = self.node2 - - return node - - def app_home(self, endpoint): - node = self.endpoint_node(endpoint) - return os.path.join(node.exp_home, self._home) - - def run_home(self, endpoint): - return os.path.join(self.app_home(endpoint), self.ec.run_id) - - def upload_sources(self, endpoint): - scripts = [] - - # vif-passfd python script - fd_udp_connect = os.path.join(os.path.dirname(__file__), - "..", - "scripts", - "pl-fd-udp-connect.py") - - scripts.append(fd_udp_connect) - - # tunnel creation python script - tunchannel = os.path.join(os.path.dirname(__file__), - "..", "..", "linux", - "scripts", - "tunchannel.py") - - scripts.append(tunchannel) - - # Upload scripts - scripts = ";".join(scripts) - - node = self.endpoint_node(endpoint) - node.upload(scripts, - os.path.join(node.src_dir), - overwrite = False) - - def endpoint_mkdir(self, endpoint): - node = self.endpoint_node(endpoint) - run_home = self.run_home(endpoint) - node.mkdir(run_home) - - def initiate_connection(self, endpoint, remote_endpoint): - cipher = self.get("cipher") - cipher_key = self.get("cipherKey") - bwlimit = self.get("bwLimit") - txqueuelen = self.get("txQueueLen") - - # Upload the tunnel creating script - self.upload_sources(endpoint) - - # Request an address to send the file descriptor to the ns-3 simulation - address = endpoint.recv_fd() - - # execute the tunnel creation script - node = self.endpoint_node(remote_endpoint) - port = self.initiate(endpoint, remote_endpoint, address, cipher, - cipher_key, bwlimit, txqueuelen) - - return port - - def establish_connection(self, endpoint, remote_endpoint, port): - self.establish(endpoint, remote_endpoint, port) - - def verify_connection(self, endpoint, remote_endpoint): - self.verify(endpoint) - - def terminate_connection(self, endpoint, remote_endpoint): - # Nothing to do - return - - def check_state_connection(self): - # Make sure the process is still running in background - # No execution errors occurred. Make sure the background - # process with the recorded pid is still running. - - node1 = self.endpoint_node(self.endpoint1) - node2 = self.endpoint_node(self.endpoint2) - run_home1 = self.run_home(self.endpoint1) - run_home2 = self.run_home(self.endpoint1) - (pid1, ppid1) = self._pids[endpoint1] - (pid2, ppid2) = self._pids[endpoint2] - - status1 = node1.status(pid1, ppid1) - status2 = node2.status(pid2, ppid2) - - if status1 == ProcStatus.FINISHED and \ - status2 == ProcStatus.FINISHED: - - # check if execution errors occurred - (out1, err1), proc1 = node1.check_errors(run_home1) - (out2, err2), proc2 = node2.check_errors(run_home2) - - if err1 or err2: - msg = "Error occurred in tunnel" - self.error(msg, err1, err2) - self.fail() - else: - self.set_stopped() - - def wait_local_port(self, endpoint): - """ Waits until the local_port file for the endpoint is generated, - and returns the port number - - """ - return self.wait_file(endpoint, "local_port") - - def wait_result(self, endpoint): - """ Waits until the return code file for the endpoint is generated - - """ - return self.wait_file(endpoint, "ret_file") - - def wait_file(self, endpoint, filename): - """ Waits until file on endpoint is generated """ - result = None - delay = 1.0 - - node = self.endpoint_node(endpoint) - run_home = self.run_home(endpoint) - - for i in xrange(20): - (out, err), proc = node.check_output(run_home, filename) - - if out: - result = out.strip() - break - else: - time.sleep(delay) - delay = delay * 1.5 - else: - msg = "Couldn't retrieve %s" % filename - self.error(msg, out, err) - raise RuntimeError, msg - - return result - - def initiate(self, endpoint, remote_endpoint, address, 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) - app_home = self.app_home(endpoint) - - # upload command to connect.sh script - shfile = os.path.join(app_home, "fd-udp-connect.sh") - node.upload_command(command, - shfile = shfile, - overwrite = False) - - # invoke connect script - cmd = "bash %s" % shfile - (out, err), proc = node.run(cmd, run_home) - - # check if execution errors occurred - msg = "Failed to connect endpoints " - - if proc.poll(): - self.error(msg, out, err) - raise RuntimeError, msg - - # Wait for pid file to be generated - pid, ppid = node.wait_pid(run_home) - - self._pids[endpoint] = (pid, ppid) - - # Check for error information on the remote machine - (out, err), proc = node.check_errors(run_home) - # Out is what was written in the stderr file - if err: - msg = " Failed to start command '%s' " % command - self.error(msg, out, err) - raise RuntimeError, msg - - port = self.wait_local_port(endpoint) - - return port - - def _initiate_command(self, endpoint, remote_endpoint, address, - cipher, cipher_key, bwlimit, txqueuelen): - 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(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) - - command = [""] - command.append("PYTHONPATH=$PYTHONPATH:${SRC}") - command.append("python ${SRC}/pl-fd-udp-connect.py") - command.append("-a %s" % address) - 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) - if cipher_key: - command.append("-k %s " % cipher_key) - if txqueuelen: - command.append("-q %s " % txqueuelen) - if bwlimit: - command.append("-b %s " % bwlimit) - - command = " ".join(command) - command = self.replace_paths(command, node=local_node, - app_home=local_app_home, run_home=local_run_home) - - return command - - def establish(self, endpoint, remote_endpoint, port): - node = self.endpoint_node(endpoint) - run_home = self.run_home(endpoint) - - # upload remote port number to file - remote_port = "%s\n" % port - node.upload(remote_port, - os.path.join(run_home, "remote_port"), - text = True, - overwrite = False) - - def verify(self, endpoint): - self.wait_result(endpoint) - diff --git a/test/resources/planetlab/ns3/cross_ns3_planetlab_fdtunnel_ping.py b/test/resources/planetlab/ns3/cross_ns3_planetlab_fdtunnel_ping.py index 0c05952a..fb7c54c3 100755 --- a/test/resources/planetlab/ns3/cross_ns3_planetlab_fdtunnel_ping.py +++ b/test/resources/planetlab/ns3/cross_ns3_planetlab_fdtunnel_ping.py @@ -122,7 +122,7 @@ class LinuxNS3FdNetDeviceTest(unittest.TestCase): ec.set(fddev2, "prefix", "30") ec.register_connection(nsnode2, fddev2) - tunnel = ec.register_resource("planetlab::ns3::P2PFdUdpTunnel") + tunnel = ec.register_resource("planetlab::ns3::FdUdpTunnel") ec.register_connection(tunnel, fddev1) ec.register_connection(tunnel, fddev2) -- 2.43.0