From 039fbd9629d7570d4c175a5448d24badcd0f3aba Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Thu, 8 Oct 2015 16:26:42 +0200 Subject: [PATCH] use print() - import print_function - should be fine for both py2 and py3 --- examples/ccn_emu_live/dce.py | 6 +- examples/ccn_emu_live/planetlab.py | 5 +- .../ccn_emu_live/planetlab_4_nodes_linear.py | 730 +++++++++--------- examples/dce/custom_dlm_ping.py | 4 +- examples/dce/custom_local_csma_ping.py | 4 +- examples/dce/custom_local_p2p_ccn.py | 4 +- examples/dce/custom_local_p2p_ping.py | 4 +- examples/dce/custom_local_wifi_ping.py | 5 +- examples/dce/wrapped_local_p2p_ccncat.py | 5 +- examples/dce/wrapped_local_p2p_ccnpeek.py | 4 +- examples/dce/wrapped_local_p2p_ping.py | 4 +- examples/linux/ccn_simple_transfer.py | 4 +- examples/linux/ccn_transfer_using_linuxapp.py | 4 +- examples/linux/hello_world.py | 4 +- examples/linux/netcat_file_transfer.py | 4 +- examples/linux/ping.py | 3 +- examples/linux/vlc_streaming.py | 4 +- examples/netns/local_switch_ping.py | 4 +- examples/ns3/local_csma_p2p_star_ping.py | 4 +- examples/ns3/local_csma_ping.py | 4 +- examples/ns3/local_mobile_wifi_ping.py | 4 +- examples/ns3/local_p2p_ping.py | 4 +- examples/ns3/local_wifi_ping.py | 4 +- examples/ns3/multi_host/distributed.py | 166 ++-- examples/ns3/multi_host/hybrid.py | 200 ++--- examples/ns3/multi_host/parallel.py | 172 +++-- examples/ns3/remote_p2p_ping.py | 4 +- examples/omf/iminds_omf6_ping.py | 4 +- examples/omf/iminds_omf6_vlc.py | 4 +- examples/omf/nitos_omf6_ping.py | 4 +- examples/omf/nitos_omf6_vlc.py | 4 +- examples/omf/nitos_testbed_bootstrap.py | 250 +++--- examples/omf/testing/nepi_omf6_iminds_vlc.py | 10 +- examples/omf/testing/nitos_omf5_ping.py | 4 +- examples/openvswitch/ovs_ping.py | 6 +- examples/openvswitch/ovs_ping_2_switches.py | 5 +- examples/openvswitch/ovs_ping_3_switches.py | 10 +- examples/planetlab/ccn_simple_transfer.py | 4 +- examples/planetlab/ping.py | 3 +- examples/planetlab/ping_with_filters.py | 4 +- examples/planetlab/select_nodes.py | 5 +- examples/planetlab/update_fedora_repo.py | 6 +- src/nepi/__init__.py | 4 +- src/nepi/data/processing/ccn/parser.py | 8 +- .../linux/scripts/linux-tap-create.py | 4 +- .../linux/scripts/linux-tap-delete.py | 6 +- .../resources/linux/scripts/tunchannel.py | 29 +- .../ns3/resource_manager_generator.py | 6 +- src/nepi/resources/omf/application.py | 4 +- .../planetlab/scripts/pl-vif-create.py | 4 +- .../planetlab/scripts/pl-vif-down.py | 6 +- src/nepi/resources/planetlab/sfa_node.py | 6 +- src/nepi/util/manifoldapi.py | 4 +- src/nepi/util/parsers/xml_parser.py | 4 +- src/nepi/util/statfuncs.py | 4 +- test/lib/test_utils.py | 24 +- test/resources/linux/ccn/ccnpeek.py | 4 +- test/resources/linux/netns/netnsclient.py | 4 +- test/resources/linux/netns/netnsemulation.py | 6 +- .../ns3/cross_ns3_linux_tuntapfdlink_ping.py | 4 +- test/resources/linux/ns3/ns3fdnetdevice.py | 4 +- test/resources/linux/ns3/ns3simulation.py | 4 +- test/resources/linux/ns3/serialization.py | 6 +- test/resources/linux/udptunnel.py | 6 +- test/resources/ns3/ns3wrapper.py | 5 +- test/resources/omf/set_hook.py | 10 +- 66 files changed, 983 insertions(+), 870 deletions(-) diff --git a/examples/ccn_emu_live/dce.py b/examples/ccn_emu_live/dce.py index 7f490a4f..79507b5d 100644 --- a/examples/ccn_emu_live/dce.py +++ b/examples/ccn_emu_live/dce.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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") diff --git a/examples/ccn_emu_live/planetlab.py b/examples/ccn_emu_live/planetlab.py index 10b4deb1..b2548f37 100644 --- a/examples/ccn_emu_live/planetlab.py +++ b/examples/ccn_emu_live/planetlab.py @@ -17,6 +17,7 @@ # # Author: Alina Quereilhac +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") diff --git a/examples/ccn_emu_live/planetlab_4_nodes_linear.py b/examples/ccn_emu_live/planetlab_4_nodes_linear.py index e527fd99..b48f496e 100644 --- a/examples/ccn_emu_live/planetlab_4_nodes_linear.py +++ b/examples/ccn_emu_live/planetlab_4_nodes_linear.py @@ -1,364 +1,366 @@ -#!/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 . -# -# Author: Alina Quereilhac - -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 -u -p " - "-k -N ") - -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) - - +#!/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 . +# +# Author: Alina Quereilhac + +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 -u -p " + "-k -N ") + +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) + + diff --git a/examples/dce/custom_dlm_ping.py b/examples/dce/custom_dlm_ping.py index ab7ef338..69f69e15 100644 --- a/examples/dce/custom_dlm_ping.py +++ b/examples/dce/custom_dlm_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/dce/custom_local_csma_ping.py b/examples/dce/custom_local_csma_ping.py index 3ce19d14..54085ab8 100644 --- a/examples/dce/custom_local_csma_ping.py +++ b/examples/dce/custom_local_csma_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/dce/custom_local_p2p_ccn.py b/examples/dce/custom_local_p2p_ccn.py index 04a46fc2..243470f0 100644 --- a/examples/dce/custom_local_p2p_ccn.py +++ b/examples/dce/custom_local_p2p_ccn.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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() diff --git a/examples/dce/custom_local_p2p_ping.py b/examples/dce/custom_local_p2p_ping.py index 578698ca..f99ac7bc 100644 --- a/examples/dce/custom_local_p2p_ping.py +++ b/examples/dce/custom_local_p2p_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/dce/custom_local_wifi_ping.py b/examples/dce/custom_local_wifi_ping.py index 273eb89a..c751b5d9 100644 --- a/examples/dce/custom_local_wifi_ping.py +++ b/examples/dce/custom_local_wifi_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/dce/wrapped_local_p2p_ccncat.py b/examples/dce/wrapped_local_p2p_ccncat.py index 80c4d485..b85bdffc 100644 --- a/examples/dce/wrapped_local_p2p_ccncat.py +++ b/examples/dce/wrapped_local_p2p_ccncat.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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() - diff --git a/examples/dce/wrapped_local_p2p_ccnpeek.py b/examples/dce/wrapped_local_p2p_ccnpeek.py index a8119cd9..0ba078c2 100644 --- a/examples/dce/wrapped_local_p2p_ccnpeek.py +++ b/examples/dce/wrapped_local_p2p_ccnpeek.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/dce/wrapped_local_p2p_ping.py b/examples/dce/wrapped_local_p2p_ping.py index 3da1e145..cdcfd6b4 100644 --- a/examples/dce/wrapped_local_p2p_ping.py +++ b/examples/dce/wrapped_local_p2p_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/linux/ccn_simple_transfer.py b/examples/linux/ccn_simple_transfer.py index 4b5d6f40..39ea8f0a 100644 --- a/examples/linux/ccn_simple_transfer.py +++ b/examples/linux/ccn_simple_transfer.py @@ -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") diff --git a/examples/linux/ccn_transfer_using_linuxapp.py b/examples/linux/ccn_transfer_using_linuxapp.py index fb4f74d3..0395a409 100644 --- a/examples/linux/ccn_transfer_using_linuxapp.py +++ b/examples/linux/ccn_transfer_using_linuxapp.py @@ -40,6 +40,8 @@ # $ cd # python examples/linux/ccn_advanced_transfer.py -a -b -u -i +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") diff --git a/examples/linux/hello_world.py b/examples/linux/hello_world.py index 424536b3..2e026b5b 100644 --- a/examples/linux/hello_world.py +++ b/examples/linux/hello_world.py @@ -22,6 +22,8 @@ # $ cd # python examples/linux/hello_world.py -a -u -i +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() diff --git a/examples/linux/netcat_file_transfer.py b/examples/linux/netcat_file_transfer.py index 05603370..3734af31 100644 --- a/examples/linux/netcat_file_transfer.py +++ b/examples/linux/netcat_file_transfer.py @@ -24,6 +24,8 @@ # $ cd # python examples/linux/netcat_file_transfer.py -a -b -u -i +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...") diff --git a/examples/linux/ping.py b/examples/linux/ping.py index d127fc95..0200b549 100644 --- a/examples/linux/ping.py +++ b/examples/linux/ping.py @@ -22,6 +22,7 @@ # $ cd # python examples/linux/ping.py -a -u -i +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() diff --git a/examples/linux/vlc_streaming.py b/examples/linux/vlc_streaming.py index 3533e018..4b5d83d1 100644 --- a/examples/linux/vlc_streaming.py +++ b/examples/linux/vlc_streaming.py @@ -21,6 +21,8 @@ # $ cd # python examples/linux/vlc_streaming.py -a -b -u -i +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") diff --git a/examples/netns/local_switch_ping.py b/examples/netns/local_switch_ping.py index 0bb1732e..e69a7e83 100644 --- a/examples/netns/local_switch_ping.py +++ b/examples/netns/local_switch_ping.py @@ -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) diff --git a/examples/ns3/local_csma_p2p_star_ping.py b/examples/ns3/local_csma_p2p_star_ping.py index 5c2de479..5d7593f6 100644 --- a/examples/ns3/local_csma_p2p_star_ping.py +++ b/examples/ns3/local_csma_p2p_star_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/ns3/local_csma_ping.py b/examples/ns3/local_csma_ping.py index 1becb79e..97afd3fb 100644 --- a/examples/ns3/local_csma_ping.py +++ b/examples/ns3/local_csma_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/ns3/local_mobile_wifi_ping.py b/examples/ns3/local_mobile_wifi_ping.py index d8d6c2c1..f51986b4 100644 --- a/examples/ns3/local_mobile_wifi_ping.py +++ b/examples/ns3/local_mobile_wifi_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/ns3/local_p2p_ping.py b/examples/ns3/local_p2p_ping.py index 4bd8200b..1741cddd 100644 --- a/examples/ns3/local_p2p_ping.py +++ b/examples/ns3/local_p2p_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/ns3/local_wifi_ping.py b/examples/ns3/local_wifi_ping.py index 40b7570e..8c17d7fa 100644 --- a/examples/ns3/local_wifi_ping.py +++ b/examples/ns3/local_wifi_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/ns3/multi_host/distributed.py b/examples/ns3/multi_host/distributed.py index c1a5a8b0..c3aef65a 100644 --- a/examples/ns3/multi_host/distributed.py +++ b/examples/ns3/multi_host/distributed.py @@ -1,82 +1,84 @@ -#!/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 . -# -# Author: Damien Saucez -# Alina Quereilhac -# - -# -# 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 -# - -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() - +#!/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 . +# +# Author: Damien Saucez +# Alina Quereilhac +# + +# +# 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() + diff --git a/examples/ns3/multi_host/hybrid.py b/examples/ns3/multi_host/hybrid.py index 0b364789..630fec2d 100644 --- a/examples/ns3/multi_host/hybrid.py +++ b/examples/ns3/multi_host/hybrid.py @@ -1,99 +1,101 @@ -#!/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 . -# -# Author: Damien Saucez -# Alina Quereilhac -# - -# -# 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 -# - -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() - - +#!/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 . +# +# Author: Damien Saucez +# Alina Quereilhac +# + +# +# 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() + + diff --git a/examples/ns3/multi_host/parallel.py b/examples/ns3/multi_host/parallel.py index a0be0a9a..fa53457c 100644 --- a/examples/ns3/multi_host/parallel.py +++ b/examples/ns3/multi_host/parallel.py @@ -1,85 +1,87 @@ -#!/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 . -# -# Author: Damien Saucez -# Alina Quereilhac -# - -# -# 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 -# - -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() - - +#!/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 . +# +# Author: Damien Saucez +# Alina Quereilhac +# + +# +# 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() + + diff --git a/examples/ns3/remote_p2p_ping.py b/examples/ns3/remote_p2p_ping.py index a592e81e..57bda491 100644 --- a/examples/ns3/remote_p2p_ping.py +++ b/examples/ns3/remote_p2p_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/examples/omf/iminds_omf6_ping.py b/examples/omf/iminds_omf6_ping.py index 173b4fdc..d5e02c73 100644 --- a/examples/omf/iminds_omf6_ping.py +++ b/examples/omf/iminds_omf6_ping.py @@ -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() diff --git a/examples/omf/iminds_omf6_vlc.py b/examples/omf/iminds_omf6_vlc.py index 1c4d1ce6..b312abdb 100644 --- a/examples/omf/iminds_omf6_vlc.py +++ b/examples/omf/iminds_omf6_vlc.py @@ -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() diff --git a/examples/omf/nitos_omf6_ping.py b/examples/omf/nitos_omf6_ping.py index 40f8012f..6deaf18e 100644 --- a/examples/omf/nitos_omf6_ping.py +++ b/examples/omf/nitos_omf6_ping.py @@ -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() diff --git a/examples/omf/nitos_omf6_vlc.py b/examples/omf/nitos_omf6_vlc.py index 95b74c03..eb615fe3 100644 --- a/examples/omf/nitos_omf6_vlc.py +++ b/examples/omf/nitos_omf6_vlc.py @@ -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 diff --git a/examples/omf/nitos_testbed_bootstrap.py b/examples/omf/nitos_testbed_bootstrap.py index 014d3eb6..6d70818d 100644 --- a/examples/omf/nitos_testbed_bootstrap.py +++ b/examples/omf/nitos_testbed_bootstrap.py @@ -1,124 +1,126 @@ -#!/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 . -# -# Author: Alina Quereilhac -# Maksym Gabielkov -# - -## 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 -# python examples/linux/nitos_testbed_bootstrap.py -H -U -i -g -u -# - -from nepi.execution.ec import ExperimentController -from nepi.execution.resource import ResourceAction, ResourceState - -from optparse import OptionParser -import os - -usage = ("usage: %prog -H -U -i -g -u ") - -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() - +#!/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 . +# +# Author: Alina Quereilhac +# Maksym Gabielkov +# + +## 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 +# python examples/linux/nitos_testbed_bootstrap.py -H -U -i -g -u +# + +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 -U -i -g -u ") + +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() + diff --git a/examples/omf/testing/nepi_omf6_iminds_vlc.py b/examples/omf/testing/nepi_omf6_iminds_vlc.py index 714d5e9f..91e1e49b 100644 --- a/examples/omf/testing/nepi_omf6_iminds_vlc.py +++ b/examples/omf/testing/nepi_omf6_iminds_vlc.py @@ -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) diff --git a/examples/omf/testing/nitos_omf5_ping.py b/examples/omf/testing/nitos_omf5_ping.py index 7decb71f..44d0ae98 100644 --- a/examples/omf/testing/nitos_omf5_ping.py +++ b/examples/omf/testing/nitos_omf5_ping.py @@ -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() diff --git a/examples/openvswitch/ovs_ping.py b/examples/openvswitch/ovs_ping.py index becd61cf..7f508468 100644 --- a/examples/openvswitch/ovs_ping.py +++ b/examples/openvswitch/ovs_ping.py @@ -32,6 +32,8 @@ # $ PYTHONPATH=$PYTHONPATH:src/ python examples/openvswitch/ovs_ping.py -n "192.168.3.0/24" -s -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() - - diff --git a/examples/openvswitch/ovs_ping_2_switches.py b/examples/openvswitch/ovs_ping_2_switches.py index 84c28d0b..a28bef20 100644 --- a/examples/openvswitch/ovs_ping_2_switches.py +++ b/examples/openvswitch/ovs_ping_2_switches.py @@ -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 -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) diff --git a/examples/openvswitch/ovs_ping_3_switches.py b/examples/openvswitch/ovs_ping_3_switches.py index 335d877b..c97b3a77 100644 --- a/examples/openvswitch/ovs_ping_3_switches.py +++ b/examples/openvswitch/ovs_ping_3_switches.py @@ -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 -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() - - diff --git a/examples/planetlab/ccn_simple_transfer.py b/examples/planetlab/ccn_simple_transfer.py index 6ca7cff9..64c78883 100644 --- a/examples/planetlab/ccn_simple_transfer.py +++ b/examples/planetlab/ccn_simple_transfer.py @@ -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") diff --git a/examples/planetlab/ping.py b/examples/planetlab/ping.py index c4812783..f35ea702 100644 --- a/examples/planetlab/ping.py +++ b/examples/planetlab/ping.py @@ -24,6 +24,7 @@ # $ cd # python examples/planetlab/ping.py -s -u -p -k +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() diff --git a/examples/planetlab/ping_with_filters.py b/examples/planetlab/ping_with_filters.py index 8f9c3cf4..f21d282a 100644 --- a/examples/planetlab/ping_with_filters.py +++ b/examples/planetlab/ping_with_filters.py @@ -22,6 +22,8 @@ # $ cd # python examples/planetlab/ping_with_filters.py -s -u -p -k +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() diff --git a/examples/planetlab/select_nodes.py b/examples/planetlab/select_nodes.py index 82ad58b8..f856f52c 100644 --- a/examples/planetlab/select_nodes.py +++ b/examples/planetlab/select_nodes.py @@ -22,6 +22,7 @@ # $ cd # python examples/planetlab/select_nodes.py -s -u -p -k -c -o -n +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() diff --git a/examples/planetlab/update_fedora_repo.py b/examples/planetlab/update_fedora_repo.py index 67c82a3b..cd2a9cde 100644 --- a/examples/planetlab/update_fedora_repo.py +++ b/examples/planetlab/update_fedora_repo.py @@ -27,6 +27,8 @@ # $ cd # python examples/planetlab/update_fedora_repo.py -H -s -u -p -k +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() diff --git a/src/nepi/__init__.py b/src/nepi/__init__.py index bb2f1729..18764d03 100644 --- a/src/nepi/__init__.py +++ b/src/nepi/__init__.py @@ -16,6 +16,8 @@ # # Author: Alina Quereilhac +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 diff --git a/src/nepi/data/processing/ccn/parser.py b/src/nepi/data/processing/ccn/parser.py index fe0e45b9..7d35d9e3 100644 --- a/src/nepi/data/processing/ccn/parser.py +++ b/src/nepi/data/processing/ccn/parser.py @@ -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, diff --git a/src/nepi/resources/linux/scripts/linux-tap-create.py b/src/nepi/resources/linux/scripts/linux-tap-create.py index 8da93115..bd14cee9 100644 --- a/src/nepi/resources/linux/scripts/linux-tap-create.py +++ b/src/nepi/resources/linux/scripts/linux-tap-create.py @@ -16,6 +16,8 @@ # # Author: Alina Quereilhac +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') diff --git a/src/nepi/resources/linux/scripts/linux-tap-delete.py b/src/nepi/resources/linux/scripts/linux-tap-delete.py index 874f1a2f..78b69c3d 100644 --- a/src/nepi/resources/linux/scripts/linux-tap-delete.py +++ b/src/nepi/resources/linux/scripts/linux-tap-delete.py @@ -16,6 +16,8 @@ # # Author: Alina Quereilhac +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") diff --git a/src/nepi/resources/linux/scripts/tunchannel.py b/src/nepi/resources/linux/scripts/tunchannel.py index 439649e6..170bf9d4 100644 --- a/src/nepi/resources/linux/scripts/tunchannel.py +++ b/src/nepi/resources/linux/scripts/tunchannel.py @@ -18,6 +18,7 @@ # Claudio Freire # +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 - - diff --git a/src/nepi/resources/ns3/resource_manager_generator.py b/src/nepi/resources/ns3/resource_manager_generator.py index 3350d77b..90979065 100644 --- a/src/nepi/resources/ns3/resource_manager_generator.py +++ b/src/nepi/resources/ns3/resource_manager_generator.py @@ -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() diff --git a/src/nepi/resources/omf/application.py b/src/nepi/resources/omf/application.py index eef5297c..8384024d 100644 --- a/src/nepi/resources/omf/application.py +++ b/src/nepi/resources/omf/application.py @@ -17,6 +17,8 @@ # Author: Alina Quereilhac # Julien Tribino +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() diff --git a/src/nepi/resources/planetlab/scripts/pl-vif-create.py b/src/nepi/resources/planetlab/scripts/pl-vif-create.py index 30ca66b2..1c19e3ee 100644 --- a/src/nepi/resources/planetlab/scripts/pl-vif-create.py +++ b/src/nepi/resources/planetlab/scripts/pl-vif-create.py @@ -16,6 +16,8 @@ # # Author: Alina Quereilhac +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') diff --git a/src/nepi/resources/planetlab/scripts/pl-vif-down.py b/src/nepi/resources/planetlab/scripts/pl-vif-down.py index 00038994..f766a379 100644 --- a/src/nepi/resources/planetlab/scripts/pl-vif-down.py +++ b/src/nepi/resources/planetlab/scripts/pl-vif-down.py @@ -16,6 +16,8 @@ # # Author: Alina Quereilhac +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 diff --git a/src/nepi/resources/planetlab/sfa_node.py b/src/nepi/resources/planetlab/sfa_node.py index e00fbcb3..81783cdd 100644 --- a/src/nepi/resources/planetlab/sfa_node.py +++ b/src/nepi/resources/planetlab/sfa_node.py @@ -16,6 +16,8 @@ # # Author: Lucia Guevgeozian +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: diff --git a/src/nepi/util/manifoldapi.py b/src/nepi/util/manifoldapi.py index b0eb2569..96301273 100644 --- a/src/nepi/util/manifoldapi.py +++ b/src/nepi/util/manifoldapi.py @@ -16,6 +16,8 @@ # # Author: Lucia Guevgeozian Odizzio +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 diff --git a/src/nepi/util/parsers/xml_parser.py b/src/nepi/util/parsers/xml_parser.py index cbbaff03..18b7a7da 100644 --- a/src/nepi/util/parsers/xml_parser.py +++ b/src/nepi/util/parsers/xml_parser.py @@ -16,6 +16,8 @@ # # Author: Alina Quereilhac +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 diff --git a/src/nepi/util/statfuncs.py b/src/nepi/util/statfuncs.py index 2a393fc4..f6a8b547 100644 --- a/src/nepi/util/statfuncs.py +++ b/src/nepi/util/statfuncs.py @@ -16,6 +16,8 @@ # # Author: Alina Quereilhac +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) diff --git a/test/lib/test_utils.py b/test/lib/test_utils.py index bc389217..c6a08d39 100644 --- a/test/lib/test_utils.py +++ b/test/lib/test_utils.py @@ -16,6 +16,8 @@ # # Author: Alina Quereilhac +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) diff --git a/test/resources/linux/ccn/ccnpeek.py b/test/resources/linux/ccn/ccnpeek.py index 35a98cc1..22acdbb7 100755 --- a/test/resources/linux/ccn/ccnpeek.py +++ b/test/resources/linux/ccn/ccnpeek.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/test/resources/linux/netns/netnsclient.py b/test/resources/linux/netns/netnsclient.py index da576fd3..13823c9b 100755 --- a/test/resources/linux/netns/netnsclient.py +++ b/test/resources/linux/netns/netnsclient.py @@ -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) diff --git a/test/resources/linux/netns/netnsemulation.py b/test/resources/linux/netns/netnsemulation.py index d6148d4b..48186b88 100755 --- a/test/resources/linux/netns/netnsemulation.py +++ b/test/resources/linux/netns/netnsemulation.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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 diff --git a/test/resources/linux/ns3/cross_ns3_linux_tuntapfdlink_ping.py b/test/resources/linux/ns3/cross_ns3_linux_tuntapfdlink_ping.py index a3e0ba5f..ac03fdee 100755 --- a/test/resources/linux/ns3/cross_ns3_linux_tuntapfdlink_ping.py +++ b/test/resources/linux/ns3/cross_ns3_linux_tuntapfdlink_ping.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/test/resources/linux/ns3/ns3fdnetdevice.py b/test/resources/linux/ns3/ns3fdnetdevice.py index 12f2ee26..67236295 100755 --- a/test/resources/linux/ns3/ns3fdnetdevice.py +++ b/test/resources/linux/ns3/ns3fdnetdevice.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/test/resources/linux/ns3/ns3simulation.py b/test/resources/linux/ns3/ns3simulation.py index 1b3b7cb2..5f7ce29b 100755 --- a/test/resources/linux/ns3/ns3simulation.py +++ b/test/resources/linux/ns3/ns3simulation.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/test/resources/linux/ns3/serialization.py b/test/resources/linux/ns3/serialization.py index c10879c5..2eea5b6a 100755 --- a/test/resources/linux/ns3/serialization.py +++ b/test/resources/linux/ns3/serialization.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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() diff --git a/test/resources/linux/udptunnel.py b/test/resources/linux/udptunnel.py index 8d025cea..2963f904 100755 --- a/test/resources/linux/udptunnel.py +++ b/test/resources/linux/udptunnel.py @@ -17,6 +17,8 @@ # # Author: Alina Quereilhac +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) diff --git a/test/resources/ns3/ns3wrapper.py b/test/resources/ns3/ns3wrapper.py index 7b6c487c..b9998cf8 100755 --- a/test/resources/ns3/ns3wrapper.py +++ b/test/resources/ns3/ns3wrapper.py @@ -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", diff --git a/test/resources/omf/set_hook.py b/test/resources/omf/set_hook.py index c297aff2..f515f1e7 100755 --- a/test/resources/omf/set_hook.py +++ b/test/resources/omf/set_hook.py @@ -17,8 +17,10 @@ # # Author: Julien Tribino +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) -- 2.43.0