#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.runner import ExperimentRunner
from nepi.util.netgraph import NetGraph, TopologyType
f = open("/tmp/metric", "a+")
f.write("%.2f\n" % metric)
f.close()
- print " METRIC", metric
+ print(" METRIC", metric)
return metric
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")
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
from nepi.execution.ec import ExperimentController
from nepi.execution.runner import ExperimentRunner
f = open("/tmp/metric", "a+")
f.write("%.2f\n" % metric)
f.close()
- print " METRIC", metric
+ print(" METRIC", metric)
return metric
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")
-#!/usr/bin/env python\r
-#\r
-# NEPI, a framework to manage network experiments\r
-# Copyright (C) 2013 INRIA\r
-#\r
-# This program is free software: you can redistribute it and/or modify\r
-# it under the terms of the GNU General Public License version 2 as\r
-# published by the Free Software Foundation;\r
-#\r
-# This program is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-# GNU General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU General Public License\r
-# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
-#\r
-# Author: Alina Quereilhac <alina.quereilhac@inria.fr>\r
-\r
-from nepi.execution.ec import ExperimentController \r
-from nepi.execution.runner import ExperimentRunner\r
-from nepi.util.netgraph import TopologyType\r
-import nepi.data.processing.ccn.parser as ccn_parser\r
-\r
-import networkx\r
-import socket\r
-import os\r
-import numpy\r
-from scipy import stats\r
-from matplotlib import pyplot\r
-import math\r
-import random\r
-\r
-from optparse import OptionParser\r
-\r
-usage = ("usage: %prog -s <pl-slice> -u <pl-user> -p <pl-password> "\r
- "-k <pl-ssh-key> -N <nodes>")\r
-\r
-parser = OptionParser(usage = usage)\r
-parser.add_option("-s", "--pl-slice", dest="pl_slice",\r
- help="PlanetLab slicename", type="str")\r
-parser.add_option("-u", "--pl-user", dest="pl_user",\r
- help="PlanetLab web username", type="str")\r
-parser.add_option("-p", "--pl-password", dest="pl_password",\r
- help="PlanetLab web password", type="str")\r
-parser.add_option("-k", "--pl-ssh-key", dest="pl_ssh_key",\r
- help="Path to private SSH key associated with the PL account",\r
- type="str")\r
-parser.add_option("-N", "--nodes", dest="nodes",\r
- help="Comma separated list of Planetlab nodes",\r
- type="str")\r
-\r
-(options, args) = parser.parse_args()\r
-\r
-pl_slice = options.pl_slice\r
-pl_ssh_key = options.pl_ssh_key\r
-pl_user = options.pl_user\r
-pl_password = options.pl_password\r
-NODES = options.nodes.strip().split(",")\r
-\r
-def avg_interest_rtt(ec, run):\r
- logs_dir = ec.run_dir\r
- \r
- # Parse downloaded CCND logs\r
- (graph,\r
- content_names,\r
- interest_expiry_count,\r
- interest_dupnonce_count,\r
- interest_count,\r
- content_count) = ccn_parser.process_content_history_logs(\r
- logs_dir, ec.netgraph.topology)\r
-\r
- # statistics on RTT\r
- rtts = [content_names[content_name]["rtt"] \\r
- for content_name in content_names.keys()]\r
-\r
- # sample mean and standard deviation\r
- sample = numpy.array(rtts)\r
- n, min_max, mean, var, skew, kurt = stats.describe(sample)\r
- std = math.sqrt(var)\r
- ci = stats.t.interval(0.95, n-1, loc = mean, \r
- scale = std/math.sqrt(n))\r
-\r
- global metrics\r
- metrics.append((mean, ci[0], ci[1]))\r
- \r
- return mean\r
-\r
-def normal_law(ec, run, sample):\r
- print "SAMPLE", sample\r
-\r
- x = numpy.array(sample)\r
- n = len(sample)\r
- std = x.std()\r
- se = std / math.sqrt(n)\r
- m = x.mean()\r
- se95 = se * 2\r
- \r
- return m * 0.05 >= se95\r
-\r
-def post_process(ec, runs):\r
- global metrics\r
- \r
- # plot convergence graph\r
- y = numpy.array([float(m[0]) for m in metrics])\r
- low = numpy.array([float(m[1]) for m in metrics])\r
- high = numpy.array([float(m[2]) for m in metrics])\r
- error = [y - low, high - y]\r
- x = range(1,runs + 1)\r
-\r
- # plot average RTT and confidence interval for each iteration\r
- pyplot.errorbar(x, y, yerr = error, fmt='o')\r
- pyplot.plot(x, y, 'r-')\r
- pyplot.xlim([0.5, runs + 0.5])\r
- pyplot.xticks(numpy.arange(1, len(y)+1, 1))\r
- pyplot.xlabel('Iteration')\r
- pyplot.ylabel('Average RTT')\r
- pyplot.grid()\r
- pyplot.savefig("plot.png")\r
- pyplot.show()\r
-\r
-content_name = "ccnx:/test/bunny.ts"\r
-\r
-repofile = os.path.join(\r
- os.path.dirname(os.path.realpath(__file__)), \r
- "repoFile1.0.8.2")\r
-\r
-def get_simulator(ec):\r
- simulator = ec.filter_resources("linux::ns3::Simulation")\r
-\r
- if not simulator:\r
- node = ec.register_resource("linux::Node")\r
- ec.set(node, "hostname", "localhost")\r
-\r
- simu = ec.register_resource("linux::ns3::Simulation")\r
- ec.register_connection(simu, node)\r
- return simu\r
-\r
- return simulator[0]\r
-\r
-def add_collector(ec, trace_name, subdir, newname = None):\r
- collector = ec.register_resource("Collector")\r
- ec.set(collector, "traceName", trace_name)\r
- ec.set(collector, "subDir", subdir)\r
- if newname:\r
- ec.set(collector, "rename", newname)\r
-\r
- return collector\r
-\r
-def add_dce_host(ec, nid):\r
- simu = get_simulator(ec)\r
- \r
- host = ec.register_resource("ns3::Node")\r
- ec.set(host, "enableStack", True)\r
- ec.register_connection(host, simu)\r
-\r
- # Annotate the graph\r
- ec.netgraph.annotate_node(nid, "host", host)\r
- \r
-def add_dce_ccnd(ec, nid):\r
- # Retrieve annotation from netgraph\r
- host = ec.netgraph.node_annotation(nid, "host")\r
- \r
- # Add dce ccnd to the dce node\r
- ccnd = ec.register_resource("linux::ns3::dce::CCND")\r
- ec.set (ccnd, "stackSize", 1<<20)\r
- ec.set (ccnd, "debug", 7)\r
- ec.set (ccnd, "capacity", 50000)\r
- ec.set (ccnd, "StartTime", "1s")\r
- ec.set (ccnd, "StopTime", STOP_TIME)\r
- ec.register_connection(ccnd, host)\r
-\r
- # Collector to retrieve ccnd log\r
- collector = add_collector(ec, "stderr", str(nid), "log")\r
- ec.register_connection(collector, ccnd)\r
-\r
- # Annotate the graph\r
- ec.netgraph.annotate_node(nid, "ccnd", ccnd)\r
-\r
-def add_dce_ccnr(ec, nid):\r
- # Retrieve annotation from netgraph\r
- host = ec.netgraph.node_annotation(nid, "host")\r
- \r
- # Add a CCN content repository to the dce node\r
- ccnr = ec.register_resource("linux::ns3::dce::CCNR")\r
- ec.set (ccnr, "repoFile1", repofile) \r
- ec.set (ccnr, "stackSize", 1<<20)\r
- ec.set (ccnr, "StartTime", "2s")\r
- ec.set (ccnr, "StopTime", STOP_TIME)\r
- ec.register_connection(ccnr, host)\r
-\r
-def add_dce_ccncat(ec, nid):\r
- # Retrieve annotation from netgraph\r
- host = ec.netgraph.node_annotation(nid, "host")\r
- \r
- # Add a ccncat application to the dce host\r
- ccncat = ec.register_resource("linux::ns3::dce::CCNCat")\r
- ec.set (ccncat, "contentName", content_name)\r
- ec.set (ccncat, "stackSize", 1<<20)\r
- ec.set (ccncat, "StartTime", "8s")\r
- ec.set (ccncat, "StopTime", STOP_TIME)\r
- ec.register_connection(ccncat, host)\r
-\r
-def add_dce_fib_entry(ec, nid1, nid2):\r
- # Retrieve annotations from netgraph\r
- host1 = ec.netgraph.node_annotation(nid1, "host")\r
- net = ec.netgraph.edge_net_annotation(nid1, nid2)\r
- ip2 = net[nid2]\r
-\r
- # Add FIB entry between peer hosts\r
- ccndc = ec.register_resource("linux::ns3::dce::FIBEntry")\r
- ec.set (ccndc, "protocol", "udp") \r
- ec.set (ccndc, "uri", "ccnx:/") \r
- ec.set (ccndc, "host", ip2)\r
- ec.set (ccndc, "stackSize", 1<<20)\r
- ec.set (ccndc, "StartTime", "2s")\r
- ec.set (ccndc, "StopTime", STOP_TIME)\r
- ec.register_connection(ccndc, host1)\r
-\r
-def add_dce_net_iface(ec, nid1, nid2):\r
- # Retrieve annotations from netgraph\r
- host = ec.netgraph.node_annotation(nid1, "host")\r
- net = ec.netgraph.edge_net_annotation(nid1, nid2)\r
- ip1 = net[nid1]\r
- prefix = net["prefix"]\r
-\r
- dev = ec.register_resource("ns3::PointToPointNetDevice")\r
- ec.set(dev,"DataRate", "5Mbps")\r
- ec.set(dev, "ip", ip1)\r
- ec.set(dev, "prefix", prefix)\r
- ec.register_connection(host, dev)\r
-\r
- queue = ec.register_resource("ns3::DropTailQueue")\r
- ec.register_connection(dev, queue)\r
-\r
- return dev\r
-\r
-def add_pl_host(ec, nid):\r
- hostname = NODES[nid]\r
-\r
- # Add a planetlab host to the experiment description\r
- host = ec.register_resource("planetlab::Node")\r
- ec.set(host, "hostname", hostname)\r
- ec.set(host, "username", pl_slice)\r
- ec.set(host, "identity", pl_ssh_key)\r
- ec.set(host, "cleanExperiment", True)\r
- ec.set(host, "cleanProcesses", True)\r
-\r
- # Annotate the graph\r
- ec.netgraph.annotate_node(nid, "hostname", hostname)\r
- ec.netgraph.annotate_node(nid, "host", host)\r
- \r
- # Annotate the graph node with an ip address\r
- ip = socket.gethostbyname(hostname)\r
- ec.netgraph.annotate_node_ip(nid, ip)\r
-\r
-def add_pl_ccnd(ec, nid):\r
- # Retrieve annotation from netgraph\r
- host = ec.netgraph.node_annotation(nid, "host")\r
- \r
- # Add a CCN daemon to the planetlab node\r
- ccnd = ec.register_resource("linux::CCND")\r
- ec.set(ccnd, "debug", 7)\r
- ec.register_connection(ccnd, host)\r
- \r
- # Collector to retrieve ccnd log\r
- collector = add_collector(ec, "stderr", str(nid), "log")\r
- ec.register_connection(collector, ccnd)\r
-\r
- # Annotate the graph\r
- ec.netgraph.annotate_node(nid, "ccnd", ccnd)\r
-\r
-def add_pl_ccnr(ec, nid):\r
- # Retrieve annotation from netgraph\r
- ccnd = ec.netgraph.node_annotation(nid, "ccnd")\r
- \r
- # Add a CCN content repository to the planetlab node\r
- ccnr = ec.register_resource("linux::CCNR")\r
-\r
- ec.set(ccnr, "repoFile1", repofile)\r
- ec.register_connection(ccnr, ccnd)\r
-\r
-def add_pl_ccncat(ec, nid):\r
- # Retrieve annotation from netgraph\r
- ccnd = ec.netgraph.node_annotation(nid, "ccnd")\r
- \r
- # Add a CCN cat application to the planetlab node\r
- ccncat = ec.register_resource("linux::CCNCat")\r
- ec.set(ccncat, "contentName", content_name)\r
- ec.register_connection(ccncat, ccnd)\r
-\r
-def add_pl_fib_entry(ec, nid1, nid2):\r
- # Retrieve annotations from netgraph\r
- ccnd1 = ec.netgraph.node_annotation(nid1, "ccnd")\r
- hostname2 = ec.netgraph.node_annotation(nid2, "hostname")\r
- \r
- # Add a FIB entry between one planetlab node and its peer\r
- entry = ec.register_resource("linux::FIBEntry")\r
- ec.set(entry, "host", hostname2)\r
- ec.register_connection(entry, ccnd1)\r
-\r
- # Collector to retrieve peering ping output (to measure neighbors delay)\r
- ec.enable_trace(entry, "ping")\r
- collector = add_collector(ec, "ping", str(nid1))\r
- ec.register_connection(collector, entry)\r
-\r
- return entry\r
-\r
-def add_node(ec, nid):\r
- ### Add CCN nodes (ec.netgraph holds the topology graph)\r
- add_dce_host(ec, nid)\r
- add_dce_ccnd(ec, nid)\r
- \r
- if nid == ec.netgraph.targets()[0]:\r
- add_dce_ccnr(ec, nid)\r
-\r
- if nid == ec.netgraph.sources()[0]:\r
- add_dce_ccncat(ec, nid)\r
-\r
-def add_edge(ec, nid1, nid2):\r
- #### Add connections between CCN nodes\r
- add_pl_fib_entry(ec, nid1, nid2)\r
- add_pl_fib_entry(ec, nid2, nid1)\r
-\r
-def add_node(ec, nid):\r
- ### Add CCN nodes (ec.netgraph holds the topology graph)\r
- add_pl_host(ec, nid)\r
- add_pl_ccnd(ec, nid)\r
- \r
- if nid == ec.netgraph.targets()[0]:\r
- add_pl_ccnr(ec, nid)\r
-\r
- if nid == ec.netgraph.sources()[0]:\r
- add_pl_ccncat(ec, nid)\r
-\r
-def wait_guids(ec):\r
- return ec.filter_resources("linux::CCNCat")\r
-\r
-if __name__ == '__main__':\r
-\r
- metrics = []\r
-\r
- # topology translation to NEPI model\r
- ec = ExperimentController("pl_4n_linear",\r
- topo_type = TopologyType.LINEAR, \r
- node_count = 4,\r
- assign_st = True,\r
- assign_ips = True,\r
- add_node_callback = add_node,\r
- add_edge_callback = add_edge)\r
-\r
- #### Run experiment until metric convergence\r
- rnr = ExperimentRunner()\r
- runs = rnr.run(ec,\r
- min_runs = 10,\r
- max_runs = 100, \r
- compute_metric_callback = avg_interest_rtt,\r
- evaluate_convergence_callback = normal_law,\r
- wait_guids = wait_guids(ec))\r
- \r
- ### post processing\r
- post_process(ec, runs)\r
-\r
-\r
+#!/usr/bin/env python
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation;
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+
+from __future__ import print_function
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.runner import ExperimentRunner
+from nepi.util.netgraph import TopologyType
+import nepi.data.processing.ccn.parser as ccn_parser
+
+import networkx
+import socket
+import os
+import numpy
+from scipy import stats
+from matplotlib import pyplot
+import math
+import random
+
+from optparse import OptionParser
+
+usage = ("usage: %prog -s <pl-slice> -u <pl-user> -p <pl-password> "
+ "-k <pl-ssh-key> -N <nodes>")
+
+parser = OptionParser(usage = usage)
+parser.add_option("-s", "--pl-slice", dest="pl_slice",
+ help="PlanetLab slicename", type="str")
+parser.add_option("-u", "--pl-user", dest="pl_user",
+ help="PlanetLab web username", type="str")
+parser.add_option("-p", "--pl-password", dest="pl_password",
+ help="PlanetLab web password", type="str")
+parser.add_option("-k", "--pl-ssh-key", dest="pl_ssh_key",
+ help="Path to private SSH key associated with the PL account",
+ type="str")
+parser.add_option("-N", "--nodes", dest="nodes",
+ help="Comma separated list of Planetlab nodes",
+ type="str")
+
+(options, args) = parser.parse_args()
+
+pl_slice = options.pl_slice
+pl_ssh_key = options.pl_ssh_key
+pl_user = options.pl_user
+pl_password = options.pl_password
+NODES = options.nodes.strip().split(",")
+
+def avg_interest_rtt(ec, run):
+ logs_dir = ec.run_dir
+
+ # Parse downloaded CCND logs
+ (graph,
+ content_names,
+ interest_expiry_count,
+ interest_dupnonce_count,
+ interest_count,
+ content_count) = ccn_parser.process_content_history_logs(
+ logs_dir, ec.netgraph.topology)
+
+ # statistics on RTT
+ rtts = [content_names[content_name]["rtt"] \
+ for content_name in content_names.keys()]
+
+ # sample mean and standard deviation
+ sample = numpy.array(rtts)
+ n, min_max, mean, var, skew, kurt = stats.describe(sample)
+ std = math.sqrt(var)
+ ci = stats.t.interval(0.95, n-1, loc = mean,
+ scale = std/math.sqrt(n))
+
+ global metrics
+ metrics.append((mean, ci[0], ci[1]))
+
+ return mean
+
+def normal_law(ec, run, sample):
+ print("SAMPLE", sample)
+
+ x = numpy.array(sample)
+ n = len(sample)
+ std = x.std()
+ se = std / math.sqrt(n)
+ m = x.mean()
+ se95 = se * 2
+
+ return m * 0.05 >= se95
+
+def post_process(ec, runs):
+ global metrics
+
+ # plot convergence graph
+ y = numpy.array([float(m[0]) for m in metrics])
+ low = numpy.array([float(m[1]) for m in metrics])
+ high = numpy.array([float(m[2]) for m in metrics])
+ error = [y - low, high - y]
+ x = range(1,runs + 1)
+
+ # plot average RTT and confidence interval for each iteration
+ pyplot.errorbar(x, y, yerr = error, fmt='o')
+ pyplot.plot(x, y, 'r-')
+ pyplot.xlim([0.5, runs + 0.5])
+ pyplot.xticks(numpy.arange(1, len(y)+1, 1))
+ pyplot.xlabel('Iteration')
+ pyplot.ylabel('Average RTT')
+ pyplot.grid()
+ pyplot.savefig("plot.png")
+ pyplot.show()
+
+content_name = "ccnx:/test/bunny.ts"
+
+repofile = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "repoFile1.0.8.2")
+
+def get_simulator(ec):
+ simulator = ec.filter_resources("linux::ns3::Simulation")
+
+ if not simulator:
+ node = ec.register_resource("linux::Node")
+ ec.set(node, "hostname", "localhost")
+
+ simu = ec.register_resource("linux::ns3::Simulation")
+ ec.register_connection(simu, node)
+ return simu
+
+ return simulator[0]
+
+def add_collector(ec, trace_name, subdir, newname = None):
+ collector = ec.register_resource("Collector")
+ ec.set(collector, "traceName", trace_name)
+ ec.set(collector, "subDir", subdir)
+ if newname:
+ ec.set(collector, "rename", newname)
+
+ return collector
+
+def add_dce_host(ec, nid):
+ simu = get_simulator(ec)
+
+ host = ec.register_resource("ns3::Node")
+ ec.set(host, "enableStack", True)
+ ec.register_connection(host, simu)
+
+ # Annotate the graph
+ ec.netgraph.annotate_node(nid, "host", host)
+
+def add_dce_ccnd(ec, nid):
+ # Retrieve annotation from netgraph
+ host = ec.netgraph.node_annotation(nid, "host")
+
+ # Add dce ccnd to the dce node
+ ccnd = ec.register_resource("linux::ns3::dce::CCND")
+ ec.set (ccnd, "stackSize", 1<<20)
+ ec.set (ccnd, "debug", 7)
+ ec.set (ccnd, "capacity", 50000)
+ ec.set (ccnd, "StartTime", "1s")
+ ec.set (ccnd, "StopTime", STOP_TIME)
+ ec.register_connection(ccnd, host)
+
+ # Collector to retrieve ccnd log
+ collector = add_collector(ec, "stderr", str(nid), "log")
+ ec.register_connection(collector, ccnd)
+
+ # Annotate the graph
+ ec.netgraph.annotate_node(nid, "ccnd", ccnd)
+
+def add_dce_ccnr(ec, nid):
+ # Retrieve annotation from netgraph
+ host = ec.netgraph.node_annotation(nid, "host")
+
+ # Add a CCN content repository to the dce node
+ ccnr = ec.register_resource("linux::ns3::dce::CCNR")
+ ec.set (ccnr, "repoFile1", repofile)
+ ec.set (ccnr, "stackSize", 1<<20)
+ ec.set (ccnr, "StartTime", "2s")
+ ec.set (ccnr, "StopTime", STOP_TIME)
+ ec.register_connection(ccnr, host)
+
+def add_dce_ccncat(ec, nid):
+ # Retrieve annotation from netgraph
+ host = ec.netgraph.node_annotation(nid, "host")
+
+ # Add a ccncat application to the dce host
+ ccncat = ec.register_resource("linux::ns3::dce::CCNCat")
+ ec.set (ccncat, "contentName", content_name)
+ ec.set (ccncat, "stackSize", 1<<20)
+ ec.set (ccncat, "StartTime", "8s")
+ ec.set (ccncat, "StopTime", STOP_TIME)
+ ec.register_connection(ccncat, host)
+
+def add_dce_fib_entry(ec, nid1, nid2):
+ # Retrieve annotations from netgraph
+ host1 = ec.netgraph.node_annotation(nid1, "host")
+ net = ec.netgraph.edge_net_annotation(nid1, nid2)
+ ip2 = net[nid2]
+
+ # Add FIB entry between peer hosts
+ ccndc = ec.register_resource("linux::ns3::dce::FIBEntry")
+ ec.set (ccndc, "protocol", "udp")
+ ec.set (ccndc, "uri", "ccnx:/")
+ ec.set (ccndc, "host", ip2)
+ ec.set (ccndc, "stackSize", 1<<20)
+ ec.set (ccndc, "StartTime", "2s")
+ ec.set (ccndc, "StopTime", STOP_TIME)
+ ec.register_connection(ccndc, host1)
+
+def add_dce_net_iface(ec, nid1, nid2):
+ # Retrieve annotations from netgraph
+ host = ec.netgraph.node_annotation(nid1, "host")
+ net = ec.netgraph.edge_net_annotation(nid1, nid2)
+ ip1 = net[nid1]
+ prefix = net["prefix"]
+
+ dev = ec.register_resource("ns3::PointToPointNetDevice")
+ ec.set(dev,"DataRate", "5Mbps")
+ ec.set(dev, "ip", ip1)
+ ec.set(dev, "prefix", prefix)
+ ec.register_connection(host, dev)
+
+ queue = ec.register_resource("ns3::DropTailQueue")
+ ec.register_connection(dev, queue)
+
+ return dev
+
+def add_pl_host(ec, nid):
+ hostname = NODES[nid]
+
+ # Add a planetlab host to the experiment description
+ host = ec.register_resource("planetlab::Node")
+ ec.set(host, "hostname", hostname)
+ ec.set(host, "username", pl_slice)
+ ec.set(host, "identity", pl_ssh_key)
+ ec.set(host, "cleanExperiment", True)
+ ec.set(host, "cleanProcesses", True)
+
+ # Annotate the graph
+ ec.netgraph.annotate_node(nid, "hostname", hostname)
+ ec.netgraph.annotate_node(nid, "host", host)
+
+ # Annotate the graph node with an ip address
+ ip = socket.gethostbyname(hostname)
+ ec.netgraph.annotate_node_ip(nid, ip)
+
+def add_pl_ccnd(ec, nid):
+ # Retrieve annotation from netgraph
+ host = ec.netgraph.node_annotation(nid, "host")
+
+ # Add a CCN daemon to the planetlab node
+ ccnd = ec.register_resource("linux::CCND")
+ ec.set(ccnd, "debug", 7)
+ ec.register_connection(ccnd, host)
+
+ # Collector to retrieve ccnd log
+ collector = add_collector(ec, "stderr", str(nid), "log")
+ ec.register_connection(collector, ccnd)
+
+ # Annotate the graph
+ ec.netgraph.annotate_node(nid, "ccnd", ccnd)
+
+def add_pl_ccnr(ec, nid):
+ # Retrieve annotation from netgraph
+ ccnd = ec.netgraph.node_annotation(nid, "ccnd")
+
+ # Add a CCN content repository to the planetlab node
+ ccnr = ec.register_resource("linux::CCNR")
+
+ ec.set(ccnr, "repoFile1", repofile)
+ ec.register_connection(ccnr, ccnd)
+
+def add_pl_ccncat(ec, nid):
+ # Retrieve annotation from netgraph
+ ccnd = ec.netgraph.node_annotation(nid, "ccnd")
+
+ # Add a CCN cat application to the planetlab node
+ ccncat = ec.register_resource("linux::CCNCat")
+ ec.set(ccncat, "contentName", content_name)
+ ec.register_connection(ccncat, ccnd)
+
+def add_pl_fib_entry(ec, nid1, nid2):
+ # Retrieve annotations from netgraph
+ ccnd1 = ec.netgraph.node_annotation(nid1, "ccnd")
+ hostname2 = ec.netgraph.node_annotation(nid2, "hostname")
+
+ # Add a FIB entry between one planetlab node and its peer
+ entry = ec.register_resource("linux::FIBEntry")
+ ec.set(entry, "host", hostname2)
+ ec.register_connection(entry, ccnd1)
+
+ # Collector to retrieve peering ping output (to measure neighbors delay)
+ ec.enable_trace(entry, "ping")
+ collector = add_collector(ec, "ping", str(nid1))
+ ec.register_connection(collector, entry)
+
+ return entry
+
+def add_node(ec, nid):
+ ### Add CCN nodes (ec.netgraph holds the topology graph)
+ add_dce_host(ec, nid)
+ add_dce_ccnd(ec, nid)
+
+ if nid == ec.netgraph.targets()[0]:
+ add_dce_ccnr(ec, nid)
+
+ if nid == ec.netgraph.sources()[0]:
+ add_dce_ccncat(ec, nid)
+
+def add_edge(ec, nid1, nid2):
+ #### Add connections between CCN nodes
+ add_pl_fib_entry(ec, nid1, nid2)
+ add_pl_fib_entry(ec, nid2, nid1)
+
+def add_node(ec, nid):
+ ### Add CCN nodes (ec.netgraph holds the topology graph)
+ add_pl_host(ec, nid)
+ add_pl_ccnd(ec, nid)
+
+ if nid == ec.netgraph.targets()[0]:
+ add_pl_ccnr(ec, nid)
+
+ if nid == ec.netgraph.sources()[0]:
+ add_pl_ccncat(ec, nid)
+
+def wait_guids(ec):
+ return ec.filter_resources("linux::CCNCat")
+
+if __name__ == '__main__':
+
+ metrics = []
+
+ # topology translation to NEPI model
+ ec = ExperimentController("pl_4n_linear",
+ topo_type = TopologyType.LINEAR,
+ node_count = 4,
+ assign_st = True,
+ assign_ips = True,
+ add_node_callback = add_node,
+ add_edge_callback = add_edge)
+
+ #### Run experiment until metric convergence
+ rnr = ExperimentRunner()
+ runs = rnr.run(ec,
+ min_runs = 10,
+ max_runs = 100,
+ compute_metric_callback = avg_interest_rtt,
+ evaluate_convergence_callback = normal_law,
+ wait_guids = wait_guids(ec))
+
+ ### post processing
+ post_process(ec, runs)
+
+
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
def add_ns3_node(ec, simu):
ec.shutdown()
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
def add_ns3_node(ec, simu):
ec.shutdown()
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
import os
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()
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
def add_ns3_node(ec, simu):
ec.shutdown()
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
def add_ns3_node(ec, simu):
ec.shutdown()
-print "PING OUTPUT", stdout
-
+print("PING OUTPUT", stdout)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
import os
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()
-
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
def add_ns3_node(ec, simu):
ec.shutdown()
-print "PEEK received", stdout
+print("PEEK received", stdout)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
def add_ns3_node(ec, simu):
ec.shutdown()
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
# 0 ------- network -------- 1
#
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from optparse import OptionParser
ec.shutdown()
-print "Transfered FILE stored localy at video.ts"
+print("Transfered FILE stored localy at video.ts")
# $ cd <path-to-nepi>
# python examples/linux/ccn_advanced_transfer.py -a <hostname1> -b <hostname2> -u <username> -i <ssh-key>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.resource import ResourceAction, ResourceState
# Shutdown the experiment controller
ec.shutdown()
-print "Transfered FILE stored localy at video.ts"
+print("Transfered FILE stored localy at video.ts")
# $ cd <path-to-nepi>
# python examples/linux/hello_world.py -a <hostname> -u <username> -i <ssh-key>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from optparse import OptionParser, SUPPRESS_HELP
ec.wait_finished(app)
-print ec.trace(app, "stdout")
+print(ec.trace(app, "stdout"))
ec.shutdown()
# $ cd <path-to-nepi>
# python examples/linux/netcat_file_transfer.py -a <hostname1> -b <hostname2> -u <username> -i <ssh-key>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.resource import ResourceAction, ResourceState
ec.shutdown()
-print "Total bytes transfered saved to bw.txt..."
+print("Total bytes transfered saved to bw.txt...")
# $ cd <path-to-nepi>
# python examples/linux/ping.py -a <hostname> -u <username> -i <ssh-key>
+from __future__ import print_function
from nepi.execution.ec import ExperimentController
ec.wait_finished(app)
-print ec.trace(app, "stdout")
+print(ec.trace(app, "stdout"))
ec.shutdown()
# $ cd <path-to-nepi>
# python examples/linux/vlc_streaming.py -a <hostname1> -b <hostname2> -u <username> -i <ssh-key>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.resource import ResourceState, ResourceAction
ec.shutdown()
-print "Streamed VIDEO stored localy at video.ts"
+print("Streamed VIDEO stored localy at video.ts")
# 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")
ec.shutdown()
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
"""
network topology:
ec.shutdown()
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
ec = ExperimentController(exp_id = "ns3-local-csma-ping")
ec.shutdown()
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
"""
network topology:
ec.shutdown()
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
ec = ExperimentController(exp_id = "ns3-local-p2p-ping")
ec.shutdown()
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
ec = ExperimentController(exp_id = "ns3-local-wifi-ping")
ec.shutdown()
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
-#!/usr/bin/env python\r
-#\r
-# NEPI, a framework to manage network experiments\r
-# Copyright (C) 2015 INRIA\r
-#\r
-# This program is free software: you can redistribute it and/or modify\r
-# it under the terms of the GNU General Public License version 2 as\r
-# published by the Free Software Foundation;\r
-#\r
-# This program is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-# GNU General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU General Public License\r
-# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
-#\r
-# Author: Damien Saucez <damien.saucez@inria.fr>\r
-# Alina Quereilhac <alina.quereilhac@inria.fr>\r
-#\r
-\r
-#\r
-# Note: To run this experiment you need to have a PlanetLab account.\r
-#\r
-# This experiment consists of a simulated wireless sensor network (ns-3)\r
-# with one fixed access point (AP), running an agent application, and several\r
-# mobile stations that run a transmitter application to send messages to\r
-# the AP.\r
-#\r
-# The experiment uses 2 networks like the one described above, running in 2\r
-# independent ns-3 instances in remote hosts, and transparently connected\r
-# through a UDP tunnel.\r
-\r
-#\r
-# command line:\r
-#\r
-# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/ditributed.py\r
-#\r
-\r
-import os\r
-\r
-from nepi.execution.ec import ExperimentController\r
-from nepi.execution.resource import ResourceState, ResourceManager\r
-\r
-from topology import *\r
-\r
-# tunning\r
-os.environ["NEPI_NTHREADS"] = "1"\r
-ResourceManager._reschedule_delay = "0s"\r
-\r
-# list of hosts for running the experiment on\r
-hostname1 = "onelab4.warsaw.rd.tp.pl"\r
-hostname2 = "planet2.servers.ua.pt"\r
-\r
-(username, pl_user, pl_password, ssh_key, node_count) = get_options()\r
-\r
-ec = ExperimentController(exp_id="distributed")\r
-\r
-host1, simu1 = add_host_simu(ec, hostname1, username, pl_user, pl_password, \r
- ssh_key)\r
-\r
-ap1, agent1 = build_ns3_topology(ec, simu1, node_count, network="10.1.0.0", \r
- prefixlen="24", agent_ip="10.1.0.1")\r
-\r
-host2, simu2 = add_host_simu(ec, hostname2, username, pl_user, pl_password, ssh_key)\r
-ap2, agent2 = build_ns3_topology(ec, simu2, node_count, network="10.2.0.0", prefixlen="24", agent_ip="10.1.0.1")\r
-\r
-fddev1 = add_fdnet_device(ec, ap1, "10.0.0.1", "30")\r
-fddev2 = add_fdnet_device(ec, ap2, "10.0.0.2", "30")\r
-\r
-connect_with_udp_tunnel(ec, fddev1, fddev2)\r
-\r
-ec.deploy()\r
-\r
-ec.wait_finished([simu1, simu2])\r
-\r
-stdout = ec.trace(agent1, "stdout")\r
-print " Agent says:"\r
-print stdout\r
-\r
-ec.shutdown()\r
-\r
+#!/usr/bin/env python
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2015 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation;
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Damien Saucez <damien.saucez@inria.fr>
+# Alina Quereilhac <alina.quereilhac@inria.fr>
+#
+
+#
+# Note: To run this experiment you need to have a PlanetLab account.
+#
+# This experiment consists of a simulated wireless sensor network (ns-3)
+# with one fixed access point (AP), running an agent application, and several
+# mobile stations that run a transmitter application to send messages to
+# the AP.
+#
+# The experiment uses 2 networks like the one described above, running in 2
+# independent ns-3 instances in remote hosts, and transparently connected
+# through a UDP tunnel.
+
+#
+# command line:
+#
+# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/ditributed.py
+#
+
+from __future__ import print_function
+
+import os
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.resource import ResourceState, ResourceManager
+
+from topology import *
+
+# tunning
+os.environ["NEPI_NTHREADS"] = "1"
+ResourceManager._reschedule_delay = "0s"
+
+# list of hosts for running the experiment on
+hostname1 = "onelab4.warsaw.rd.tp.pl"
+hostname2 = "planet2.servers.ua.pt"
+
+(username, pl_user, pl_password, ssh_key, node_count) = get_options()
+
+ec = ExperimentController(exp_id="distributed")
+
+host1, simu1 = add_host_simu(ec, hostname1, username, pl_user, pl_password,
+ ssh_key)
+
+ap1, agent1 = build_ns3_topology(ec, simu1, node_count, network="10.1.0.0",
+ prefixlen="24", agent_ip="10.1.0.1")
+
+host2, simu2 = add_host_simu(ec, hostname2, username, pl_user, pl_password, ssh_key)
+ap2, agent2 = build_ns3_topology(ec, simu2, node_count, network="10.2.0.0", prefixlen="24", agent_ip="10.1.0.1")
+
+fddev1 = add_fdnet_device(ec, ap1, "10.0.0.1", "30")
+fddev2 = add_fdnet_device(ec, ap2, "10.0.0.2", "30")
+
+connect_with_udp_tunnel(ec, fddev1, fddev2)
+
+ec.deploy()
+
+ec.wait_finished([simu1, simu2])
+
+stdout = ec.trace(agent1, "stdout")
+print(" Agent says:")
+print(stdout)
+
+ec.shutdown()
+
-#!/usr/bin/env python\r
-#\r
-# NEPI, a framework to manage network experiments\r
-# Copyright (C) 2015 INRIA\r
-#\r
-# This program is free software: you can redistribute it and/or modify\r
-# it under the terms of the GNU General Public License version 2 as\r
-# published by the Free Software Foundation;\r
-#\r
-# This program is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-# GNU General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU General Public License\r
-# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
-#\r
-# Author: Damien Saucez <damien.saucez@inria.fr>\r
-# Alina Quereilhac <alina.quereilhac@inria.fr>\r
-#\r
-\r
-#\r
-# Note that to run this experiment you need to have a PlanetLab account.\r
-#\r
-# This experiment consists of a simulated wireless sensor network (ns-3)\r
-# with one fixed access point (AP), running an agent application, and several\r
-# mobile stations that run a transmitter application to send messages to\r
-# the AP.\r
-#\r
-# One of the transmitter applications runs outside the simulation, on\r
-# the host, and sends messages to the AP through the FdNetDevice/TAP\r
-# link.\r
-#\r
-\r
-#\r
-# command line:\r
-#\r
-# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/hybrid.py\r
-#\r
-\r
-import os\r
-\r
-from nepi.execution.ec import ExperimentController\r
-from nepi.execution.resource import ResourceState, ResourceManager\r
-\r
-from topology import *\r
-\r
-# tunning\r
-os.environ["NEPI_NTHREADS"] = "1"\r
-ResourceManager._reschedule_delay = "0s"\r
-\r
-# list of hosts for running the experiment on\r
-hostname1 = "onelab4.warsaw.rd.tp.pl"\r
-hostname2 = "planet2.servers.ua.pt"\r
-\r
-(username, pl_user, pl_password, ssh_key, node_count) = get_options()\r
-\r
-ec = ExperimentController(exp_id="hybrid")\r
-\r
-host, simu = add_host_simu(ec, hostname1, username, pl_user, pl_password, \r
- ssh_key)\r
-\r
-ap, agent = build_ns3_topology(ec, simu, node_count, network="192.168.3.0", \r
- prefixlen="25", agent_ip="192.168.3.1")\r
-\r
-fddev = add_fdnet_device(ec, ap, "192.168.3.129", "25")\r
-\r
-tap = ec.register_resource("planetlab::Tap")\r
-ec.set(tap, "ip", "192.168.3.130")\r
-ec.set(tap, "prefix", "25")\r
-ec.set(tap, "pointopoint", "192.168.3.129")\r
-ec.register_connection(host, tap) \r
-\r
-connect_with_virtual_link(ec, tap, fddev)\r
-\r
-add_ns3_route(ec, ap, network="192.168.3.128", prefixlen="25", nexthop="192.168.3.1")\r
-add_planetlab_route(ec, tap, network="192.168.3.0", prefixlen="25", nexthop="192.168.3.129")\r
-\r
-transmitter = ec.register_resource("linux::Application")\r
-ec.set(transmitter, "sources", "code/transmitter.c")\r
-ec.set(transmitter, "build", "gcc ${SRC}/transmitter.c -o ${BIN}/transmitter")\r
-ec.set(transmitter, "command", "${BIN}/transmitter 192.168.3.1")\r
-ec.register_connection(transmitter, host)\r
-\r
-ec.deploy()\r
-\r
-ec.wait_finished([simu, transmitter])\r
-\r
-stdout = ec.trace(agent, "stdout")\r
-print " Agent says: "\r
-print stdout\r
-\r
-stdout = ec.trace(transmitter, "stdout")\r
-print " Live transmitter output: "\r
-print stdout\r
-\r
-ec.shutdown()\r
-\r
-\r
+#!/usr/bin/env python
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2015 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation;
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Damien Saucez <damien.saucez@inria.fr>
+# Alina Quereilhac <alina.quereilhac@inria.fr>
+#
+
+#
+# Note that to run this experiment you need to have a PlanetLab account.
+#
+# This experiment consists of a simulated wireless sensor network (ns-3)
+# with one fixed access point (AP), running an agent application, and several
+# mobile stations that run a transmitter application to send messages to
+# the AP.
+#
+# One of the transmitter applications runs outside the simulation, on
+# the host, and sends messages to the AP through the FdNetDevice/TAP
+# link.
+#
+
+#
+# command line:
+#
+# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/hybrid.py
+#
+
+from __future__ import print_function
+
+import os
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.resource import ResourceState, ResourceManager
+
+from topology import *
+
+# tunning
+os.environ["NEPI_NTHREADS"] = "1"
+ResourceManager._reschedule_delay = "0s"
+
+# list of hosts for running the experiment on
+hostname1 = "onelab4.warsaw.rd.tp.pl"
+hostname2 = "planet2.servers.ua.pt"
+
+(username, pl_user, pl_password, ssh_key, node_count) = get_options()
+
+ec = ExperimentController(exp_id="hybrid")
+
+host, simu = add_host_simu(ec, hostname1, username, pl_user, pl_password,
+ ssh_key)
+
+ap, agent = build_ns3_topology(ec, simu, node_count, network="192.168.3.0",
+ prefixlen="25", agent_ip="192.168.3.1")
+
+fddev = add_fdnet_device(ec, ap, "192.168.3.129", "25")
+
+tap = ec.register_resource("planetlab::Tap")
+ec.set(tap, "ip", "192.168.3.130")
+ec.set(tap, "prefix", "25")
+ec.set(tap, "pointopoint", "192.168.3.129")
+ec.register_connection(host, tap)
+
+connect_with_virtual_link(ec, tap, fddev)
+
+add_ns3_route(ec, ap, network="192.168.3.128", prefixlen="25", nexthop="192.168.3.1")
+add_planetlab_route(ec, tap, network="192.168.3.0", prefixlen="25", nexthop="192.168.3.129")
+
+transmitter = ec.register_resource("linux::Application")
+ec.set(transmitter, "sources", "code/transmitter.c")
+ec.set(transmitter, "build", "gcc ${SRC}/transmitter.c -o ${BIN}/transmitter")
+ec.set(transmitter, "command", "${BIN}/transmitter 192.168.3.1")
+ec.register_connection(transmitter, host)
+
+ec.deploy()
+
+ec.wait_finished([simu, transmitter])
+
+stdout = ec.trace(agent, "stdout")
+print(" Agent says: ")
+print(stdout)
+
+stdout = ec.trace(transmitter, "stdout")
+print(" Live transmitter output: ")
+print(stdout)
+
+ec.shutdown()
+
+
-#!/usr/bin/env python\r
-#\r
-# NEPI, a framework to manage network experiments\r
-# Copyright (C) 2015 INRIA\r
-#\r
-# This program is free software: you can redistribute it and/or modify\r
-# it under the terms of the GNU General Public License version 2 as\r
-# published by the Free Software Foundation;\r
-#\r
-# This program is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-# GNU General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU General Public License\r
-# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
-#\r
-# Author: Damien Saucez <damien.saucez@inria.fr>\r
-# Alina Quereilhac <alina.quereilhac@inria.fr>\r
-#\r
-\r
-#\r
-# Note: To run this experiment you need to have a PlanetLab account.\r
-#\r
-# This experiment consists of a simulated wireless sensor network (ns-3)\r
-# with one fixed access point (AP), running an agent application, and several\r
-# mobile stations that run a transmitter application to send messages to\r
-# the AP.\r
-#\r
-# The same experiment described above is run in parallel with different\r
-# number of mobile stations in 2 PlanetLab hosts.\r
-#\r
-\r
-#\r
-# command line:\r
-#\r
-# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/parallel.py\r
-#\r
-\r
-import os\r
-\r
-from topology import *\r
-\r
-from nepi.execution.ec import ExperimentController\r
-from nepi.execution.resource import ResourceState, ResourceManager\r
-\r
-# tunning\r
-os.environ["NEPI_NTHREADS"] = "1"\r
-ResourceManager._reschedule_delay = "0s"\r
-\r
-# list of hosts for running the experiment on\r
-hostname1 = "onelab4.warsaw.rd.tp.pl"\r
-hostname2 = "planet2.servers.ua.pt"\r
-\r
-(username, pl_user, pl_password, ssh_key, node_count) = get_options()\r
-\r
-ec = ExperimentController(exp_id="parallel")\r
-counts = [node_count, 10]\r
-hosts = [hostname1, hostname2]\r
-\r
-simulations = []\r
-agents = []\r
-\r
-for hostname in hosts:\r
- host, simu = add_host_simu(ec, hostname, username, pl_user, pl_password, \r
- ssh_key)\r
- simulations.append(simu)\r
-\r
- node_count = counts.pop()\r
- ap, agent = build_ns3_topology(ec, simu, node_count, network="10.1.0.0", \r
- prefixlen="24", agent_ip="10.1.0.1")\r
- agents.append(agent)\r
-\r
-ec.deploy()\r
-\r
-ec.wait_finished(simulations)\r
-\r
-for agent in agents:\r
- stdout = ec.trace(agent, "stdout")\r
- print " Agent says:"\r
- print stdout\r
-\r
-ec.shutdown()\r
-\r
-\r
+#!/usr/bin/env python
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2015 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation;
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Damien Saucez <damien.saucez@inria.fr>
+# Alina Quereilhac <alina.quereilhac@inria.fr>
+#
+
+#
+# Note: To run this experiment you need to have a PlanetLab account.
+#
+# This experiment consists of a simulated wireless sensor network (ns-3)
+# with one fixed access point (AP), running an agent application, and several
+# mobile stations that run a transmitter application to send messages to
+# the AP.
+#
+# The same experiment described above is run in parallel with different
+# number of mobile stations in 2 PlanetLab hosts.
+#
+
+#
+# command line:
+#
+# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/parallel.py
+#
+
+from __future__ import print_function
+
+import os
+
+from topology import *
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.resource import ResourceState, ResourceManager
+
+# tunning
+os.environ["NEPI_NTHREADS"] = "1"
+ResourceManager._reschedule_delay = "0s"
+
+# list of hosts for running the experiment on
+hostname1 = "onelab4.warsaw.rd.tp.pl"
+hostname2 = "planet2.servers.ua.pt"
+
+(username, pl_user, pl_password, ssh_key, node_count) = get_options()
+
+ec = ExperimentController(exp_id="parallel")
+counts = [node_count, 10]
+hosts = [hostname1, hostname2]
+
+simulations = []
+agents = []
+
+for hostname in hosts:
+ host, simu = add_host_simu(ec, hostname, username, pl_user, pl_password,
+ ssh_key)
+ simulations.append(simu)
+
+ node_count = counts.pop()
+ ap, agent = build_ns3_topology(ec, simu, node_count, network="10.1.0.0",
+ prefixlen="24", agent_ip="10.1.0.1")
+ agents.append(agent)
+
+ec.deploy()
+
+ec.wait_finished(simulations)
+
+for agent in agents:
+ stdout = ec.trace(agent, "stdout")
+ print(" Agent says:")
+ print(stdout)
+
+ec.shutdown()
+
+
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from optparse import OptionParser
ec.shutdown()
-print "PING OUTPUT", stdout
+print("PING OUTPUT", stdout)
# - t3 (t2 + 2s) : Kill the application
#
+from __future__ import print_function
+
from nepi.execution.resource import ResourceAction, ResourceState
from nepi.execution.ec import ExperimentController
# 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()
# - t3 (t2 + 2s) : Kill the application
#
+from __future__ import print_function
+
from nepi.execution.resource import ResourceAction, ResourceState
from nepi.execution.ec import ExperimentController
# 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()
# - t3 (t2 + 2s) : Kill the application
#
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.resource import ResourceAction, ResourceState
# 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()
# - t3 (t2 + 2s) : Kill the application
#
+from __future__ import print_function
+
from nepi.execution.resource import ResourceAction, ResourceState
from nepi.execution.ec import ExperimentController
# 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
-#!/usr/bin/env python\r
-#\r
-# NEPI, a framework to manage network experiments\r
-# Copyright (C) 2013 INRIA\r
-#\r
-# This program is free software: you can redistribute it and/or modify\r
-# it under the terms of the GNU General Public License version 2 as\r
-# published by the Free Software Foundation;\r
-#\r
-# This program is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-# GNU General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU General Public License\r
-# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
-#\r
-# Author: Alina Quereilhac <alina.quereilhac@inria.fr>\r
-# Maksym Gabielkov <maksym.gabielkovc@inria.fr>\r
-#\r
-\r
-## This is a maintenance script used to bootstrap the nodes from\r
-## Nitos testbed (NITLab) before running a OMF experiment using\r
-## Nitos nodes. This fixes the problem of Resource Controller \r
-## misbehaving by restarting it and it also loads the ath5k driver.\r
-\r
-# Example of how to run this experiment (replace with your information):\r
-#\r
-# $ cd <path-to-nepi>\r
-# python examples/linux/nitos_testbed_bootstrap.py -H <omf.nitos.node0XX,omf.nitos.node0ZZ,..> -U <node-username> -i <ssh-key> -g <nitos-gateway> -u <nitos-slice>\r
-#\r
-\r
-from nepi.execution.ec import ExperimentController\r
-from nepi.execution.resource import ResourceAction, ResourceState\r
-\r
-from optparse import OptionParser\r
-import os\r
-\r
-usage = ("usage: %prog -H <list-of-nitos-hosts> -U <node-username> -i <ssh-key> -g <nitos-gateway> -u <slicename>")\r
-\r
-parser = OptionParser(usage = usage)\r
-parser.add_option("-H", "--hosts", dest="hosts", \r
- help="Space separated list of hosts", type="str")\r
-parser.add_option("-U", "--username", dest="username", \r
- help="Username for the nitos hosts (usually root)", \r
- type="str", default="root" )\r
-parser.add_option("-g", "--gateway", dest="gateway", \r
- help="Nitos gateway hostname", \r
- type="str", default="nitlab.inf.uth.gr")\r
-parser.add_option("-u", "--gateway-user", dest="gateway_username", \r
- help="Nitos gateway username (slicename)", \r
- type="str", default="nitlab.inf.uth.gr")\r
-parser.add_option("-i", "--ssh-key", dest="ssh_key", \r
- help="Path to private SSH key to be used for connection", \r
- type="str")\r
-(options, args) = parser.parse_args()\r
-\r
-hosts = options.hosts\r
-username = options.username\r
-gateway = options.gateway\r
-gateway_username = options.gateway_username\r
-identity = options.ssh_key\r
-\r
-apps = []\r
-\r
-ec = ExperimentController(exp_id="nitos_bootstrap")\r
-\r
-gw_node = ec.register_resource("linux::Node")\r
-ec.set(gw_node, "username", gateway_username)\r
-ec.set(gw_node, "hostname", gateway)\r
-ec.set(gw_node, "identity", identity)\r
-ec.set(gw_node, "cleanExperiment", True)\r
-\r
-load_cmd = "omf load -i nepi_OMF6_VLC_baseline_grid.ndz -t %s" % hosts \r
-load_app = ec.register_resource("linux::Application")\r
-ec.set(load_app, "command", load_cmd)\r
-ec.register_connection(load_app, gw_node)\r
-\r
-reboot_cmd = "omf tell -a on -t %s" % hosts \r
-reboot_app = ec.register_resource("linux::Application")\r
-ec.set(reboot_app, "command", reboot_cmd)\r
-ec.register_connection(reboot_app, gw_node)\r
-\r
-ec.register_condition(reboot_app, ResourceAction.START, load_app, \r
- ResourceState.STOPPED, time="60s") \r
-\r
-hosts = hosts.split(",")\r
-\r
-for hostname in hosts:\r
- host = hostname.split(".")[-1]\r
- node = ec.register_resource("linux::Node")\r
- ec.set(node, "username", username)\r
- ec.set(node, "hostname", host)\r
- ec.set(node, "identity", identity)\r
- ec.set(node, "gateway", gateway)\r
- ec.set(node, "gatewayUser", gateway_username)\r
- ec.set(node, "cleanExperiment", True)\r
- ec.register_condition(node, ResourceAction.DEPLOY, reboot_app, \r
- ResourceState.STOPPED, time="300s") \r
- \r
- modprobe_app = ec.register_resource("linux::Application")\r
- ec.set(modprobe_app, "command", "modprobe ath5k && ip a | grep wlan0")\r
- ec.register_connection(modprobe_app, node)\r
- apps.append(modprobe_app)\r
-\r
- rc_app = ec.register_resource("linux::Application")\r
- ec.set(rc_app, "command", "service omf_rc stop; service omf_rc start")\r
- ec.register_connection(rc_app, node)\r
- apps.append(rc_app)\r
-\r
-print "This might take time..."\r
-\r
-ec.deploy(wait_all_ready=False)\r
-\r
-ec.wait_finished(apps)\r
-\r
-print ec.trace(load_app, "stdout")\r
-print ec.trace(reboot_app, "stdout")\r
-\r
-for app in apps:\r
- print ec.trace(app, "stdout")\r
-\r
-ec.shutdown()\r
-\r
+#!/usr/bin/env python
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation;
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+# Maksym Gabielkov <maksym.gabielkovc@inria.fr>
+#
+
+## This is a maintenance script used to bootstrap the nodes from
+## Nitos testbed (NITLab) before running a OMF experiment using
+## Nitos nodes. This fixes the problem of Resource Controller
+## misbehaving by restarting it and it also loads the ath5k driver.
+
+# Example of how to run this experiment (replace with your information):
+#
+# $ cd <path-to-nepi>
+# python examples/linux/nitos_testbed_bootstrap.py -H <omf.nitos.node0XX,omf.nitos.node0ZZ,..> -U <node-username> -i <ssh-key> -g <nitos-gateway> -u <nitos-slice>
+#
+
+from __future__ import print_function
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.resource import ResourceAction, ResourceState
+
+from optparse import OptionParser
+import os
+
+usage = ("usage: %prog -H <list-of-nitos-hosts> -U <node-username> -i <ssh-key> -g <nitos-gateway> -u <slicename>")
+
+parser = OptionParser(usage = usage)
+parser.add_option("-H", "--hosts", dest="hosts",
+ help="Space separated list of hosts", type="str")
+parser.add_option("-U", "--username", dest="username",
+ help="Username for the nitos hosts (usually root)",
+ type="str", default="root" )
+parser.add_option("-g", "--gateway", dest="gateway",
+ help="Nitos gateway hostname",
+ type="str", default="nitlab.inf.uth.gr")
+parser.add_option("-u", "--gateway-user", dest="gateway_username",
+ help="Nitos gateway username (slicename)",
+ type="str", default="nitlab.inf.uth.gr")
+parser.add_option("-i", "--ssh-key", dest="ssh_key",
+ help="Path to private SSH key to be used for connection",
+ type="str")
+(options, args) = parser.parse_args()
+
+hosts = options.hosts
+username = options.username
+gateway = options.gateway
+gateway_username = options.gateway_username
+identity = options.ssh_key
+
+apps = []
+
+ec = ExperimentController(exp_id="nitos_bootstrap")
+
+gw_node = ec.register_resource("linux::Node")
+ec.set(gw_node, "username", gateway_username)
+ec.set(gw_node, "hostname", gateway)
+ec.set(gw_node, "identity", identity)
+ec.set(gw_node, "cleanExperiment", True)
+
+load_cmd = "omf load -i nepi_OMF6_VLC_baseline_grid.ndz -t %s" % hosts
+load_app = ec.register_resource("linux::Application")
+ec.set(load_app, "command", load_cmd)
+ec.register_connection(load_app, gw_node)
+
+reboot_cmd = "omf tell -a on -t %s" % hosts
+reboot_app = ec.register_resource("linux::Application")
+ec.set(reboot_app, "command", reboot_cmd)
+ec.register_connection(reboot_app, gw_node)
+
+ec.register_condition(reboot_app, ResourceAction.START, load_app,
+ ResourceState.STOPPED, time="60s")
+
+hosts = hosts.split(",")
+
+for hostname in hosts:
+ host = hostname.split(".")[-1]
+ node = ec.register_resource("linux::Node")
+ ec.set(node, "username", username)
+ ec.set(node, "hostname", host)
+ ec.set(node, "identity", identity)
+ ec.set(node, "gateway", gateway)
+ ec.set(node, "gatewayUser", gateway_username)
+ ec.set(node, "cleanExperiment", True)
+ ec.register_condition(node, ResourceAction.DEPLOY, reboot_app,
+ ResourceState.STOPPED, time="300s")
+
+ modprobe_app = ec.register_resource("linux::Application")
+ ec.set(modprobe_app, "command", "modprobe ath5k && ip a | grep wlan0")
+ ec.register_connection(modprobe_app, node)
+ apps.append(modprobe_app)
+
+ rc_app = ec.register_resource("linux::Application")
+ ec.set(rc_app, "command", "service omf_rc stop; service omf_rc start")
+ ec.register_connection(rc_app, node)
+ apps.append(rc_app)
+
+print("This might take time...")
+
+ec.deploy(wait_all_ready=False)
+
+ec.wait_finished(apps)
+
+print(ec.trace(load_app, "stdout"))
+print(ec.trace(reboot_app, "stdout"))
+
+for app in apps:
+ print(ec.trace(app, "stdout"))
+
+ec.shutdown()
+
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)
#
#
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.resource import ResourceAction, ResourceState
ec.wait_finished([app1, app2])
-print ec.trace(app1, "stdout")
+print(ec.trace(app1, "stdout"))
# Stop Experiment
ec.shutdown()
# $ PYTHONPATH=$PYTHONPATH:src/ python examples/openvswitch/ovs_ping.py -n "192.168.3.0/24" -s <slicename> -i /~/.ssh/id_rsa
#
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
import os
# Retreive ping results and save them in a file
ping = ec.trace(app, "stdout")
-print ping
+print(ping)
# Delete the overlay network
ec.shutdown()
-
-
# $ PYTHONPATH=$PYTHONPATH:src/ python examples/openvswitch/ovs_ping_2_switches.py -n "192.168.3.0/24" -C "1.1.1.1" -s <slicename> -i /~/.ssh/id_rsa
#
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
import os
# Delete the overlay network
ec.shutdown()
-print stdout
-
+print(stdout)
# $ PYTHONPATH=$PYTHONPATH:src/ python examples/openvswitch/ovs_ping_3_switches.py -n "192.168.3.0/24" -C "1.1.1.1" -s <slicename> -i /~/.ssh/id_rsa
#
-
+from __future__ import print_function
from nepi.execution.ec import ExperimentController
# 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()
-
-
# 0 ------- network -------- 1
#
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from optparse import OptionParser, SUPPRESS_HELP
ec.shutdown()
-print "Transfered FILE stored localy at video.ts"
+print("Transfered FILE stored localy at video.ts")
# $ cd <path-to-nepi>
# python examples/planetlab/ping.py -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key>
+from __future__ import print_function
from nepi.execution.ec import ExperimentController
trace = ec.trace(app, "stdout")
-print "PING outout ", trace
+print("PING outout ", trace)
# Do the experiment controller shutdown
ec.shutdown()
# $ cd <path-to-nepi>
# python examples/planetlab/ping_with_filters.py -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.resource import ResourceAction, ResourceState
# 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()
# $ cd <path-to-nepi>
# python examples/planetlab/select_nodes.py -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key> -c <country> -o <operating-system> -n <node-count>
+from __future__ import print_function
from nepi.execution.ec import ExperimentController
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()
# $ cd <path-to-nepi>
# python examples/planetlab/update_fedora_repo.py -H <host1,host2,..> -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from optparse import OptionParser, SUPPRESS_HELP
for app in apps:
try:
- print ec.trace(app, "stderr")
+ print(ec.trace(app, "stderr"))
except:
- print "NO stderr"
+ print("NO stderr")
ec.shutdown()
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
import logging
import os
import traceback
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
# \ nid3.log
#
+from __future__ import print_function
+
import collections
import functools
import networkx
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
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]
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,
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
import base64
import fcntl
import errno
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')
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
import base64
import socket
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")
# Claudio Freire <claudio-daniel.freire@inria.fr>
#
+from __future__ import print_function
import select
import sys
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()
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
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
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
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
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
if not sock:
raise OSError, "Error: tcp_establish could not establish connection."
return sock
-
-
# 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
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()
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
# Julien Tribino <julien.tribino@inria.fr>
+from __future__ import print_function
+
import os
from nepi.util.timefuncs import tnow
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()
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
import base64
import errno
import passfd
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')
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
import base64
import socket
import vsys
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
#
# Author: Lucia Guevgeozian <lucia.guevgeozian_odizzio@inria.fr>
+from __future__ import print_function
+
from nepi.execution.attribute import Attribute, Flags, Types
from nepi.execution.resource import ResourceManager, clsinit_copy, \
ResourceState
# 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:
#
# Author: Lucia Guevgeozian Odizzio <lucia.guevgeozian_odizzio@inria.fr>
+from __future__ import print_function
+
import xmlrpclib
import hashlib
import threading
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
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.util.netgraph import NetGraph, TopologyType
from nepi.util.timefuncs import stformat, tsformat
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
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
import math
import numpy
from scipy import stats
# 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)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.resources.linux.node import LinuxNode
import os
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)
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)
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)
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)
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)
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)
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)
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)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.resource import ResourceState, ResourceAction
from nepi.execution.ec import ExperimentController
from test_utils import skipIfAnyNotAlive
ec.wait_finished(peek)
stdout = ec.trace(peek, "stdout")
- print stdout
+ print(stdout)
expected = "DATA"
self.assertTrue(stdout.find(expected) > -1)
# 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
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)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.trace import TraceAttr
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
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.resource import ResourceState, ResourceAction
from nepi.execution.trace import TraceAttr
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)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.trace import TraceAttr
stdout = ec.trace(simu, "stdout")
- print stdout
+ print(stdout)
expected = "20 packets transmitted, 20 received, 0% packet loss"
self.assertTrue(stdout.find(expected) > -1)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.trace import TraceAttr
stdout = ec.trace(simu, "stdout")
- print stdout
+ print(stdout)
expected = "20 packets transmitted, 20 received, 0% packet loss"
self.assertTrue(stdout.find(expected) > -1)
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from nepi.execution.trace import TraceAttr
ec.register_connection(ping, nsnode2)
filepath = ec.save(dirpath)
- print filepath
+ print(filepath)
ec.deploy()
ec.register_connection(ping, nsnode1)
filepath = ec.save(dirpath)
- print filepath
+ print(filepath)
ec.deploy()
#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
from test_utils import skipIfAnyNotAliveWithIdentity
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)
ping = ec.trace(app, "stdout")
- print ping
+ print(ping)
expected = """3 packets transmitted, 3 received, 0% packet loss"""
self.assertTrue(ping.find(expected) > -1)
#
# node n0 sends IGMP traffic to node n3
+from __future__ import print_function
from nepi.resources.ns3.ns3wrapper import NS3Wrapper
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",
#
# Author: Julien Tribino <julien.tribino@inria.fr>
+from __future__ import print_function
-from nepi.execution.resource import ResourceFactory, clsinit_copy, ResourceManager, ResourceAction, ResourceState
+from nepi.execution.resource import (ResourceFactory, clsinit_copy,
+ ResourceManager, ResourceAction, ResourceState)
from nepi.execution.ec import ExperimentController
from nepi.execution.attribute import Attribute, Flags
@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
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)