-def add_node(ec, host, user):
- node = ec.register_resource("LinuxNode")
- ec.set(node, "hostname", host)
- ec.set(node, "username", user)
- ec.set(node, "cleanHome", True)
- ec.set(node, "cleanProcesses", True)
- return node
-
-def add_app(ec, command, node, sudo=None, video=None, depends=None, forward_x11=None, \
- env=None):
- app = ec.register_resource("LinuxApplication")
- if sudo is not None:
- ec.set(app, "sudo", sudo)
- if video is not None:
- ec.set(app, "sources", video)
- if depends is not None:
- ec.set(app, "depends", depends)
- if forward_x11 is not None:
- ec.set(app, "forwardX11", forward_x11)
- if env is not None:
- ec.set(app, "env", env)
- ec.set(app, "command", command)
- ec.register_connection(app, node)
- return app
-
-exp_id = "transfer_file"
-
-# Create the EC
-ec = ExperimentController(exp_id)
-
-# PlanetLab choosen nodes for the experiment, change for PlanetLab nodes in your slice or
-# other linux nodes
-server_name = "planetlab2.ionio.gr"
-client_name = "planetlab2.fri.uni-lj.si"
-
-slicename = "inria_sfatest"
-
-# Location of the video in local machine
-video= "../big_buck_bunny_240p_mpeg4_lq.ts"
-
-# Packets needed for running the experiment
-depends_server = "pv nc tcpdump"
-depends_client = "nc"
-
-# Add resource managers for the linux nodes
-server = add_node(ec, server_name, slicename)
-client = add_node(ec, client_name, slicename)
-
-# Add resource managers for the linux applications
-app_server = add_app(ec, "cat ${SRC}/big_buck_bunny_240p_mpeg4_lq.ts | pv -fbt 2> \
- bw.txt | nc %s 1234" % client_name, server, video=video, depends=depends_server)
+from optparse import OptionParser, SUPPRESS_HELP
+import os
+
+usage = ("usage: %prog -a <hostanme1> -b <hostname2> -u <username> -i <ssh-key>")
+
+parser = OptionParser(usage = usage)
+parser.add_option("-a", "--hostname1", dest="hostname1",
+ help="Remote host 1", type="str")
+parser.add_option("-b", "--hostname2", dest="hostname2",
+ help="Remote host 2", type="str")
+parser.add_option("-u", "--username", dest="username",
+ help="Username to SSH to remote host", type="str")
+parser.add_option("-i", "--ssh-key", dest="ssh_key",
+ help="Path to private SSH key to be used for connection",
+ type="str")
+(options, args) = parser.parse_args()
+
+hostname1 = options.hostname1
+hostname2 = options.hostname2
+username = options.username
+ssh_key = options.ssh_key
+
+## Create the experiment controller
+ec = ExperimentController(exp_id = "file_transfer")
+
+## Register node 1
+node1 = ec.register_resource("LinuxNode")
+# Set the hostname of the first node to use for the experiment
+ec.set(node1, "hostname", hostname1)
+# username should be your SSH user
+ec.set(node1, "username", username)
+# Absolute path to the SSH private key
+ec.set(node1, "identity", ssh_key)
+# Clean all files, results, etc, from previous experiments wit the same exp_id
+ec.set(node1, "cleanExperiment", True)
+# Kill all running processes in the node before running the experiment
+ec.set(node1, "cleanProcesses", True)
+
+## Register node 2
+node2 = ec.register_resource("LinuxNode")
+# Set the hostname of the first node to use for the experiment
+ec.set(node2, "hostname", hostname2)
+# username should be your SSH user
+ec.set(node2, "username", username)
+# Absolute path to the SSH private key
+ec.set(node2, "identity", ssh_key)
+# Clean all files, results, etc, from previous experiments wit the same exp_id
+ec.set(node2, "cleanExperiment", True)
+# Kill all running processes in the node before running the experiment
+ec.set(node2, "cleanProcesses", True)
+
+# Register server
+video = "big_buck_bunny_240p_mpeg4_lq.ts"
+local_path_to_video = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "..", video)
+
+command = "cat ${SHARE}/%s | pv -fbt 2> bw.txt | nc %s 1234" % (
+ video, hostname2 )
+
+server = ec.register_resource("LinuxApplication")
+ec.set(server, "depends", "pv nc tcpdump")
+ec.set(server, "files", local_path_to_video)
+ec.set(server, "command", command)
+ec.register_connection(server, node1)
+
+# Register client
+command = ("sudo -S dbus-uuidgen --ensure; sleep 3; "
+ "vlc -I dummy rtp://%s:5004/%s "
+ "--sout '#std{access=file,mux=ts,dst=VIDEO}'") % \
+ (hostname2, video)