From e7eb6ef8873e1e197b3db8842f67a483c004a77a Mon Sep 17 00:00:00 2001 From: Alina Quereilhac Date: Thu, 11 Sep 2014 16:16:18 +0200 Subject: [PATCH] Cleaning up examples folder --- .../linux/{ccn => }/ccn_simple_transfer.py | 102 +++++++++--------- examples/linux/netcat_file_transfer.py | 6 +- examples/linux/ping.py | 6 ++ .../linux/{ccn => testing}/ccncat_2_nodes.py | 0 .../ccncat_extended_ring_topo.py | 0 examples/linux/vlc_streaming.py | 11 +- src/nepi/resources/linux/ccn/ccnd.py | 2 +- 7 files changed, 72 insertions(+), 55 deletions(-) rename examples/linux/{ccn => }/ccn_simple_transfer.py (80%) rename examples/linux/{ccn => testing}/ccncat_2_nodes.py (100%) rename examples/linux/{ccn => testing}/ccncat_extended_ring_topo.py (100%) diff --git a/examples/linux/ccn/ccn_simple_transfer.py b/examples/linux/ccn_simple_transfer.py similarity index 80% rename from examples/linux/ccn/ccn_simple_transfer.py rename to examples/linux/ccn_simple_transfer.py index 19c78417..7e06207f 100644 --- a/examples/linux/ccn/ccn_simple_transfer.py +++ b/examples/linux/ccn_simple_transfer.py @@ -17,14 +17,19 @@ # # Author: Alina Quereilhac # -# Instructions to run this example: -# -# 1. First edit the script file where required (See ASSING messages) -# -# 2. Then, run the script: + +# Example of how to run this experiment (replace with your information): # # $ cd -# $ PYTHONPATH=$PYTHONPATHS:src python examples/linux/ccn/two_nodes_file_retrieval.py +# python examples/linux/ccn_simple_transfer.py -a -b -u -i + +# CCN topology: +# +# +# +# content ccncat +# Linux host Linux host +# 0 ------- network -------- 1 # from nepi.execution.ec import ExperimentController @@ -54,6 +59,8 @@ ssh_key = options.ssh_key ## Create the experiment controller ec = ExperimentController(exp_id = "ccn_simple_transfer") +##### CONFIGURING NODE 1 + ## Register node 1 node1 = ec.register_resource("LinuxNode") # Set the hostname of the first node to use for the experiment @@ -67,6 +74,33 @@ ec.set(node1, "cleanExperiment", True) # Kill all running processes in the node before running the experiment ec.set(node1, "cleanProcesses", True) +## Register a CCN daemon in node 1 +ccnd1 = ec.register_resource("LinuxCCND") +# Set ccnd log level to 7 +ec.set(ccnd1, "debug", 7) +ec.register_connection(ccnd1, node1) + +## Register a repository in node 1 +ccnr1 = ec.register_resource("LinuxCCNR") +ec.register_connection(ccnr1, ccnd1) + +## Push the file into the repository +local_path_to_content = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "..", "big_buck_bunny_240p_mpeg4_lq.ts") + +content_name = "ccnx:/test/FILE" + +# Add a content to the repository +co = ec.register_resource("LinuxCCNContent") +ec.set(co, "contentName", content_name) +# NEPI will upload the specified file to the remote node and write it +# into the CCN repository +ec.set(co, "content", local_path_to_content) +ec.register_connection(co, ccnr1) + +##### CONFIGURING NODE 2 + ## Register node 2 node2 = ec.register_resource("LinuxNode") # Set the hostname of the first node to use for the experiment @@ -80,35 +114,18 @@ ec.set(node2, "cleanExperiment", True) # Kill all running processes in the node before running the experiment ec.set(node2, "cleanProcesses", True) -## Register a CCN daemon in node 1 -ccnd1 = ec.register_resource("LinuxCCND") -# Set ccnd log level to 7 -ec.set(ccnd1, "debug", 7) -ec.register_connection(ccnd1, node1) - ## Register a CCN daemon in node 2 ccnd2 = ec.register_resource("LinuxCCND") # Set ccnd log level to 7 ec.set(ccnd2, "debug", 7) ec.register_connection(ccnd2, node2) -## Register a repository in node 1 -ccnr1 = ec.register_resource("LinuxCCNR") -ec.register_connection(ccnr1, ccnd1) - -## Push the file into the repository -local_path_to_content = os.path.join( - os.path.dirname(os.path.realpath(__file__)), - "..", "..", - "big_buck_bunny_240p_mpeg4_lq.ts") +## Retrieve the file stored in node 1 from node 2 +ccncat = ec.register_resource("LinuxCCNCat") +ec.set(ccncat, "contentName", content_name) +ec.register_connection(ccncat, ccnd2) -# Register a FIB entry from node 1 to node 2 -co = ec.register_resource("LinuxCCNContent") -ec.set(co, "contentName", "ccnx:/test/FILE1") -# NEPI will upload the specified file to the remote node and write it -# into the CCN repository -ec.set(co, "content", local_path_to_content) -ec.register_connection(co, ccnr1) +##### INTERCONNECTING CCN NODES ... # Register a FIB entry from node 1 to node 2 entry1 = ec.register_resource("LinuxFIBEntry") @@ -120,30 +137,19 @@ entry2 = ec.register_resource("LinuxFIBEntry") ec.set(entry2, "host", hostname1) ec.register_connection(entry2, ccnd2) -## Retrieve the file stored in node 1 from node 2 -command = "ccncat ccnx:/test/FILE1" -app = ec.register_resource("LinuxCCNApplication") -ec.set(app, "command", command) -ec.register_connection(app, ccnd2) - -# Register a collector to automatically collect the ccnd logs -# to a local directory -col1 = ec.register_resource("Collector") -ec.set(col1, "traceName", "stderr") -ec.set(col1, "subDir", hostname1) -ec.register_connection(col1, ccnd1) - -col2 = ec.register_resource("Collector") -ec.set(col2, "traceName", "stderr") -ec.set(col2, "subDir", hostname2) -ec.register_connection(col2, ccnd2) - -print "Results stored at", ec.exp_dir +##### STARTING THE EXPERIMENT ## Deploy all resources ec.deploy() # Wait until the ccncat is finished -ec.wait_finished([app]) +ec.wait_finished([ccncat]) + +stdout = ec.trace(ccncat, "stdout") +f = open("video.ts", "w") +f.write(stdout) +f.close() ec.shutdown() + +print "Transfered FILE stored localy at video.ts" diff --git a/examples/linux/netcat_file_transfer.py b/examples/linux/netcat_file_transfer.py index 69091b49..e2047d10 100644 --- a/examples/linux/netcat_file_transfer.py +++ b/examples/linux/netcat_file_transfer.py @@ -20,10 +20,10 @@ # Alina Quereilhac # # -# Example of how to run this experiment (replace with your credentials): +# Example of how to run this experiment (replace with your information): # # $ cd -# python examples/linux/netcat_file_transfer.py -a -b -u -i +# python examples/linux/netcat_file_transfer.py -a -b -u -i from nepi.execution.ec import ExperimentController from nepi.execution.resource import ResourceAction, ResourceState @@ -139,3 +139,5 @@ f.close() ec.shutdown() +print "Total bytes transfered saved to bw.txt..." + diff --git a/examples/linux/ping.py b/examples/linux/ping.py index 9e67f580..3e9f03a8 100644 --- a/examples/linux/ping.py +++ b/examples/linux/ping.py @@ -18,6 +18,12 @@ # # Author: Alina Quereilhac +# Example of how to run this experiment (replace with your information): +# +# $ cd +# python examples/linux/ping.py -a -u -i + + from nepi.execution.ec import ExperimentController from optparse import OptionParser, SUPPRESS_HELP diff --git a/examples/linux/ccn/ccncat_2_nodes.py b/examples/linux/testing/ccncat_2_nodes.py similarity index 100% rename from examples/linux/ccn/ccncat_2_nodes.py rename to examples/linux/testing/ccncat_2_nodes.py diff --git a/examples/linux/ccn/ccncat_extended_ring_topo.py b/examples/linux/testing/ccncat_extended_ring_topo.py similarity index 100% rename from examples/linux/ccn/ccncat_extended_ring_topo.py rename to examples/linux/testing/ccncat_extended_ring_topo.py diff --git a/examples/linux/vlc_streaming.py b/examples/linux/vlc_streaming.py index 6d01a9b6..49e2e7e0 100644 --- a/examples/linux/vlc_streaming.py +++ b/examples/linux/vlc_streaming.py @@ -17,11 +17,10 @@ # # Author: Alina Quereilhac # -# Example of how to run this experiment (replace with your credentials): +# Example of how to run this experiment (replace with your information): # # $ cd -# $ PYTHONPATH=$PYTHONPATH:~/repos/nepi/src python examples/linux/vlc_streaming.py -u inria_nepi -i ~/.ssh/id_rsa_planetlab -a planetlab1.u-strasbg.fr -b planetlab1.utt.fr | vlc - - +# python examples/linux/vlc_streaming.py -a -b -u -i from nepi.execution.ec import ExperimentController from nepi.execution.resource import ResourceState, ResourceAction @@ -115,8 +114,12 @@ ec.deploy() # Wait until the ccncat is finished ec.wait_finished([server]) -print ec.trace(client, "VIDEO") +video = ec.trace(client, "VIDEO") +f = open("video.ts", "w") +f.write(video) +f.close() ec.shutdown() +print "Streamed VIDEO stored localy at video.ts" diff --git a/src/nepi/resources/linux/ccn/ccnd.py b/src/nepi/resources/linux/ccn/ccnd.py index ffaee508..1fc8979b 100644 --- a/src/nepi/resources/linux/ccn/ccnd.py +++ b/src/nepi/resources/linux/ccn/ccnd.py @@ -282,7 +282,7 @@ class LinuxCCND(LinuxApplication): @property def _sources(self): - return "http://www.ccnx.org/releases/ccnx-0.8.1.tar.gz" + return "http://www.ccnx.org/releases/ccnx-0.8.2.tar.gz" @property def _build(self): -- 2.43.0