use print() - import print_function - should be fine for both py2 and py3
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 8 Oct 2015 14:26:42 +0000 (16:26 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 8 Oct 2015 14:26:42 +0000 (16:26 +0200)
66 files changed:
examples/ccn_emu_live/dce.py
examples/ccn_emu_live/planetlab.py
examples/ccn_emu_live/planetlab_4_nodes_linear.py
examples/dce/custom_dlm_ping.py
examples/dce/custom_local_csma_ping.py
examples/dce/custom_local_p2p_ccn.py
examples/dce/custom_local_p2p_ping.py
examples/dce/custom_local_wifi_ping.py
examples/dce/wrapped_local_p2p_ccncat.py
examples/dce/wrapped_local_p2p_ccnpeek.py
examples/dce/wrapped_local_p2p_ping.py
examples/linux/ccn_simple_transfer.py
examples/linux/ccn_transfer_using_linuxapp.py
examples/linux/hello_world.py
examples/linux/netcat_file_transfer.py
examples/linux/ping.py
examples/linux/vlc_streaming.py
examples/netns/local_switch_ping.py
examples/ns3/local_csma_p2p_star_ping.py
examples/ns3/local_csma_ping.py
examples/ns3/local_mobile_wifi_ping.py
examples/ns3/local_p2p_ping.py
examples/ns3/local_wifi_ping.py
examples/ns3/multi_host/distributed.py
examples/ns3/multi_host/hybrid.py
examples/ns3/multi_host/parallel.py
examples/ns3/remote_p2p_ping.py
examples/omf/iminds_omf6_ping.py
examples/omf/iminds_omf6_vlc.py
examples/omf/nitos_omf6_ping.py
examples/omf/nitos_omf6_vlc.py
examples/omf/nitos_testbed_bootstrap.py
examples/omf/testing/nepi_omf6_iminds_vlc.py
examples/omf/testing/nitos_omf5_ping.py
examples/openvswitch/ovs_ping.py
examples/openvswitch/ovs_ping_2_switches.py
examples/openvswitch/ovs_ping_3_switches.py
examples/planetlab/ccn_simple_transfer.py
examples/planetlab/ping.py
examples/planetlab/ping_with_filters.py
examples/planetlab/select_nodes.py
examples/planetlab/update_fedora_repo.py
src/nepi/__init__.py
src/nepi/data/processing/ccn/parser.py
src/nepi/resources/linux/scripts/linux-tap-create.py
src/nepi/resources/linux/scripts/linux-tap-delete.py
src/nepi/resources/linux/scripts/tunchannel.py
src/nepi/resources/ns3/resource_manager_generator.py
src/nepi/resources/omf/application.py
src/nepi/resources/planetlab/scripts/pl-vif-create.py
src/nepi/resources/planetlab/scripts/pl-vif-down.py
src/nepi/resources/planetlab/sfa_node.py
src/nepi/util/manifoldapi.py
src/nepi/util/parsers/xml_parser.py
src/nepi/util/statfuncs.py
test/lib/test_utils.py
test/resources/linux/ccn/ccnpeek.py
test/resources/linux/netns/netnsclient.py
test/resources/linux/netns/netnsemulation.py
test/resources/linux/ns3/cross_ns3_linux_tuntapfdlink_ping.py
test/resources/linux/ns3/ns3fdnetdevice.py
test/resources/linux/ns3/ns3simulation.py
test/resources/linux/ns3/serialization.py
test/resources/linux/udptunnel.py
test/resources/ns3/ns3wrapper.py
test/resources/omf/set_hook.py

index 7f490a4..79507b5 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 from nepi.execution.runner import ExperimentRunner
 from nepi.util.netgraph import NetGraph, TopologyType
@@ -169,7 +171,7 @@ def avg_interests(ec, run):
     f = open("/tmp/metric", "a+")
     f.write("%.2f\n" % metric)
     f.close()
-    print " METRIC", metric
+    print(" METRIC", metric)
 
     return metric
 
@@ -211,7 +213,7 @@ if __name__ == '__main__':
             add_node_callback = add_dce_node, 
             add_edge_callback = add_dce_edge)
     
-    print "Results stored at", ec.exp_dir
+    print("Results stored at", ec.exp_dir)
 
     #### Retrieve the consumer to wait for ot to finish
     ccncat = ec.filter_resources("linux::ns3::dce::CCNCat")
index 10b4deb..b2548f3 100644 (file)
@@ -17,6 +17,7 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
 
 from nepi.execution.ec import ExperimentController 
 from nepi.execution.runner import ExperimentRunner
@@ -174,7 +175,7 @@ def avg_interests(ec, run):
     f = open("/tmp/metric", "a+")
     f.write("%.2f\n" % metric)
     f.close()
-    print " METRIC", metric
+    print(" METRIC", metric)
 
     return metric
 
@@ -205,7 +206,7 @@ if __name__ == '__main__':
             add_node_callback = add_pl_node, 
             add_edge_callback = add_pl_edge)
     
-    print "Results stored at", ec.exp_dir
+    print("Results stored at", ec.exp_dir)
 
     #### Retrieve the content producing resource to wait for ot to finish
     ccncat = ec.filter_resources("linux::CCNCat")
index e527fd9..b48f496 100644 (file)
-#!/usr/bin/env python\r
-#\r
-#    NEPI, a framework to manage network experiments\r
-#    Copyright (C) 2013 INRIA\r
-#\r
-#    This program is free software: you can redistribute it and/or modify\r
-#    it under the terms of the GNU General Public License version 2 as\r
-#    published by the Free Software Foundation;\r
-#\r
-#    This program is distributed in the hope that it will be useful,\r
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-#    GNU General Public License for more details.\r
-#\r
-#    You should have received a copy of the GNU General Public License\r
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
-#\r
-# Author: Alina Quereilhac <alina.quereilhac@inria.fr>\r
-\r
-from nepi.execution.ec import ExperimentController \r
-from nepi.execution.runner import ExperimentRunner\r
-from nepi.util.netgraph import TopologyType\r
-import nepi.data.processing.ccn.parser as ccn_parser\r
-\r
-import networkx\r
-import socket\r
-import os\r
-import numpy\r
-from scipy import stats\r
-from matplotlib import pyplot\r
-import math\r
-import random\r
-\r
-from optparse import OptionParser\r
-\r
-usage = ("usage: %prog -s <pl-slice> -u <pl-user> -p <pl-password> "\r
-     "-k <pl-ssh-key> -N <nodes>")\r
-\r
-parser = OptionParser(usage = usage)\r
-parser.add_option("-s", "--pl-slice", dest="pl_slice",\r
-        help="PlanetLab slicename", type="str")\r
-parser.add_option("-u", "--pl-user", dest="pl_user",\r
-        help="PlanetLab web username", type="str")\r
-parser.add_option("-p", "--pl-password", dest="pl_password",\r
-        help="PlanetLab web password", type="str")\r
-parser.add_option("-k", "--pl-ssh-key", dest="pl_ssh_key",\r
-        help="Path to private SSH key associated with the PL account",\r
-        type="str")\r
-parser.add_option("-N", "--nodes", dest="nodes",\r
-        help="Comma separated list of Planetlab nodes",\r
-        type="str")\r
-\r
-(options, args) = parser.parse_args()\r
-\r
-pl_slice = options.pl_slice\r
-pl_ssh_key = options.pl_ssh_key\r
-pl_user = options.pl_user\r
-pl_password = options.pl_password\r
-NODES = options.nodes.strip().split(",")\r
-\r
-def avg_interest_rtt(ec, run):\r
-    logs_dir = ec.run_dir\r
-    \r
-    # Parse downloaded CCND logs\r
-    (graph,\r
-      content_names,\r
-      interest_expiry_count,\r
-      interest_dupnonce_count,\r
-      interest_count,\r
-      content_count) = ccn_parser.process_content_history_logs(\r
-        logs_dir, ec.netgraph.topology)\r
-\r
-    # statistics on RTT\r
-    rtts = [content_names[content_name]["rtt"] \\r
-            for content_name in content_names.keys()]\r
-\r
-    # sample mean and standard deviation\r
-    sample = numpy.array(rtts)\r
-    n, min_max, mean, var, skew, kurt = stats.describe(sample)\r
-    std = math.sqrt(var)\r
-    ci = stats.t.interval(0.95, n-1, loc = mean, \r
-            scale = std/math.sqrt(n))\r
-\r
-    global metrics\r
-    metrics.append((mean, ci[0], ci[1]))\r
-    \r
-    return mean\r
-\r
-def normal_law(ec, run, sample):\r
-    print "SAMPLE", sample\r
-\r
-    x = numpy.array(sample)\r
-    n = len(sample)\r
-    std = x.std()\r
-    se = std / math.sqrt(n)\r
-    m = x.mean()\r
-    se95 = se * 2\r
-    \r
-    return m * 0.05 >= se95\r
-\r
-def post_process(ec, runs):\r
-    global metrics\r
-    \r
-    # plot convergence graph\r
-    y = numpy.array([float(m[0]) for m in metrics])\r
-    low = numpy.array([float(m[1]) for m in metrics])\r
-    high = numpy.array([float(m[2]) for m in metrics])\r
-    error = [y - low, high - y]\r
-    x = range(1,runs + 1)\r
-\r
-    # plot average RTT and confidence interval for each iteration\r
-    pyplot.errorbar(x, y, yerr = error, fmt='o')\r
-    pyplot.plot(x, y, 'r-')\r
-    pyplot.xlim([0.5, runs + 0.5])\r
-    pyplot.xticks(numpy.arange(1, len(y)+1, 1))\r
-    pyplot.xlabel('Iteration')\r
-    pyplot.ylabel('Average RTT')\r
-    pyplot.grid()\r
-    pyplot.savefig("plot.png")\r
-    pyplot.show()\r
-\r
-content_name = "ccnx:/test/bunny.ts"\r
-\r
-repofile = os.path.join(\r
-        os.path.dirname(os.path.realpath(__file__)), \r
-        "repoFile1.0.8.2")\r
-\r
-def get_simulator(ec):\r
-    simulator = ec.filter_resources("linux::ns3::Simulation")\r
-\r
-    if not simulator:\r
-        node = ec.register_resource("linux::Node")\r
-        ec.set(node, "hostname", "localhost")\r
-\r
-        simu = ec.register_resource("linux::ns3::Simulation")\r
-        ec.register_connection(simu, node)\r
-        return simu\r
-\r
-    return simulator[0]\r
-\r
-def add_collector(ec, trace_name, subdir, newname = None):\r
-    collector = ec.register_resource("Collector")\r
-    ec.set(collector, "traceName", trace_name)\r
-    ec.set(collector, "subDir", subdir)\r
-    if newname:\r
-        ec.set(collector, "rename", newname)\r
-\r
-    return collector\r
-\r
-def add_dce_host(ec, nid):\r
-    simu = get_simulator(ec)\r
-    \r
-    host = ec.register_resource("ns3::Node")\r
-    ec.set(host, "enableStack", True)\r
-    ec.register_connection(host, simu)\r
-\r
-    # Annotate the graph\r
-    ec.netgraph.annotate_node(nid, "host", host)\r
-    \r
-def add_dce_ccnd(ec, nid):\r
-    # Retrieve annotation from netgraph\r
-    host = ec.netgraph.node_annotation(nid, "host")\r
-    \r
-    # Add dce ccnd to the dce node\r
-    ccnd = ec.register_resource("linux::ns3::dce::CCND")\r
-    ec.set (ccnd, "stackSize", 1<<20)\r
-    ec.set (ccnd, "debug", 7)\r
-    ec.set (ccnd, "capacity", 50000)\r
-    ec.set (ccnd, "StartTime", "1s")\r
-    ec.set (ccnd, "StopTime", STOP_TIME)\r
-    ec.register_connection(ccnd, host)\r
-\r
-    # Collector to retrieve ccnd log\r
-    collector = add_collector(ec, "stderr", str(nid), "log")\r
-    ec.register_connection(collector, ccnd)\r
-\r
-    # Annotate the graph\r
-    ec.netgraph.annotate_node(nid, "ccnd", ccnd)\r
-\r
-def add_dce_ccnr(ec, nid):\r
-    # Retrieve annotation from netgraph\r
-    host = ec.netgraph.node_annotation(nid, "host")\r
-    \r
-    # Add a CCN content repository to the dce node\r
-    ccnr = ec.register_resource("linux::ns3::dce::CCNR")\r
-    ec.set (ccnr, "repoFile1", repofile) \r
-    ec.set (ccnr, "stackSize", 1<<20)\r
-    ec.set (ccnr, "StartTime", "2s")\r
-    ec.set (ccnr, "StopTime", STOP_TIME)\r
-    ec.register_connection(ccnr, host)\r
-\r
-def add_dce_ccncat(ec, nid):\r
-    # Retrieve annotation from netgraph\r
-    host = ec.netgraph.node_annotation(nid, "host")\r
-   \r
-    # Add a ccncat application to the dce host\r
-    ccncat = ec.register_resource("linux::ns3::dce::CCNCat")\r
-    ec.set (ccncat, "contentName", content_name)\r
-    ec.set (ccncat, "stackSize", 1<<20)\r
-    ec.set (ccncat, "StartTime", "8s")\r
-    ec.set (ccncat, "StopTime", STOP_TIME)\r
-    ec.register_connection(ccncat, host)\r
-\r
-def add_dce_fib_entry(ec, nid1, nid2):\r
-    # Retrieve annotations from netgraph\r
-    host1 = ec.netgraph.node_annotation(nid1, "host")\r
-    net = ec.netgraph.edge_net_annotation(nid1, nid2)\r
-    ip2 = net[nid2]\r
-\r
-    # Add FIB entry between peer hosts\r
-    ccndc = ec.register_resource("linux::ns3::dce::FIBEntry")\r
-    ec.set (ccndc, "protocol", "udp") \r
-    ec.set (ccndc, "uri", "ccnx:/") \r
-    ec.set (ccndc, "host", ip2)\r
-    ec.set (ccndc, "stackSize", 1<<20)\r
-    ec.set (ccndc, "StartTime", "2s")\r
-    ec.set (ccndc, "StopTime", STOP_TIME)\r
-    ec.register_connection(ccndc, host1)\r
-\r
-def add_dce_net_iface(ec, nid1, nid2):\r
-    # Retrieve annotations from netgraph\r
-    host = ec.netgraph.node_annotation(nid1, "host")\r
-    net = ec.netgraph.edge_net_annotation(nid1, nid2)\r
-    ip1 = net[nid1]\r
-    prefix = net["prefix"]\r
-\r
-    dev = ec.register_resource("ns3::PointToPointNetDevice")\r
-    ec.set(dev,"DataRate", "5Mbps")\r
-    ec.set(dev, "ip", ip1)\r
-    ec.set(dev, "prefix", prefix)\r
-    ec.register_connection(host, dev)\r
-\r
-    queue = ec.register_resource("ns3::DropTailQueue")\r
-    ec.register_connection(dev, queue)\r
-\r
-    return dev\r
-\r
-def add_pl_host(ec, nid):\r
-    hostname = NODES[nid]\r
-\r
-    # Add a planetlab host to the experiment description\r
-    host = ec.register_resource("planetlab::Node")\r
-    ec.set(host, "hostname", hostname)\r
-    ec.set(host, "username", pl_slice)\r
-    ec.set(host, "identity", pl_ssh_key)\r
-    ec.set(host, "cleanExperiment", True)\r
-    ec.set(host, "cleanProcesses", True)\r
-\r
-    # Annotate the graph\r
-    ec.netgraph.annotate_node(nid, "hostname", hostname)\r
-    ec.netgraph.annotate_node(nid, "host", host)\r
-    \r
-    # Annotate the graph node with an ip address\r
-    ip = socket.gethostbyname(hostname)\r
-    ec.netgraph.annotate_node_ip(nid, ip)\r
-\r
-def add_pl_ccnd(ec, nid):\r
-    # Retrieve annotation from netgraph\r
-    host = ec.netgraph.node_annotation(nid, "host")\r
-    \r
-    # Add a CCN daemon to the planetlab node\r
-    ccnd = ec.register_resource("linux::CCND")\r
-    ec.set(ccnd, "debug", 7)\r
-    ec.register_connection(ccnd, host)\r
-    \r
-    # Collector to retrieve ccnd log\r
-    collector = add_collector(ec, "stderr", str(nid), "log")\r
-    ec.register_connection(collector, ccnd)\r
-\r
-    # Annotate the graph\r
-    ec.netgraph.annotate_node(nid, "ccnd", ccnd)\r
-\r
-def add_pl_ccnr(ec, nid):\r
-    # Retrieve annotation from netgraph\r
-    ccnd = ec.netgraph.node_annotation(nid, "ccnd")\r
-    \r
-    # Add a CCN content repository to the planetlab node\r
-    ccnr = ec.register_resource("linux::CCNR")\r
-\r
-    ec.set(ccnr, "repoFile1", repofile)\r
-    ec.register_connection(ccnr, ccnd)\r
-\r
-def add_pl_ccncat(ec, nid):\r
-    # Retrieve annotation from netgraph\r
-    ccnd = ec.netgraph.node_annotation(nid, "ccnd")\r
-    \r
-    # Add a CCN cat application to the planetlab node\r
-    ccncat = ec.register_resource("linux::CCNCat")\r
-    ec.set(ccncat, "contentName", content_name)\r
-    ec.register_connection(ccncat, ccnd)\r
-\r
-def add_pl_fib_entry(ec, nid1, nid2):\r
-    # Retrieve annotations from netgraph\r
-    ccnd1 = ec.netgraph.node_annotation(nid1, "ccnd")\r
-    hostname2 = ec.netgraph.node_annotation(nid2, "hostname")\r
-    \r
-    # Add a FIB entry between one planetlab node and its peer\r
-    entry = ec.register_resource("linux::FIBEntry")\r
-    ec.set(entry, "host", hostname2)\r
-    ec.register_connection(entry, ccnd1)\r
-\r
-    # Collector to retrieve peering ping output (to measure neighbors delay)\r
-    ec.enable_trace(entry, "ping")\r
-    collector = add_collector(ec, "ping", str(nid1))\r
-    ec.register_connection(collector, entry)\r
-\r
-    return entry\r
-\r
-def add_node(ec, nid):\r
-    ### Add CCN nodes (ec.netgraph holds the topology graph)\r
-    add_dce_host(ec, nid)\r
-    add_dce_ccnd(ec, nid)\r
-        \r
-    if nid == ec.netgraph.targets()[0]:\r
-        add_dce_ccnr(ec, nid)\r
-\r
-    if nid == ec.netgraph.sources()[0]:\r
-        add_dce_ccncat(ec, nid)\r
-\r
-def add_edge(ec, nid1, nid2):\r
-    #### Add connections between CCN nodes\r
-    add_pl_fib_entry(ec, nid1, nid2)\r
-    add_pl_fib_entry(ec, nid2, nid1)\r
-\r
-def add_node(ec, nid):\r
-    ### Add CCN nodes (ec.netgraph holds the topology graph)\r
-    add_pl_host(ec, nid)\r
-    add_pl_ccnd(ec, nid)\r
-        \r
-    if nid == ec.netgraph.targets()[0]:\r
-        add_pl_ccnr(ec, nid)\r
-\r
-    if nid == ec.netgraph.sources()[0]:\r
-        add_pl_ccncat(ec, nid)\r
-\r
-def wait_guids(ec):\r
-    return ec.filter_resources("linux::CCNCat")\r
-\r
-if __name__ == '__main__':\r
-\r
-    metrics = []\r
-\r
-    # topology translation to NEPI model\r
-    ec = ExperimentController("pl_4n_linear",\r
-        topo_type = TopologyType.LINEAR, \r
-        node_count = 4,\r
-        assign_st = True,\r
-        assign_ips = True,\r
-        add_node_callback = add_node,\r
-       add_edge_callback = add_edge)\r
-\r
-    #### Run experiment until metric convergence\r
-    rnr = ExperimentRunner()\r
-    runs = rnr.run(ec,\r
-            min_runs = 10,\r
-            max_runs = 100, \r
-            compute_metric_callback = avg_interest_rtt,\r
-            evaluate_convergence_callback = normal_law,\r
-            wait_guids = wait_guids(ec))\r
-   \r
-    ### post processing\r
-    post_process(ec, runs)\r
-\r
-\r
+#!/usr/bin/env python
+#
+#    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 version 2 as
+#    published by the Free Software Foundation;
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+
+from __future__ import print_function
+
+from nepi.execution.ec import ExperimentController 
+from nepi.execution.runner import ExperimentRunner
+from nepi.util.netgraph import TopologyType
+import nepi.data.processing.ccn.parser as ccn_parser
+
+import networkx
+import socket
+import os
+import numpy
+from scipy import stats
+from matplotlib import pyplot
+import math
+import random
+
+from optparse import OptionParser
+
+usage = ("usage: %prog -s <pl-slice> -u <pl-user> -p <pl-password> "
+     "-k <pl-ssh-key> -N <nodes>")
+
+parser = OptionParser(usage = usage)
+parser.add_option("-s", "--pl-slice", dest="pl_slice",
+        help="PlanetLab slicename", type="str")
+parser.add_option("-u", "--pl-user", dest="pl_user",
+        help="PlanetLab web username", type="str")
+parser.add_option("-p", "--pl-password", dest="pl_password",
+        help="PlanetLab web password", type="str")
+parser.add_option("-k", "--pl-ssh-key", dest="pl_ssh_key",
+        help="Path to private SSH key associated with the PL account",
+        type="str")
+parser.add_option("-N", "--nodes", dest="nodes",
+        help="Comma separated list of Planetlab nodes",
+        type="str")
+
+(options, args) = parser.parse_args()
+
+pl_slice = options.pl_slice
+pl_ssh_key = options.pl_ssh_key
+pl_user = options.pl_user
+pl_password = options.pl_password
+NODES = options.nodes.strip().split(",")
+
+def avg_interest_rtt(ec, run):
+    logs_dir = ec.run_dir
+    
+    # Parse downloaded CCND logs
+    (graph,
+      content_names,
+      interest_expiry_count,
+      interest_dupnonce_count,
+      interest_count,
+      content_count) = ccn_parser.process_content_history_logs(
+        logs_dir, ec.netgraph.topology)
+
+    # statistics on RTT
+    rtts = [content_names[content_name]["rtt"] \
+            for content_name in content_names.keys()]
+
+    # sample mean and standard deviation
+    sample = numpy.array(rtts)
+    n, min_max, mean, var, skew, kurt = stats.describe(sample)
+    std = math.sqrt(var)
+    ci = stats.t.interval(0.95, n-1, loc = mean, 
+            scale = std/math.sqrt(n))
+
+    global metrics
+    metrics.append((mean, ci[0], ci[1]))
+    
+    return mean
+
+def normal_law(ec, run, sample):
+    print("SAMPLE", sample)
+
+    x = numpy.array(sample)
+    n = len(sample)
+    std = x.std()
+    se = std / math.sqrt(n)
+    m = x.mean()
+    se95 = se * 2
+    
+    return m * 0.05 >= se95
+
+def post_process(ec, runs):
+    global metrics
+    
+    # plot convergence graph
+    y = numpy.array([float(m[0]) for m in metrics])
+    low = numpy.array([float(m[1]) for m in metrics])
+    high = numpy.array([float(m[2]) for m in metrics])
+    error = [y - low, high - y]
+    x = range(1,runs + 1)
+
+    # plot average RTT and confidence interval for each iteration
+    pyplot.errorbar(x, y, yerr = error, fmt='o')
+    pyplot.plot(x, y, 'r-')
+    pyplot.xlim([0.5, runs + 0.5])
+    pyplot.xticks(numpy.arange(1, len(y)+1, 1))
+    pyplot.xlabel('Iteration')
+    pyplot.ylabel('Average RTT')
+    pyplot.grid()
+    pyplot.savefig("plot.png")
+    pyplot.show()
+
+content_name = "ccnx:/test/bunny.ts"
+
+repofile = os.path.join(
+        os.path.dirname(os.path.realpath(__file__)), 
+        "repoFile1.0.8.2")
+
+def get_simulator(ec):
+    simulator = ec.filter_resources("linux::ns3::Simulation")
+
+    if not simulator:
+        node = ec.register_resource("linux::Node")
+        ec.set(node, "hostname", "localhost")
+
+        simu = ec.register_resource("linux::ns3::Simulation")
+        ec.register_connection(simu, node)
+        return simu
+
+    return simulator[0]
+
+def add_collector(ec, trace_name, subdir, newname = None):
+    collector = ec.register_resource("Collector")
+    ec.set(collector, "traceName", trace_name)
+    ec.set(collector, "subDir", subdir)
+    if newname:
+        ec.set(collector, "rename", newname)
+
+    return collector
+
+def add_dce_host(ec, nid):
+    simu = get_simulator(ec)
+    
+    host = ec.register_resource("ns3::Node")
+    ec.set(host, "enableStack", True)
+    ec.register_connection(host, simu)
+
+    # Annotate the graph
+    ec.netgraph.annotate_node(nid, "host", host)
+    
+def add_dce_ccnd(ec, nid):
+    # Retrieve annotation from netgraph
+    host = ec.netgraph.node_annotation(nid, "host")
+    
+    # Add dce ccnd to the dce node
+    ccnd = ec.register_resource("linux::ns3::dce::CCND")
+    ec.set (ccnd, "stackSize", 1<<20)
+    ec.set (ccnd, "debug", 7)
+    ec.set (ccnd, "capacity", 50000)
+    ec.set (ccnd, "StartTime", "1s")
+    ec.set (ccnd, "StopTime", STOP_TIME)
+    ec.register_connection(ccnd, host)
+
+    # Collector to retrieve ccnd log
+    collector = add_collector(ec, "stderr", str(nid), "log")
+    ec.register_connection(collector, ccnd)
+
+    # Annotate the graph
+    ec.netgraph.annotate_node(nid, "ccnd", ccnd)
+
+def add_dce_ccnr(ec, nid):
+    # Retrieve annotation from netgraph
+    host = ec.netgraph.node_annotation(nid, "host")
+    
+    # Add a CCN content repository to the dce node
+    ccnr = ec.register_resource("linux::ns3::dce::CCNR")
+    ec.set (ccnr, "repoFile1", repofile) 
+    ec.set (ccnr, "stackSize", 1<<20)
+    ec.set (ccnr, "StartTime", "2s")
+    ec.set (ccnr, "StopTime", STOP_TIME)
+    ec.register_connection(ccnr, host)
+
+def add_dce_ccncat(ec, nid):
+    # Retrieve annotation from netgraph
+    host = ec.netgraph.node_annotation(nid, "host")
+   
+    # Add a ccncat application to the dce host
+    ccncat = ec.register_resource("linux::ns3::dce::CCNCat")
+    ec.set (ccncat, "contentName", content_name)
+    ec.set (ccncat, "stackSize", 1<<20)
+    ec.set (ccncat, "StartTime", "8s")
+    ec.set (ccncat, "StopTime", STOP_TIME)
+    ec.register_connection(ccncat, host)
+
+def add_dce_fib_entry(ec, nid1, nid2):
+    # Retrieve annotations from netgraph
+    host1 = ec.netgraph.node_annotation(nid1, "host")
+    net = ec.netgraph.edge_net_annotation(nid1, nid2)
+    ip2 = net[nid2]
+
+    # Add FIB entry between peer hosts
+    ccndc = ec.register_resource("linux::ns3::dce::FIBEntry")
+    ec.set (ccndc, "protocol", "udp") 
+    ec.set (ccndc, "uri", "ccnx:/") 
+    ec.set (ccndc, "host", ip2)
+    ec.set (ccndc, "stackSize", 1<<20)
+    ec.set (ccndc, "StartTime", "2s")
+    ec.set (ccndc, "StopTime", STOP_TIME)
+    ec.register_connection(ccndc, host1)
+
+def add_dce_net_iface(ec, nid1, nid2):
+    # Retrieve annotations from netgraph
+    host = ec.netgraph.node_annotation(nid1, "host")
+    net = ec.netgraph.edge_net_annotation(nid1, nid2)
+    ip1 = net[nid1]
+    prefix = net["prefix"]
+
+    dev = ec.register_resource("ns3::PointToPointNetDevice")
+    ec.set(dev,"DataRate", "5Mbps")
+    ec.set(dev, "ip", ip1)
+    ec.set(dev, "prefix", prefix)
+    ec.register_connection(host, dev)
+
+    queue = ec.register_resource("ns3::DropTailQueue")
+    ec.register_connection(dev, queue)
+
+    return dev
+
+def add_pl_host(ec, nid):
+    hostname = NODES[nid]
+
+    # Add a planetlab host to the experiment description
+    host = ec.register_resource("planetlab::Node")
+    ec.set(host, "hostname", hostname)
+    ec.set(host, "username", pl_slice)
+    ec.set(host, "identity", pl_ssh_key)
+    ec.set(host, "cleanExperiment", True)
+    ec.set(host, "cleanProcesses", True)
+
+    # Annotate the graph
+    ec.netgraph.annotate_node(nid, "hostname", hostname)
+    ec.netgraph.annotate_node(nid, "host", host)
+    
+    # Annotate the graph node with an ip address
+    ip = socket.gethostbyname(hostname)
+    ec.netgraph.annotate_node_ip(nid, ip)
+
+def add_pl_ccnd(ec, nid):
+    # Retrieve annotation from netgraph
+    host = ec.netgraph.node_annotation(nid, "host")
+    
+    # Add a CCN daemon to the planetlab node
+    ccnd = ec.register_resource("linux::CCND")
+    ec.set(ccnd, "debug", 7)
+    ec.register_connection(ccnd, host)
+    
+    # Collector to retrieve ccnd log
+    collector = add_collector(ec, "stderr", str(nid), "log")
+    ec.register_connection(collector, ccnd)
+
+    # Annotate the graph
+    ec.netgraph.annotate_node(nid, "ccnd", ccnd)
+
+def add_pl_ccnr(ec, nid):
+    # Retrieve annotation from netgraph
+    ccnd = ec.netgraph.node_annotation(nid, "ccnd")
+    
+    # Add a CCN content repository to the planetlab node
+    ccnr = ec.register_resource("linux::CCNR")
+
+    ec.set(ccnr, "repoFile1", repofile)
+    ec.register_connection(ccnr, ccnd)
+
+def add_pl_ccncat(ec, nid):
+    # Retrieve annotation from netgraph
+    ccnd = ec.netgraph.node_annotation(nid, "ccnd")
+    
+    # Add a CCN cat application to the planetlab node
+    ccncat = ec.register_resource("linux::CCNCat")
+    ec.set(ccncat, "contentName", content_name)
+    ec.register_connection(ccncat, ccnd)
+
+def add_pl_fib_entry(ec, nid1, nid2):
+    # Retrieve annotations from netgraph
+    ccnd1 = ec.netgraph.node_annotation(nid1, "ccnd")
+    hostname2 = ec.netgraph.node_annotation(nid2, "hostname")
+    
+    # Add a FIB entry between one planetlab node and its peer
+    entry = ec.register_resource("linux::FIBEntry")
+    ec.set(entry, "host", hostname2)
+    ec.register_connection(entry, ccnd1)
+
+    # Collector to retrieve peering ping output (to measure neighbors delay)
+    ec.enable_trace(entry, "ping")
+    collector = add_collector(ec, "ping", str(nid1))
+    ec.register_connection(collector, entry)
+
+    return entry
+
+def add_node(ec, nid):
+    ### Add CCN nodes (ec.netgraph holds the topology graph)
+    add_dce_host(ec, nid)
+    add_dce_ccnd(ec, nid)
+        
+    if nid == ec.netgraph.targets()[0]:
+        add_dce_ccnr(ec, nid)
+
+    if nid == ec.netgraph.sources()[0]:
+        add_dce_ccncat(ec, nid)
+
+def add_edge(ec, nid1, nid2):
+    #### Add connections between CCN nodes
+    add_pl_fib_entry(ec, nid1, nid2)
+    add_pl_fib_entry(ec, nid2, nid1)
+
+def add_node(ec, nid):
+    ### Add CCN nodes (ec.netgraph holds the topology graph)
+    add_pl_host(ec, nid)
+    add_pl_ccnd(ec, nid)
+        
+    if nid == ec.netgraph.targets()[0]:
+        add_pl_ccnr(ec, nid)
+
+    if nid == ec.netgraph.sources()[0]:
+        add_pl_ccncat(ec, nid)
+
+def wait_guids(ec):
+    return ec.filter_resources("linux::CCNCat")
+
+if __name__ == '__main__':
+
+    metrics = []
+
+    # topology translation to NEPI model
+    ec = ExperimentController("pl_4n_linear",
+        topo_type = TopologyType.LINEAR, 
+        node_count = 4,
+        assign_st = True,
+        assign_ips = True,
+        add_node_callback = add_node,
+       add_edge_callback = add_edge)
+
+    #### Run experiment until metric convergence
+    rnr = ExperimentRunner()
+    runs = rnr.run(ec,
+            min_runs = 10,
+            max_runs = 100, 
+            compute_metric_callback = avg_interest_rtt,
+            evaluate_convergence_callback = normal_law,
+            wait_guids = wait_guids(ec))
+   
+    ### post processing
+    post_process(ec, runs)
+
+
index ab7ef33..69f69e1 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 def add_ns3_node(ec, simu):
@@ -101,5 +103,5 @@ stdout = ec.trace(ping, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
 
index 3ce19d1..54085ab 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 def add_ns3_node(ec, simu):
@@ -97,5 +99,5 @@ stdout = ec.trace(ping, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
 
index 04a46fc..243470f 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 import os
@@ -164,7 +166,7 @@ ec.wait_finished([ccncat])
 
 stdout = ec.trace(ccncat, "stdout")
 # convert from bytes to MB
-print "%0.2f MBytes received" % (len(stdout) / 1024.0 / 1024.0 )
+print("%0.2f MBytes received" % (len(stdout) / 1024.0 / 1024.0 ))
 
 ec.shutdown()
 
index 578698c..f99ac7b 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 def add_ns3_node(ec, simu):
@@ -99,5 +101,5 @@ stdout = ec.trace(ping, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
 
index 273eb89..c751b5d 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 def add_ns3_node(ec, simu):
@@ -129,5 +131,4 @@ stdout = ec.trace(ping, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
-
+print("PING OUTPUT", stdout)
index 80c4d48..b85bdff 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 import os
@@ -143,7 +145,6 @@ ec.wait_finished([ccncat])
 
 stdout = ec.trace(ccncat, "stdout")
 # convert from bytes to MB
-print "%0.2f MBytes received" % (len(stdout) / 1024.0 / 1024.0 )
+print("%0.2f MBytes received" % (len(stdout) / 1024.0 / 1024.0 ))
 
 ec.shutdown()
-
index a8119cd..0ba078c 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 def add_ns3_node(ec, simu):
@@ -79,5 +81,5 @@ stdout = ec.trace(ccnpeek, "stdout")
 
 ec.shutdown()
 
-print "PEEK received", stdout
+print("PEEK received", stdout)
 
index 3da1e14..cdcfd6b 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 def add_ns3_node(ec, simu):
@@ -93,5 +95,5 @@ stdout = ec.trace(ping, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
 
index 4b5d6f4..39ea8f0 100644 (file)
@@ -31,6 +31,8 @@
 #     0 ------- network -------- 1
 #
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController
 
 from optparse import OptionParser
@@ -151,4 +153,4 @@ f.close()
 
 ec.shutdown()
 
-print "Transfered FILE stored localy at video.ts"
+print("Transfered FILE stored localy at video.ts")
index fb4f74d..0395a40 100644 (file)
@@ -40,6 +40,8 @@
 # $ cd <path-to-nepi>
 # python examples/linux/ccn_advanced_transfer.py -a <hostname1> -b <hostname2> -u <username> -i <ssh-key>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController
 from nepi.execution.resource import ResourceAction, ResourceState
 
@@ -212,5 +214,5 @@ f.close()
 # Shutdown the experiment controller
 ec.shutdown()
 
-print "Transfered FILE stored localy at video.ts"
+print("Transfered FILE stored localy at video.ts")
 
index 424536b..2e026b5 100644 (file)
@@ -22,6 +22,8 @@
 # $ cd <path-to-nepi>
 # python examples/linux/hello_world.py -a <hostname> -u <username> -i <ssh-key>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 from optparse import OptionParser, SUPPRESS_HELP
@@ -66,7 +68,7 @@ ec.deploy()
 
 ec.wait_finished(app)
 
-print ec.trace(app, "stdout")
+print(ec.trace(app, "stdout"))
 
 ec.shutdown()
 
index 0560337..3734af3 100644 (file)
@@ -24,6 +24,8 @@
 # $ cd <path-to-nepi>
 # python examples/linux/netcat_file_transfer.py -a <hostname1> -b <hostname2> -u <username> -i <ssh-key>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController
 from nepi.execution.resource import ResourceAction, ResourceState
 
@@ -138,5 +140,5 @@ f.close()
 
 ec.shutdown()
 
-print "Total bytes transfered saved to bw.txt..."
+print("Total bytes transfered saved to bw.txt...")
 
index d127fc9..0200b54 100644 (file)
@@ -22,6 +22,7 @@
 # $ cd <path-to-nepi>
 # python examples/linux/ping.py -a <hostname> -u <username> -i <ssh-key>
 
+from __future__ import print_function
 
 from nepi.execution.ec import ExperimentController 
 
@@ -61,7 +62,7 @@ ec.deploy()
 
 ec.wait_finished(app)
 
-print ec.trace(app, "stdout")
+print(ec.trace(app, "stdout"))
 
 ec.shutdown()
 
index 3533e01..4b5d83d 100644 (file)
@@ -21,6 +21,8 @@
 # $ cd <path-to-nepi>
 # python examples/linux/vlc_streaming.py -a <hostname1> -b <hostname2> -u <username> -i <ssh-key>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController
 from nepi.execution.resource import ResourceState, ResourceAction 
 
@@ -120,5 +122,5 @@ f.close()
 
 ec.shutdown()
 
-print "Streamed VIDEO stored localy at video.ts"
+print("Streamed VIDEO stored localy at video.ts")
 
index 0bb1732..e69a7e8 100644 (file)
@@ -21,6 +21,8 @@
 # This example must be executed as root: 
 # $ sudo PYTHONPATH=$PYTHONPATH:src python examples/netns/local_switch_ping.py
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 ec = ExperimentController(exp_id = "netns-local-p2p-ping")
@@ -73,4 +75,4 @@ stdout = ec.trace(ping, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
index 5c2de47..5d7593f 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 """ 
 network topology:
   
@@ -181,4 +183,4 @@ stdout = ec.trace(simu, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
index 1becb79..97afd3f 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 ec = ExperimentController(exp_id = "ns3-local-csma-ping")
@@ -91,4 +93,4 @@ stdout = ec.trace(simu, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
index d8d6c2c..f51986b 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 """ 
 network topology:
  
@@ -197,5 +199,5 @@ stdout = ec.trace(simu, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
 
index 4bd8200..1741cdd 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 ec = ExperimentController(exp_id = "ns3-local-p2p-ping")
@@ -91,4 +93,4 @@ stdout = ec.trace(simu, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
index 40b7570..8c17d7f 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 ec = ExperimentController(exp_id = "ns3-local-wifi-ping")
@@ -132,4 +134,4 @@ stdout = ec.trace(simu, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
index c1a5a8b..c3aef65 100644 (file)
@@ -1,82 +1,84 @@
-#!/usr/bin/env python\r
-#\r
-#    NEPI, a framework to manage network experiments\r
-#    Copyright (C) 2015 INRIA\r
-#\r
-#    This program is free software: you can redistribute it and/or modify\r
-#    it under the terms of the GNU General Public License version 2 as\r
-#    published by the Free Software Foundation;\r
-#\r
-#    This program is distributed in the hope that it will be useful,\r
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-#    GNU General Public License for more details.\r
-#\r
-#    You should have received a copy of the GNU General Public License\r
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
-#\r
-# Author: Damien Saucez <damien.saucez@inria.fr>\r
-#         Alina Quereilhac <alina.quereilhac@inria.fr>\r
-#\r
-\r
-#\r
-# Note: To run this experiment you need to have a PlanetLab account.\r
-#\r
-# This experiment consists of a simulated wireless sensor network (ns-3)\r
-# with one fixed access point (AP), running an agent application, and several\r
-# mobile stations that run a transmitter application to send messages to\r
-# the AP.\r
-#\r
-# The experiment uses 2 networks like the one described above, running in 2\r
-# independent ns-3 instances in remote hosts, and transparently connected\r
-# through a UDP tunnel.\r
-\r
-#\r
-# command line:\r
-#\r
-# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/ditributed.py\r
-#\r
-\r
-import os\r
-\r
-from nepi.execution.ec import ExperimentController\r
-from nepi.execution.resource import ResourceState, ResourceManager\r
-\r
-from topology import *\r
-\r
-# tunning\r
-os.environ["NEPI_NTHREADS"] = "1"\r
-ResourceManager._reschedule_delay = "0s"\r
-\r
-# list of hosts for running the experiment on\r
-hostname1 = "onelab4.warsaw.rd.tp.pl"\r
-hostname2 = "planet2.servers.ua.pt"\r
-\r
-(username, pl_user, pl_password, ssh_key, node_count) = get_options()\r
-\r
-ec = ExperimentController(exp_id="distributed")\r
-\r
-host1, simu1 = add_host_simu(ec, hostname1, username, pl_user, pl_password, \r
-        ssh_key)\r
-\r
-ap1, agent1 = build_ns3_topology(ec, simu1, node_count, network="10.1.0.0", \r
-        prefixlen="24", agent_ip="10.1.0.1")\r
-\r
-host2, simu2 = add_host_simu(ec, hostname2, username, pl_user, pl_password, ssh_key)\r
-ap2, agent2 = build_ns3_topology(ec, simu2, node_count, network="10.2.0.0", prefixlen="24", agent_ip="10.1.0.1")\r
-\r
-fddev1 = add_fdnet_device(ec, ap1, "10.0.0.1", "30")\r
-fddev2 = add_fdnet_device(ec, ap2, "10.0.0.2", "30")\r
-\r
-connect_with_udp_tunnel(ec, fddev1, fddev2)\r
-\r
-ec.deploy()\r
-\r
-ec.wait_finished([simu1, simu2])\r
-\r
-stdout = ec.trace(agent1, "stdout")\r
-print " Agent says:"\r
-print stdout\r
-\r
-ec.shutdown()\r
-\r
+#!/usr/bin/env python
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2015 INRIA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License version 2 as
+#    published by the Free Software Foundation;
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+# Author: Damien Saucez <damien.saucez@inria.fr>
+#         Alina Quereilhac <alina.quereilhac@inria.fr>
+#
+
+#
+# Note: To run this experiment you need to have a PlanetLab account.
+#
+# This experiment consists of a simulated wireless sensor network (ns-3)
+# with one fixed access point (AP), running an agent application, and several
+# mobile stations that run a transmitter application to send messages to
+# the AP.
+#
+# The experiment uses 2 networks like the one described above, running in 2
+# independent ns-3 instances in remote hosts, and transparently connected
+# through a UDP tunnel.
+
+#
+# command line:
+#
+# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/ditributed.py
+#
+
+from __future__ import print_function
+
+import os
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.resource import ResourceState, ResourceManager
+
+from topology import *
+
+# tunning
+os.environ["NEPI_NTHREADS"] = "1"
+ResourceManager._reschedule_delay = "0s"
+
+# list of hosts for running the experiment on
+hostname1 = "onelab4.warsaw.rd.tp.pl"
+hostname2 = "planet2.servers.ua.pt"
+
+(username, pl_user, pl_password, ssh_key, node_count) = get_options()
+
+ec = ExperimentController(exp_id="distributed")
+
+host1, simu1 = add_host_simu(ec, hostname1, username, pl_user, pl_password, 
+        ssh_key)
+
+ap1, agent1 = build_ns3_topology(ec, simu1, node_count, network="10.1.0.0", 
+        prefixlen="24", agent_ip="10.1.0.1")
+
+host2, simu2 = add_host_simu(ec, hostname2, username, pl_user, pl_password, ssh_key)
+ap2, agent2 = build_ns3_topology(ec, simu2, node_count, network="10.2.0.0", prefixlen="24", agent_ip="10.1.0.1")
+
+fddev1 = add_fdnet_device(ec, ap1, "10.0.0.1", "30")
+fddev2 = add_fdnet_device(ec, ap2, "10.0.0.2", "30")
+
+connect_with_udp_tunnel(ec, fddev1, fddev2)
+
+ec.deploy()
+
+ec.wait_finished([simu1, simu2])
+
+stdout = ec.trace(agent1, "stdout")
+print(" Agent says:")
+print(stdout)
+
+ec.shutdown()
+
index 0b36478..630fec2 100644 (file)
-#!/usr/bin/env python\r
-#\r
-#    NEPI, a framework to manage network experiments\r
-#    Copyright (C) 2015 INRIA\r
-#\r
-#    This program is free software: you can redistribute it and/or modify\r
-#    it under the terms of the GNU General Public License version 2 as\r
-#    published by the Free Software Foundation;\r
-#\r
-#    This program is distributed in the hope that it will be useful,\r
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-#    GNU General Public License for more details.\r
-#\r
-#    You should have received a copy of the GNU General Public License\r
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
-#\r
-# Author: Damien Saucez <damien.saucez@inria.fr>\r
-#         Alina Quereilhac <alina.quereilhac@inria.fr>\r
-#\r
-\r
-#\r
-# Note that to run this experiment you need to have a PlanetLab account.\r
-#\r
-# This experiment consists of a simulated wireless sensor network (ns-3)\r
-# with one fixed access point (AP), running an agent application, and several\r
-# mobile stations that run a transmitter application to send messages to\r
-# the AP.\r
-#\r
-# One of the transmitter applications runs outside the simulation, on\r
-# the host, and sends messages to the AP through the FdNetDevice/TAP\r
-# link.\r
-#\r
-\r
-#\r
-# command line:\r
-#\r
-# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/hybrid.py\r
-#\r
-\r
-import os\r
-\r
-from nepi.execution.ec import ExperimentController\r
-from nepi.execution.resource import ResourceState, ResourceManager\r
-\r
-from topology import *\r
-\r
-# tunning\r
-os.environ["NEPI_NTHREADS"] = "1"\r
-ResourceManager._reschedule_delay = "0s"\r
-\r
-# list of hosts for running the experiment on\r
-hostname1 = "onelab4.warsaw.rd.tp.pl"\r
-hostname2 = "planet2.servers.ua.pt"\r
-\r
-(username, pl_user, pl_password, ssh_key, node_count) = get_options()\r
-\r
-ec = ExperimentController(exp_id="hybrid")\r
-\r
-host, simu = add_host_simu(ec, hostname1, username, pl_user, pl_password, \r
-        ssh_key)\r
-\r
-ap, agent = build_ns3_topology(ec, simu, node_count, network="192.168.3.0", \r
-        prefixlen="25", agent_ip="192.168.3.1")\r
-\r
-fddev = add_fdnet_device(ec, ap, "192.168.3.129", "25")\r
-\r
-tap = ec.register_resource("planetlab::Tap")\r
-ec.set(tap, "ip", "192.168.3.130")\r
-ec.set(tap, "prefix", "25")\r
-ec.set(tap, "pointopoint", "192.168.3.129")\r
-ec.register_connection(host, tap)  \r
-\r
-connect_with_virtual_link(ec, tap, fddev)\r
-\r
-add_ns3_route(ec, ap, network="192.168.3.128", prefixlen="25", nexthop="192.168.3.1")\r
-add_planetlab_route(ec, tap, network="192.168.3.0", prefixlen="25", nexthop="192.168.3.129")\r
-\r
-transmitter = ec.register_resource("linux::Application")\r
-ec.set(transmitter, "sources", "code/transmitter.c")\r
-ec.set(transmitter, "build", "gcc ${SRC}/transmitter.c -o ${BIN}/transmitter")\r
-ec.set(transmitter, "command", "${BIN}/transmitter 192.168.3.1")\r
-ec.register_connection(transmitter, host)\r
-\r
-ec.deploy()\r
-\r
-ec.wait_finished([simu, transmitter])\r
-\r
-stdout = ec.trace(agent, "stdout")\r
-print " Agent says: "\r
-print stdout\r
-\r
-stdout = ec.trace(transmitter, "stdout")\r
-print " Live transmitter output: "\r
-print stdout\r
-\r
-ec.shutdown()\r
-\r
-\r
+#!/usr/bin/env python
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2015 INRIA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License version 2 as
+#    published by the Free Software Foundation;
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+# Author: Damien Saucez <damien.saucez@inria.fr>
+#         Alina Quereilhac <alina.quereilhac@inria.fr>
+#
+
+#
+# Note that to run this experiment you need to have a PlanetLab account.
+#
+# This experiment consists of a simulated wireless sensor network (ns-3)
+# with one fixed access point (AP), running an agent application, and several
+# mobile stations that run a transmitter application to send messages to
+# the AP.
+#
+# One of the transmitter applications runs outside the simulation, on
+# the host, and sends messages to the AP through the FdNetDevice/TAP
+# link.
+#
+
+#
+# command line:
+#
+# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/hybrid.py
+#
+
+from __future__ import print_function
+
+import os
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.resource import ResourceState, ResourceManager
+
+from topology import *
+
+# tunning
+os.environ["NEPI_NTHREADS"] = "1"
+ResourceManager._reschedule_delay = "0s"
+
+# list of hosts for running the experiment on
+hostname1 = "onelab4.warsaw.rd.tp.pl"
+hostname2 = "planet2.servers.ua.pt"
+
+(username, pl_user, pl_password, ssh_key, node_count) = get_options()
+
+ec = ExperimentController(exp_id="hybrid")
+
+host, simu = add_host_simu(ec, hostname1, username, pl_user, pl_password, 
+        ssh_key)
+
+ap, agent = build_ns3_topology(ec, simu, node_count, network="192.168.3.0", 
+        prefixlen="25", agent_ip="192.168.3.1")
+
+fddev = add_fdnet_device(ec, ap, "192.168.3.129", "25")
+
+tap = ec.register_resource("planetlab::Tap")
+ec.set(tap, "ip", "192.168.3.130")
+ec.set(tap, "prefix", "25")
+ec.set(tap, "pointopoint", "192.168.3.129")
+ec.register_connection(host, tap)  
+
+connect_with_virtual_link(ec, tap, fddev)
+
+add_ns3_route(ec, ap, network="192.168.3.128", prefixlen="25", nexthop="192.168.3.1")
+add_planetlab_route(ec, tap, network="192.168.3.0", prefixlen="25", nexthop="192.168.3.129")
+
+transmitter = ec.register_resource("linux::Application")
+ec.set(transmitter, "sources", "code/transmitter.c")
+ec.set(transmitter, "build", "gcc ${SRC}/transmitter.c -o ${BIN}/transmitter")
+ec.set(transmitter, "command", "${BIN}/transmitter 192.168.3.1")
+ec.register_connection(transmitter, host)
+
+ec.deploy()
+
+ec.wait_finished([simu, transmitter])
+
+stdout = ec.trace(agent, "stdout")
+print(" Agent says: ")
+print(stdout)
+
+stdout = ec.trace(transmitter, "stdout")
+print(" Live transmitter output: ")
+print(stdout)
+
+ec.shutdown()
+
+
index a0be0a9..fa53457 100644 (file)
@@ -1,85 +1,87 @@
-#!/usr/bin/env python\r
-#\r
-#    NEPI, a framework to manage network experiments\r
-#    Copyright (C) 2015 INRIA\r
-#\r
-#    This program is free software: you can redistribute it and/or modify\r
-#    it under the terms of the GNU General Public License version 2 as\r
-#    published by the Free Software Foundation;\r
-#\r
-#    This program is distributed in the hope that it will be useful,\r
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-#    GNU General Public License for more details.\r
-#\r
-#    You should have received a copy of the GNU General Public License\r
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
-#\r
-# Author: Damien Saucez <damien.saucez@inria.fr>\r
-#         Alina Quereilhac <alina.quereilhac@inria.fr>\r
-#\r
-\r
-#\r
-# Note: To run this experiment you need to have a PlanetLab account.\r
-#\r
-# This experiment consists of a simulated wireless sensor network (ns-3)\r
-# with one fixed access point (AP), running an agent application, and several\r
-# mobile stations that run a transmitter application to send messages to\r
-# the AP.\r
-#\r
-# The same experiment described above is run in parallel with different\r
-# number of mobile stations in 2 PlanetLab hosts.\r
-#\r
-\r
-#\r
-# command line:\r
-#\r
-# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/parallel.py\r
-#\r
-\r
-import os\r
-\r
-from topology import *\r
-\r
-from nepi.execution.ec import ExperimentController\r
-from nepi.execution.resource import ResourceState, ResourceManager\r
-\r
-# tunning\r
-os.environ["NEPI_NTHREADS"] = "1"\r
-ResourceManager._reschedule_delay = "0s"\r
-\r
-# list of hosts for running the experiment on\r
-hostname1 = "onelab4.warsaw.rd.tp.pl"\r
-hostname2 = "planet2.servers.ua.pt"\r
-\r
-(username, pl_user, pl_password, ssh_key, node_count) = get_options()\r
-\r
-ec = ExperimentController(exp_id="parallel")\r
-counts = [node_count, 10]\r
-hosts = [hostname1, hostname2]\r
-\r
-simulations = []\r
-agents = []\r
-\r
-for hostname in hosts:\r
-    host, simu = add_host_simu(ec, hostname, username, pl_user, pl_password, \r
-            ssh_key)\r
-    simulations.append(simu)\r
-\r
-    node_count = counts.pop()\r
-    ap, agent = build_ns3_topology(ec, simu, node_count, network="10.1.0.0", \r
-            prefixlen="24", agent_ip="10.1.0.1")\r
-    agents.append(agent)\r
-\r
-ec.deploy()\r
-\r
-ec.wait_finished(simulations)\r
-\r
-for agent in agents:\r
-    stdout = ec.trace(agent, "stdout")\r
-    print " Agent says:"\r
-    print stdout\r
-\r
-ec.shutdown()\r
-\r
-\r
+#!/usr/bin/env python
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2015 INRIA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License version 2 as
+#    published by the Free Software Foundation;
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+# Author: Damien Saucez <damien.saucez@inria.fr>
+#         Alina Quereilhac <alina.quereilhac@inria.fr>
+#
+
+#
+# Note: To run this experiment you need to have a PlanetLab account.
+#
+# This experiment consists of a simulated wireless sensor network (ns-3)
+# with one fixed access point (AP), running an agent application, and several
+# mobile stations that run a transmitter application to send messages to
+# the AP.
+#
+# The same experiment described above is run in parallel with different
+# number of mobile stations in 2 PlanetLab hosts.
+#
+
+#
+# command line:
+#
+# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/parallel.py
+#
+
+from __future__ import print_function
+
+import os
+
+from topology import *
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.resource import ResourceState, ResourceManager
+
+# tunning
+os.environ["NEPI_NTHREADS"] = "1"
+ResourceManager._reschedule_delay = "0s"
+
+# list of hosts for running the experiment on
+hostname1 = "onelab4.warsaw.rd.tp.pl"
+hostname2 = "planet2.servers.ua.pt"
+
+(username, pl_user, pl_password, ssh_key, node_count) = get_options()
+
+ec = ExperimentController(exp_id="parallel")
+counts = [node_count, 10]
+hosts = [hostname1, hostname2]
+
+simulations = []
+agents = []
+
+for hostname in hosts:
+    host, simu = add_host_simu(ec, hostname, username, pl_user, pl_password, 
+            ssh_key)
+    simulations.append(simu)
+
+    node_count = counts.pop()
+    ap, agent = build_ns3_topology(ec, simu, node_count, network="10.1.0.0", 
+            prefixlen="24", agent_ip="10.1.0.1")
+    agents.append(agent)
+
+ec.deploy()
+
+ec.wait_finished(simulations)
+
+for agent in agents:
+    stdout = ec.trace(agent, "stdout")
+    print(" Agent says:")
+    print(stdout)
+
+ec.shutdown()
+
+
index a592e81..57bda49 100644 (file)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 from optparse import OptionParser
@@ -113,4 +115,4 @@ stdout = ec.trace(simu, "stdout")
 
 ec.shutdown()
 
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
index 173b4fd..d5e02c7 100644 (file)
@@ -44,6 +44,8 @@
 #        - t3 (t2 + 2s) : Kill the application
 #
 
+from __future__ import print_function
+
 from nepi.execution.resource import ResourceAction, ResourceState
 from nepi.execution.ec import ExperimentController
 
@@ -130,7 +132,7 @@ ec.wait_finished([app1])
 
 # Retrieve the output of the ping command
 ping_output = ec.trace(app1, "stdout")
-print "\n PING OUTPUT\n", ping_output, "\n"
+print("\n PING OUTPUT\n", ping_output, "\n")
 
 # Stop Experiment
 ec.shutdown()
index 1c4d1ce..b312abd 100644 (file)
@@ -45,6 +45,8 @@
 #        - t3 (t2 + 2s) : Kill the application
 #
 
+from __future__ import print_function
+
 from nepi.execution.resource import ResourceAction, ResourceState
 from nepi.execution.ec import ExperimentController
 
@@ -174,7 +176,7 @@ ec.wait_finished([app4, app5])
 
 # Retrieve the bytes transmitted output and print it
 byte_count = ec.trace(app3, "stdout")
-print "BYTES transmitted", byte_count
+print("BYTES transmitted", byte_count)
 
 # Stop Experiment
 ec.shutdown()
index 40f8012..6deaf18 100644 (file)
@@ -45,6 +45,8 @@
 #        - t3 (t2 + 2s) : Kill the application
 #
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController
 from nepi.execution.resource import ResourceAction, ResourceState
 
@@ -148,7 +150,7 @@ ec.wait_finished([app1])
 
 # Retrieve the output of the ping command
 ping_output = ec.trace(app1, "stdout")
-print "\n PING OUTPUT\n", ping_output, "\n"
+print("\n PING OUTPUT\n", ping_output, "\n")
 
 # Stop Experiment
 ec.shutdown()
index 95b74c0..eb615fe 100644 (file)
@@ -46,6 +46,8 @@
 #        - t3 (t2 + 2s) : Kill the application
 #
 
+from __future__ import print_function
+
 from nepi.execution.resource import ResourceAction, ResourceState
 from nepi.execution.ec import ExperimentController
 
@@ -156,7 +158,7 @@ ec.wait_finished([app2])
 
 # Retrieve the bytes transmitted count and print it
 byte_count = ec.trace(app2, "stdout")
-print "BYTES transmitted", byte_count
+print("BYTES transmitted", byte_count)
 
 ## If you redirected the video to standard output, you can try to 
 ## retrieve the stdout of the VLC client
index 014d3eb..6d70818 100644 (file)
-#!/usr/bin/env python\r
-#\r
-#    NEPI, a framework to manage network experiments\r
-#    Copyright (C) 2013 INRIA\r
-#\r
-#    This program is free software: you can redistribute it and/or modify\r
-#    it under the terms of the GNU General Public License version 2 as\r
-#    published by the Free Software Foundation;\r
-#\r
-#    This program is distributed in the hope that it will be useful,\r
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-#    GNU General Public License for more details.\r
-#\r
-#    You should have received a copy of the GNU General Public License\r
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
-#\r
-# Author: Alina Quereilhac <alina.quereilhac@inria.fr>\r
-#         Maksym Gabielkov <maksym.gabielkovc@inria.fr>\r
-#\r
-\r
-## This is a maintenance script used to bootstrap the nodes from\r
-## Nitos testbed (NITLab) before running a OMF experiment using\r
-## Nitos nodes. This fixes the problem of Resource Controller \r
-## misbehaving by restarting it and it also loads the ath5k driver.\r
-\r
-# Example of how to run this experiment (replace with your information):\r
-#\r
-# $ cd <path-to-nepi>\r
-# python examples/linux/nitos_testbed_bootstrap.py -H <omf.nitos.node0XX,omf.nitos.node0ZZ,..> -U <node-username> -i <ssh-key> -g <nitos-gateway> -u <nitos-slice>\r
-#\r
-\r
-from nepi.execution.ec import ExperimentController\r
-from nepi.execution.resource import ResourceAction, ResourceState\r
-\r
-from optparse import OptionParser\r
-import os\r
-\r
-usage = ("usage: %prog -H <list-of-nitos-hosts> -U <node-username> -i <ssh-key> -g <nitos-gateway> -u <slicename>")\r
-\r
-parser = OptionParser(usage = usage)\r
-parser.add_option("-H", "--hosts", dest="hosts", \r
-        help="Space separated list of hosts", type="str")\r
-parser.add_option("-U", "--username", dest="username", \r
-        help="Username for the nitos hosts (usually root)", \r
-        type="str", default="root" )\r
-parser.add_option("-g", "--gateway", dest="gateway", \r
-        help="Nitos gateway hostname", \r
-        type="str", default="nitlab.inf.uth.gr")\r
-parser.add_option("-u", "--gateway-user", dest="gateway_username", \r
-        help="Nitos gateway username (slicename)", \r
-        type="str", default="nitlab.inf.uth.gr")\r
-parser.add_option("-i", "--ssh-key", dest="ssh_key", \r
-        help="Path to private SSH key to be used for connection", \r
-        type="str")\r
-(options, args) = parser.parse_args()\r
-\r
-hosts = options.hosts\r
-username = options.username\r
-gateway = options.gateway\r
-gateway_username = options.gateway_username\r
-identity = options.ssh_key\r
-\r
-apps = []\r
-\r
-ec = ExperimentController(exp_id="nitos_bootstrap")\r
-\r
-gw_node = ec.register_resource("linux::Node")\r
-ec.set(gw_node, "username", gateway_username)\r
-ec.set(gw_node, "hostname", gateway)\r
-ec.set(gw_node, "identity", identity)\r
-ec.set(gw_node, "cleanExperiment", True)\r
-\r
-load_cmd = "omf load -i nepi_OMF6_VLC_baseline_grid.ndz -t %s" % hosts \r
-load_app = ec.register_resource("linux::Application")\r
-ec.set(load_app, "command", load_cmd)\r
-ec.register_connection(load_app, gw_node)\r
-\r
-reboot_cmd = "omf tell -a on -t %s" % hosts \r
-reboot_app = ec.register_resource("linux::Application")\r
-ec.set(reboot_app, "command", reboot_cmd)\r
-ec.register_connection(reboot_app, gw_node)\r
-\r
-ec.register_condition(reboot_app, ResourceAction.START, load_app, \r
-            ResourceState.STOPPED, time="60s") \r
-\r
-hosts = hosts.split(",")\r
-\r
-for hostname in hosts:\r
-    host = hostname.split(".")[-1]\r
-    node = ec.register_resource("linux::Node")\r
-    ec.set(node, "username", username)\r
-    ec.set(node, "hostname", host)\r
-    ec.set(node, "identity", identity)\r
-    ec.set(node, "gateway", gateway)\r
-    ec.set(node, "gatewayUser", gateway_username)\r
-    ec.set(node, "cleanExperiment", True)\r
-    ec.register_condition(node, ResourceAction.DEPLOY, reboot_app, \r
-            ResourceState.STOPPED, time="300s") \r
\r
-    modprobe_app = ec.register_resource("linux::Application")\r
-    ec.set(modprobe_app, "command", "modprobe ath5k && ip a | grep wlan0")\r
-    ec.register_connection(modprobe_app, node)\r
-    apps.append(modprobe_app)\r
-\r
-    rc_app = ec.register_resource("linux::Application")\r
-    ec.set(rc_app, "command", "service omf_rc stop; service omf_rc start")\r
-    ec.register_connection(rc_app, node)\r
-    apps.append(rc_app)\r
-\r
-print "This might take time..."\r
-\r
-ec.deploy(wait_all_ready=False)\r
-\r
-ec.wait_finished(apps)\r
-\r
-print ec.trace(load_app, "stdout")\r
-print ec.trace(reboot_app, "stdout")\r
-\r
-for app in apps:\r
-    print ec.trace(app, "stdout")\r
-\r
-ec.shutdown()\r
-\r
+#!/usr/bin/env python
+#
+#    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 version 2 as
+#    published by the Free Software Foundation;
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+#         Maksym Gabielkov <maksym.gabielkovc@inria.fr>
+#
+
+## This is a maintenance script used to bootstrap the nodes from
+## Nitos testbed (NITLab) before running a OMF experiment using
+## Nitos nodes. This fixes the problem of Resource Controller 
+## misbehaving by restarting it and it also loads the ath5k driver.
+
+# Example of how to run this experiment (replace with your information):
+#
+# $ cd <path-to-nepi>
+# python examples/linux/nitos_testbed_bootstrap.py -H <omf.nitos.node0XX,omf.nitos.node0ZZ,..> -U <node-username> -i <ssh-key> -g <nitos-gateway> -u <nitos-slice>
+#
+
+from __future__ import print_function
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.resource import ResourceAction, ResourceState
+
+from optparse import OptionParser
+import os
+
+usage = ("usage: %prog -H <list-of-nitos-hosts> -U <node-username> -i <ssh-key> -g <nitos-gateway> -u <slicename>")
+
+parser = OptionParser(usage = usage)
+parser.add_option("-H", "--hosts", dest="hosts", 
+        help="Space separated list of hosts", type="str")
+parser.add_option("-U", "--username", dest="username", 
+        help="Username for the nitos hosts (usually root)", 
+        type="str", default="root" )
+parser.add_option("-g", "--gateway", dest="gateway", 
+        help="Nitos gateway hostname", 
+        type="str", default="nitlab.inf.uth.gr")
+parser.add_option("-u", "--gateway-user", dest="gateway_username", 
+        help="Nitos gateway username (slicename)", 
+        type="str", default="nitlab.inf.uth.gr")
+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()
+
+hosts = options.hosts
+username = options.username
+gateway = options.gateway
+gateway_username = options.gateway_username
+identity = options.ssh_key
+
+apps = []
+
+ec = ExperimentController(exp_id="nitos_bootstrap")
+
+gw_node = ec.register_resource("linux::Node")
+ec.set(gw_node, "username", gateway_username)
+ec.set(gw_node, "hostname", gateway)
+ec.set(gw_node, "identity", identity)
+ec.set(gw_node, "cleanExperiment", True)
+
+load_cmd = "omf load -i nepi_OMF6_VLC_baseline_grid.ndz -t %s" % hosts 
+load_app = ec.register_resource("linux::Application")
+ec.set(load_app, "command", load_cmd)
+ec.register_connection(load_app, gw_node)
+
+reboot_cmd = "omf tell -a on -t %s" % hosts 
+reboot_app = ec.register_resource("linux::Application")
+ec.set(reboot_app, "command", reboot_cmd)
+ec.register_connection(reboot_app, gw_node)
+
+ec.register_condition(reboot_app, ResourceAction.START, load_app, 
+            ResourceState.STOPPED, time="60s") 
+
+hosts = hosts.split(",")
+
+for hostname in hosts:
+    host = hostname.split(".")[-1]
+    node = ec.register_resource("linux::Node")
+    ec.set(node, "username", username)
+    ec.set(node, "hostname", host)
+    ec.set(node, "identity", identity)
+    ec.set(node, "gateway", gateway)
+    ec.set(node, "gatewayUser", gateway_username)
+    ec.set(node, "cleanExperiment", True)
+    ec.register_condition(node, ResourceAction.DEPLOY, reboot_app, 
+            ResourceState.STOPPED, time="300s") 
+    modprobe_app = ec.register_resource("linux::Application")
+    ec.set(modprobe_app, "command", "modprobe ath5k && ip a | grep wlan0")
+    ec.register_connection(modprobe_app, node)
+    apps.append(modprobe_app)
+
+    rc_app = ec.register_resource("linux::Application")
+    ec.set(rc_app, "command", "service omf_rc stop; service omf_rc start")
+    ec.register_connection(rc_app, node)
+    apps.append(rc_app)
+
+print("This might take time...")
+
+ec.deploy(wait_all_ready=False)
+
+ec.wait_finished(apps)
+
+print(ec.trace(load_app, "stdout"))
+print(ec.trace(reboot_app, "stdout"))
+
+for app in apps:
+    print(ec.trace(app, "stdout"))
+
+ec.shutdown()
+
index 714d5e9..91e1e49 100644 (file)
@@ -82,11 +82,11 @@ app3 = ec.register_resource("omf::Application")
 ec.set(app3, 'command', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc rtp://192.168.0.3:1234")
 
 
-       "echo -e 'new TEST broadcast enabled loop\\n"\
-       "setup TEST input %s\\n"\
-       "setup TEST output #rtp{mux=ts,sdp=rtsp://0.0.0.0:8554/TEST}\\n\\n"\
-       "new test_sched schedule enabled\\n"\
-       "setup test_sched append control TEST play' > ${SOURCES}/VOD.vlm" % mv)
+#       "echo -e 'new TEST broadcast enabled loop\\n"\
+#       "setup TEST input %s\\n"\
+#       "setup TEST output #rtp{mux=ts,sdp=rtsp://0.0.0.0:8554/TEST}\\n\\n"\
+#       "new test_sched schedule enabled\\n"\
+#       "setup test_sched append control TEST play' > ${SOURCES}/VOD.vlm" % mv)
 
 
 
index 7decb71..44d0ae9 100644 (file)
@@ -42,6 +42,8 @@
 #
 #
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController
 from nepi.execution.resource import ResourceAction, ResourceState
 
@@ -126,7 +128,7 @@ ec.deploy()
 
 ec.wait_finished([app1, app2])
 
-print ec.trace(app1, "stdout")
+print(ec.trace(app1, "stdout"))
 
 # Stop Experiment
 ec.shutdown()
index becd61c..7f50846 100644 (file)
@@ -32,6 +32,8 @@
 # $ PYTHONPATH=$PYTHONPATH:src/ python examples/openvswitch/ovs_ping.py -n "192.168.3.0/24" -s <slicename> -i /~/.ssh/id_rsa
 #
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController
 
 import os
@@ -153,9 +155,7 @@ ec.wait_finished([app])
 # Retreive ping results and save them in a file
 ping = ec.trace(app, "stdout")
 
-print ping
+print(ping)
 
 # Delete the overlay network
 ec.shutdown()
-
-
index 84c28d0..a28bef2 100644 (file)
@@ -33,6 +33,8 @@
 # $ PYTHONPATH=$PYTHONPATH:src/ python examples/openvswitch/ovs_ping_2_switches.py -n "192.168.3.0/24" -C "1.1.1.1" -s <slicename> -i /~/.ssh/id_rsa
 #
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController
 
 import os
@@ -202,5 +204,4 @@ stdout = ec.trace(app, "stdout")
 # Delete the overlay network
 ec.shutdown()
 
-print stdout
-
+print(stdout)
index 335d877..c97b3a7 100644 (file)
@@ -32,7 +32,7 @@
 # $ PYTHONPATH=$PYTHONPATH:src/ python examples/openvswitch/ovs_ping_3_switches.py -n "192.168.3.0/24" -C "1.1.1.1" -s <slicename> -i /~/.ssh/id_rsa
 #
 
-
+from __future__ import print_function
 
 from nepi.execution.ec import ExperimentController
 
@@ -241,11 +241,9 @@ ec.wait_finished(apps.values())
 # collect results
 for key, app in apps.iteritems():
     stdout = ec.trace(app, "stdout")
-    print "***************************", key, "************************"
-    print stdout
-    print "\n"
+    print("***************************", key, "************************")
+    print(stdout)
+    print("\n")
 
 # Delete the overlay network
 ec.shutdown()
-
-
index 6ca7cff..64c7888 100644 (file)
@@ -31,6 +31,8 @@
 #     0 ------- network -------- 1
 #
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController
 
 from optparse import OptionParser, SUPPRESS_HELP
@@ -164,5 +166,5 @@ f.close()
 
 ec.shutdown()
 
-print "Transfered FILE stored localy at video.ts"
+print("Transfered FILE stored localy at video.ts")
 
index c481278..f35ea70 100644 (file)
@@ -24,6 +24,7 @@
 # $ cd <path-to-nepi>
 # python examples/planetlab/ping.py -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key>  
 
+from __future__ import print_function
 
 from nepi.execution.ec import ExperimentController
 
@@ -86,7 +87,7 @@ ec.wait_finished(app)
 
 trace = ec.trace(app, "stdout")
 
-print "PING outout ", trace
+print("PING outout ", trace)
 
 # Do the experiment controller shutdown
 ec.shutdown()
index 8f9c3cf..f21d282 100644 (file)
@@ -22,6 +22,8 @@
 # $ cd <path-to-nepi>
 # python examples/planetlab/ping_with_filters.py -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key>  
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController
 from nepi.execution.resource import ResourceAction, ResourceState
 
@@ -178,7 +180,7 @@ ec.deploy()
 # Wait until the applications are finish to retrive the traces:
 ec.wait_finished(apps)
 
-print "Results stored at", ec.exp_dir
+print("Results stored at", ec.exp_dir)
 
 # Do the experiment controller shutdown:
 ec.shutdown()
index 82ad58b..f856f52 100644 (file)
@@ -22,6 +22,7 @@
 # $ cd <path-to-nepi>
 # python examples/planetlab/select_nodes.py -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key> -c <country> -o <operating-system> -n <node-count> 
 
+from __future__ import print_function
 
 from nepi.execution.ec import ExperimentController
 
@@ -92,10 +93,10 @@ ec.deploy()
 
 ec.wait_deployed(nodes)
 
-print "SELECTED HOSTS"
+print("SELECTED HOSTS")
 
 for node in nodes:
-    print ec.get(node, "hostname")
+    print(ec.get(node, "hostname"))
 
 ec.shutdown()
 
index 67c82a3..cd2a9cd 100644 (file)
@@ -27,6 +27,8 @@
 # $ cd <path-to-nepi>
 # python examples/planetlab/update_fedora_repo.py -H <host1,host2,..> -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key>  
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 from optparse import OptionParser, SUPPRESS_HELP
@@ -132,9 +134,9 @@ ec.wait_finished(apps)
 
 for app in apps:
     try:
-        print ec.trace(app, "stderr")
+        print(ec.trace(app, "stderr"))
     except:
-        print "NO stderr"
+        print("NO stderr")
 
 ec.shutdown()
 
index bb2f172..18764d0 100644 (file)
@@ -16,6 +16,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 import logging
 import os
 import traceback
@@ -40,7 +42,7 @@ if LOG != 'ALL':
            log.setLevel(LOGLEVEL)
         except:
             err = traceback.format_exc()
-            print "ERROR ", err
+            print("ERROR ", err)
 else:
     # Set the logging level defined by the user for all
     # components
index fe0e45b..7d35d9e 100644 (file)
@@ -40,6 +40,8 @@
 #                        \ nid3.log
 #
 
+from __future__ import print_function
+
 import collections
 import functools
 import networkx
@@ -129,7 +131,7 @@ def parse_file(filename):
         try:
             size = int((cols[6]).replace('(',''))
         except:
-            print "interest_expiry without face id!", line
+            print("interest_expiry without face id!", line)
             continue
 
         # If no external IP address was identified for this face
@@ -386,7 +388,7 @@ def process_content_history_logs(logs_dir, graph, parse_ping_logs = False):
         graph = annotate_cn_graph(logs_dir, graph, 
                 parse_ping_logs = parse_ping_logs)
     except:
-        print "Skipping: Error parsing ccnd logs", logs_dir
+        print("Skipping: Error parsing ccnd logs", logs_dir)
         raise
 
     source = ccn_consumers(graph)[0]
@@ -402,7 +404,7 @@ def process_content_history_logs(logs_dir, graph, parse_ping_logs = False):
         interest_count,
         content_count) = process_content_history(graph)
     except:
-        print "Skipping: Error processing ccn data", logs_dir
+        print("Skipping: Error processing ccn data", logs_dir)
         raise
 
     return (graph,
index 8da9311..bd14cee 100644 (file)
@@ -16,6 +16,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 import base64
 import fcntl
 import errno
@@ -153,7 +155,7 @@ def passfd_action(fd, args):
     to another process through a unix socket.
     """
     address = args.pop(0)
-    print address
+    print(address)
     sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
     sock.connect(address)
     passfd.sendfd(sock, fd, '0')
index 874f1a2..78b69c3 100644 (file)
@@ -16,6 +16,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 import base64
 import socket
 
@@ -54,7 +56,7 @@ if __name__ == '__main__':
         sock.send("%s\n" % encoded)
         reply = sock.recv(1024)
         reply = base64.b64decode(reply)
-        print reply
+        print(reply)
     except:
-        print "Did not properly shutdown device"
+        print("Did not properly shutdown device")
 
index 439649e..170bf9d 100644 (file)
@@ -18,6 +18,7 @@
 #         Claudio Freire <claudio-daniel.freire@inria.fr>
 #
 
+from __future__ import print_function
 
 import select
 import sys
@@ -261,9 +262,9 @@ def tun_fwd(tun, remote, with_pi, ether_mode, cipher_key, udp, TERMINATE, SUSPEN
 
     if stderr is not None:
         if crypto_mode:
-            print >>stderr, "Packets are transmitted in CIPHER"
+            print("Packets are transmitted in CIPHER", file=stderr)
         else:
-            print >>stderr, "Packets are transmitted in PLAINTEXT"
+            print("Packets are transmitted in PLAINTEXT", file=stderr)
     
     if hasattr(remote, 'fileno'):
         remote_fd = remote.fileno()
@@ -592,13 +593,13 @@ def udp_connect(TERMINATE, local_addr, local_port, peer_addr, peer_port):
             break
         except socket.error:
             # wait a while, retry
-            print >>sys.stderr, "%s: Could not bind. Retrying in a sec..." % (time.strftime('%c'),)
+            print("%s: Could not bind. Retrying in a sec..." % (time.strftime('%c'),), file=sys.stderr)
             time.sleep(min(30.0,retrydelay))
             retrydelay *= 1.1
     else:
         rsock.bind((local_addr, local_port))
-    print >>sys.stderr, "Listening UDP at: %s:%d" % (local_addr, local_port)
-    print >>sys.stderr, "Connecting UDP to: %s:%d" % (peer_addr, peer_port)
+    print("Listening UDP at: %s:%d" % (local_addr, local_port), file=sys.stderr)
+    print("Connecting UDP to: %s:%d" % (peer_addr, peer_port), file=sys.stderr)
     rsock.connect((peer_addr, peer_port))
     return rsock
 
@@ -654,17 +655,17 @@ def tcp_connect(TERMINATE, stop, rsock, peer_addr, peer_port):
             break
         except socket.error:
             # wait a while, retry
-            print >>sys.stderr, "%s: Could not connect. Retrying in a sec..." % (time.strftime('%c'),)
+            print("%s: Could not connect. Retrying in a sec..." % (time.strftime('%c'),), file=sys.stderr)
             time.sleep(min(30.0,retrydelay))
             retrydelay *= 1.1
     else:
         rsock.connect((peer_addr, peer_port))
         sock = rsock
     if sock:
-        print >>sys.stderr, "tcp_connect: TCP sock connected to remote %s:%s" % (peer_addr, peer_port)
+        print("tcp_connect: TCP sock connected to remote %s:%s" % (peer_addr, peer_port), file=sys.stderr)
         sock.settimeout(0) 
         
-        print >>sys.stderr, "tcp_connect: disabling NAGLE"
+        print("tcp_connect: disabling NAGLE", file=sys.stderr)
         sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
     return sock
 
@@ -683,13 +684,13 @@ def tcp_listen(TERMINATE, stop, lsock, local_addr, local_port):
             break
         except socket.error:
             # wait a while, retry
-            print >>sys.stderr, "%s: Could not bind. Retrying in a sec..." % (time.strftime('%c'),)
+            print("%s: Could not bind. Retrying in a sec..." % (time.strftime('%c'),), file=sys.stderr)
             time.sleep(min(30.0,retrydelay))
             retrydelay *= 1.1
     else:
         lsock.bind((local_addr, local_port))
 
-    print >>sys.stderr, "tcp_listen: TCP sock listening in local sock %s:%s" % (local_addr, local_port)
+    print("tcp_listen: TCP sock listening in local sock %s:%s" % (local_addr, local_port), file=sys.stderr)
     # Now we wait until the other side connects. 
     # The other side might not be ready yet, so we also wait in a loop for timeouts.
     timeout = 1
@@ -702,7 +703,7 @@ def tcp_listen(TERMINATE, stop, lsock, local_addr, local_port):
             break
         if lsock in rlist:
             sock,raddr = lsock.accept()
-            print >>sys.stderr, "tcp_listen: TCP connection accepted in local sock %s:%s" % (local_addr, local_port)
+            print("tcp_listen: TCP connection accepted in local sock %s:%s" % (local_addr, local_port), file=sys.stderr)
             break
         timeout += 5
     return sock
@@ -717,10 +718,10 @@ def tcp_handshake(rsock, listen, hand):
         rsock.send(hand)
         peer_hand = rsock.recv(4)
         if not peer_hand:
-            print >>sys.stderr, "tcp_handshake: connection reset by peer"
+            print("tcp_handshake: connection reset by peer", file=sys.stderr)
             return False
         else:
-            print >>sys.stderr, "tcp_handshake: hand %r, peer_hand %r" % (hand, peer_hand)
+            print("tcp_handshake: hand %r, peer_hand %r" % (hand, peer_hand), file=sys.stderr)
         if hand < peer_hand:
             if listen:
                 win = True
@@ -787,5 +788,3 @@ def tcp_establish(TERMINATE, local_addr, local_port, peer_addr, peer_port):
     if not sock:
         raise OSError, "Error: tcp_establish could not establish connection."
     return sock
-
-
index 3350d77..9097906 100644 (file)
@@ -29,6 +29,8 @@
 #  PYTHONPATH=$PYTHONPATH:~/repos/nepi/src python src/nepi/resources/ns3/resource_manager_generator.py
 #
 
+from __future__ import print_function
+
 # Force the load of ns3 libraries
 from nepi.resources.ns3.ns3wrapper import load_ns3_module
 
@@ -143,8 +145,8 @@ def create_ns3_rms():
                 replace("-","_").lower() + ".py"
 
         f = open(os.path.join(d, "classes", fname), "w")
-        print os.path.join(d, fname)
-        print template
+        print(os.path.join(d, fname))
+        print(template)
         f.write(template)
         f.close()
 
index eef5297..8384024 100644 (file)
@@ -17,6 +17,8 @@
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 #         Julien Tribino <julien.tribino@inria.fr>
 
+from __future__ import print_function
+
 import os
 
 from nepi.util.timefuncs import tnow
@@ -286,7 +288,7 @@ class OMFApplication(OMFResource):
             try:
                 f = open(trace_path ,'r')
             except IOError:
-                print "File with traces has not been found"
+                print("File with traces has not been found")
                 return False
             out = f.read()
             f.close()
index 30ca66b..1c19e3e 100644 (file)
@@ -16,6 +16,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 import base64
 import errno
 import passfd
@@ -76,7 +78,7 @@ def passfd_action(fd, args):
     to another process through a unix socket.
     """
     address = args.pop(0)
-    print address
+    print(address)
     sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
     sock.connect(address)
     passfd.sendfd(sock, fd, '0')
index 0003899..f766a37 100644 (file)
@@ -16,6 +16,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 import base64
 import socket
 import vsys
@@ -75,9 +77,9 @@ if __name__ == '__main__':
             sock.send("%s\n" % encoded)
             reply = sock.recv(1024)
             reply = base64.b64decode(reply)
-            print reply
+            print(reply)
         except:
-            print "Did not properly shutdown device"
+            print("Did not properly shutdown device")
     # If a slicename is provided, use it to remove a GRE device
     elif slicename:
         import pwd
index e00fbcb..81783cd 100644 (file)
@@ -16,6 +16,8 @@
 #
 # Author: Lucia Guevgeozian <lucia.guevgeozian_odizzio@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.attribute import Attribute, Flags, Types
 from nepi.execution.resource import ResourceManager, clsinit_copy, \
         ResourceState
@@ -529,10 +531,10 @@ class PlanetlabSfaNode(LinuxNode):
             # and perform ping to check that is really alive
             if not self._blacklisted(host_hrn):
                 if not self._reserved(host_hrn):
-                    print self.sfaapi._reserved ,self.guid
+                    print(self.sfaapi._reserved ,self.guid)
                     for hostname, hrn in nodes.iteritems():
                         if host_hrn == hrn:
-                            print 'hostname' ,hostname
+                            print('hostname' ,hostname)
                             ping_ok = self._do_ping(hostname)
                 
                     if not ping_ok:
index b0eb256..9630127 100644 (file)
@@ -16,6 +16,8 @@
 #
 # Author: Lucia Guevgeozian Odizzio <lucia.guevgeozian_odizzio@inria.fr>
 
+from __future__ import print_function
+
 import xmlrpclib
 import hashlib
 import threading
@@ -134,7 +136,7 @@ class MANIFOLDAPI(object):
             return True
         else:
             msg = "Failed while trying to add %s to slice" % resource_urn
-            print msg
+            print(msg)
             # check how to do warning
             return False
 
index cbbaff0..18b7a7d 100644 (file)
@@ -16,6 +16,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.util.netgraph import NetGraph, TopologyType 
 from nepi.util.timefuncs import stformat, tsformat
 
@@ -81,7 +83,7 @@ class ECXMLParser(object):
         try:
             xml = doc.toprettyxml(indent="    ", encoding="UTF-8")
         except:
-            print >>sys.stderr, "Oops: generating XML from %s" % (data,)
+            print("Oops: generating XML from %s" % (data,), file=sys.stderr)
             raise
         
         return xml
index 2a393fc..f6a8b54 100644 (file)
@@ -16,6 +16,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 import math
 import numpy
 from scipy import stats
@@ -24,7 +26,7 @@ def compute_mean(sample):
     # TODO: Discard outliers !!!!
 
     if not sample:
-        print " CANNOT COMPUTE STATS for ", sample
+        print(" CANNOT COMPUTE STATS for ", sample)
         return (0, 0, 0, 0)
 
     x = numpy.array(sample)
index bc38921..c6a08d3 100644 (file)
@@ -16,6 +16,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.resources.linux.node import LinuxNode
 
 import os
@@ -60,8 +62,8 @@ def skipIfNotAlive(func):
             node, ec = create_node(hostname, username, identity)
 
             if not node.is_alive():
-                print "*** WARNING: Skipping test %s: Node %s is not alive\n" % (
-                    name, node.get("hostname"))
+                print("*** WARNING: Skipping test %s: Node %s is not alive\n" % (
+                    name, node.get("hostname")))
                 return
 
         return func(*args, **kwargs)
@@ -80,8 +82,8 @@ def skipIfAnyNotAlive(func):
             node, ec = create_node(hostname, username)
 
             if not node.is_alive():
-                print "*** WARNING: Skipping test %s: Node %s is not alive\n" % (
-                    name, node.get("hostname"))
+                print("*** WARNING: Skipping test %s: Node %s is not alive\n" % (
+                    name, node.get("hostname")))
                 return
 
         return func(*args, **kwargs)
@@ -101,8 +103,8 @@ def skipIfAnyNotAliveWithIdentity(func):
             node, ec = create_node(hostname, username, identity)
 
             if not node.is_alive():
-                print "*** WARNING: Skipping test %s: Node %s is not alive\n" % (
-                    name, node.get("hostname"))
+                print("*** WARNING: Skipping test %s: Node %s is not alive\n" % (
+                    name, node.get("hostname")))
                 return
 
         return func(*args, **kwargs)
@@ -116,7 +118,7 @@ def skipInteractive(func):
         mode = os.environ.get("NEPI_INTERACTIVE_TEST", False)
         mode = mode and  mode.lower() in ['true', 'yes']
         if not mode:
-            print "*** WARNING: Skipping test %s: Interactive mode off \n" % name
+            print("*** WARNING: Skipping test %s: Interactive mode off \n" % name)
             return
 
         return func(*args, **kwargs)
@@ -129,7 +131,7 @@ def skipIfNotPLCredentials(func):
         pl_user = os.environ.get("PL_USER")
         pl_pass = os.environ.get("PL_PASS")
         if not (pl_user and pl_pass):
-            print "*** WARNING: Skipping test %s: Planetlab user, password and slicename not defined\n" % name
+            print("*** WARNING: Skipping test %s: Planetlab user, password and slicename not defined\n" % name)
             return
 
         return func(*args, **kwargs)
@@ -140,7 +142,7 @@ def skipIfNotPythonVersion(func):
     name = func.__name__
     def wrapped(*args, **kwargs):
         if sys.version_info < 2.7:
-            print "*** WARNING: Skipping test %s: total_seconds() method doesn't exist\n" % name
+            print("*** WARNING: Skipping test %s: total_seconds() method doesn't exist\n" % name)
             return
 
         return func(*args, **kwargs)
@@ -154,7 +156,7 @@ def skipIfNotSfaCredentials(func):
         sfa_pk = os.environ.get("SFA_PK")
         
         if not (sfa_user and os.path.exists(os.path.expanduser(sfa_pk))):
-            print "*** WARNING: Skipping test %s: SFA path to private key doesn't exist\n" % name
+            print("*** WARNING: Skipping test %s: SFA path to private key doesn't exist\n" % name)
             return
 
         return func(*args, **kwargs)
@@ -168,7 +170,7 @@ def skipIfNotSfi(func):
             from sfa.client.sfi import Sfi
             from sfa.util.xrn import hrn_to_urn
         except ImportError:
-            print "*** WARNING: Skipping test %s: sfi-client or sfi-common not installed\n" % name
+            print("*** WARNING: Skipping test %s: sfi-client or sfi-common not installed\n" % name)
             return
 
         return func(*args, **kwargs)
index 35a98cc..22acdbb 100755 (executable)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.resource import ResourceState, ResourceAction 
 from nepi.execution.ec import ExperimentController 
 from test_utils import skipIfAnyNotAlive
@@ -66,7 +68,7 @@ class LinuxCCNPeekTestCase(unittest.TestCase):
         ec.wait_finished(peek)
 
         stdout = ec.trace(peek, "stdout")
-        print stdout
+        print(stdout)
         expected = "DATA"
         self.assertTrue(stdout.find(expected) > -1)
 
index da576fd..13823c9 100755 (executable)
@@ -20,6 +20,8 @@
 # Test based on netns test/test_core.py file test_run_ping_routing test
 #
 
+from __future__ import print_function
+
 from nepi.resources.netns.netnsserver import run_server
 from nepi.resources.linux.netns.netnsclient import LinuxNetNSClient
 
@@ -157,7 +159,7 @@ class LinuxNetNSClientTest(unittest.TestCase):
         s1 = stdout1.read()
         s2 = stdout2.read()
 
-        print s1, s2
+        print(s1, s2)
 
         expected = "1 packets transmitted, 1 received, 0% packet loss"
         self.assertTrue(s1.find(expected) > -1)
index d6148d4..48186b8 100755 (executable)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 from nepi.execution.trace import TraceAttr
 
@@ -38,8 +40,8 @@ def add_node(ec, emu, addr, prefix):
     ec.set(ip, "prefix", prefix)
     ec.register_connection(ip, iface)
 
-    print ec.get(ip, "ip"), addr
-    print ec.get(ip, "prefix"), prefix
+    print(ec.get(ip, "ip"), addr)
+    print(ec.get(ip, "prefix"), prefix)
 
     return node, iface
 
index a3e0ba5..ac03fde 100755 (executable)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 from nepi.execution.resource import ResourceState, ResourceAction
 from nepi.execution.trace import TraceAttr
@@ -157,7 +159,7 @@ class LinuxNS3FdNetDeviceTest(unittest.TestCase):
         ec.wait_finished([app])
 
         stdout = ec.trace(app, "stdout")
-        print stdout
+        print(stdout)
         expected = "3 packets transmitted, 3 received, 0% packet loss"
         self.assertTrue(stdout.find(expected) > -1)
 
index 12f2ee2..6723629 100755 (executable)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 from nepi.execution.trace import TraceAttr
 
@@ -104,7 +106,7 @@ class LinuxNS3FdNetDeviceTest(unittest.TestCase):
 
         stdout = ec.trace(simu, "stdout") 
 
-        print stdout
+        print(stdout)
 
         expected = "20 packets transmitted, 20 received, 0% packet loss"
         self.assertTrue(stdout.find(expected) > -1)
index 1b3b7cb..5f7ce29 100755 (executable)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 from nepi.execution.trace import TraceAttr
 
@@ -744,7 +746,7 @@ class LinuxNS3SimulationTest(unittest.TestCase):
         
         stdout = ec.trace(simu, "stdout")
 
-        print stdout
+        print(stdout)
 
         expected = "20 packets transmitted, 20 received, 0% packet loss"
         self.assertTrue(stdout.find(expected) > -1)
index c10879c..2eea5b6 100755 (executable)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 from nepi.execution.trace import TraceAttr
 
@@ -183,7 +185,7 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase):
         ec.register_connection(ping, nsnode2)
 
         filepath = ec.save(dirpath)
-        print filepath
+        print(filepath)
         
         ec.deploy()
 
@@ -323,7 +325,7 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase):
         ec.register_connection(ping, nsnode1)
 
         filepath = ec.save(dirpath)
-        print filepath
+        print(filepath)
         
         ec.deploy()
 
index 8d025ce..2963f90 100755 (executable)
@@ -17,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 from test_utils import skipIfAnyNotAliveWithIdentity
@@ -72,7 +74,7 @@ class LinuxUdpTunnelTestCase(unittest.TestCase):
         ec.wait_finished(app)
 
         ping = ec.trace(app, "stdout")
-        print ping
+        print(ping)
         expected = """3 packets transmitted, 3 received, 0% packet loss"""
         self.assertTrue(ping.find(expected) > -1)
         
@@ -126,7 +128,7 @@ class LinuxUdpTunnelTestCase(unittest.TestCase):
 
         ping = ec.trace(app, "stdout")
 
-        print ping
+        print(ping)
         expected = """3 packets transmitted, 3 received, 0% packet loss"""
         self.assertTrue(ping.find(expected) > -1)
         
index 7b6c487..b9998cf 100755 (executable)
@@ -28,6 +28,7 @@
 #
 #  node n0 sends IGMP traffic to node n3
 
+from __future__ import print_function
 
 from nepi.resources.ns3.ns3wrapper import NS3Wrapper
 
@@ -180,10 +181,10 @@ class NS3WrapperTest(unittest.TestCase):
         wrapper.invoke(csma, "EnableAsciiAll", "/tmp/csma-ping-ascii")
  
         def SinkRx(packet, address):
-            print packet
+            print(packet)
 
         def PingRtt(context, rtt):
-            print context, rtt
+            print(context, rtt)
       
         # XXX: No biding for MakeCallback
         #Config::ConnectWithoutContext ("/NodeList/3/ApplicationList/0/$ns3::PacketSink/Rx", 
index c297aff..f515f1e 100755 (executable)
 #
 # Author: Julien Tribino <julien.tribino@inria.fr>
 
+from __future__ import print_function
 
-from nepi.execution.resource import ResourceFactory, clsinit_copy, ResourceManager, ResourceAction, ResourceState
+from nepi.execution.resource import (ResourceFactory, clsinit_copy,
+                                     ResourceManager, ResourceAction, ResourceState)
 from nepi.execution.ec import ExperimentController
 from nepi.execution.attribute import Attribute, Flags 
 
@@ -45,7 +47,7 @@ class OMFDummyApplication(OMFApplication):
     @classmethod
     def test_hook(cls, old_value, new_value):
         new_value *= 10
-        print "Change the value of test from "+ str(old_value) +" to : " + str(new_value)
+        print("Change the value of test from "+ str(old_value) +" to : " + str(new_value))
         return new_value
 
 
@@ -80,13 +82,13 @@ class OMFTestSet(unittest.TestCase):
         self.ec.deploy()
 
         time.sleep(3)
-        print "First try to change the STDIN"
+        print("First try to change the STDIN")
         self.ec.set(self.app1, 'test', 3)
 
         self.assertEquals(self.ec.get(self.app1, 'test'), 30)
 
         time.sleep(3)
-        print "Second try to change the STDIN"
+        print("Second try to change the STDIN")
         self.ec.set(self.app1, 'test', 101)
         self.assertEquals(self.ec.get(self.app1, 'test'), 1010)