use print() - import print_function - should be fine for both py2 and py3
[nepi.git] / examples / ns3 / multi_host / distributed.py
index c1a5a8b..c3aef65 100644 (file)
@@ -1,82 +1,84 @@
-#!/usr/bin/env python\r
-#\r
-#    NEPI, a framework to manage network experiments\r
-#    Copyright (C) 2015 INRIA\r
-#\r
-#    This program is free software: you can redistribute it and/or modify\r
-#    it under the terms of the GNU General Public License version 2 as\r
-#    published by the Free Software Foundation;\r
-#\r
-#    This program is distributed in the hope that it will be useful,\r
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-#    GNU General Public License for more details.\r
-#\r
-#    You should have received a copy of the GNU General Public License\r
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
-#\r
-# Author: Damien Saucez <damien.saucez@inria.fr>\r
-#         Alina Quereilhac <alina.quereilhac@inria.fr>\r
-#\r
-\r
-#\r
-# Note: To run this experiment you need to have a PlanetLab account.\r
-#\r
-# This experiment consists of a simulated wireless sensor network (ns-3)\r
-# with one fixed access point (AP), running an agent application, and several\r
-# mobile stations that run a transmitter application to send messages to\r
-# the AP.\r
-#\r
-# The experiment uses 2 networks like the one described above, running in 2\r
-# independent ns-3 instances in remote hosts, and transparently connected\r
-# through a UDP tunnel.\r
-\r
-#\r
-# command line:\r
-#\r
-# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/ditributed.py\r
-#\r
-\r
-import os\r
-\r
-from nepi.execution.ec import ExperimentController\r
-from nepi.execution.resource import ResourceState, ResourceManager\r
-\r
-from topology import *\r
-\r
-# tunning\r
-os.environ["NEPI_NTHREADS"] = "1"\r
-ResourceManager._reschedule_delay = "0s"\r
-\r
-# list of hosts for running the experiment on\r
-hostname1 = "onelab4.warsaw.rd.tp.pl"\r
-hostname2 = "planet2.servers.ua.pt"\r
-\r
-(username, pl_user, pl_password, ssh_key, node_count) = get_options()\r
-\r
-ec = ExperimentController(exp_id="distributed")\r
-\r
-host1, simu1 = add_host_simu(ec, hostname1, username, pl_user, pl_password, \r
-        ssh_key)\r
-\r
-ap1, agent1 = build_ns3_topology(ec, simu1, node_count, network="10.1.0.0", \r
-        prefixlen="24", agent_ip="10.1.0.1")\r
-\r
-host2, simu2 = add_host_simu(ec, hostname2, username, pl_user, pl_password, ssh_key)\r
-ap2, agent2 = build_ns3_topology(ec, simu2, node_count, network="10.2.0.0", prefixlen="24", agent_ip="10.1.0.1")\r
-\r
-fddev1 = add_fdnet_device(ec, ap1, "10.0.0.1", "30")\r
-fddev2 = add_fdnet_device(ec, ap2, "10.0.0.2", "30")\r
-\r
-connect_with_udp_tunnel(ec, fddev1, fddev2)\r
-\r
-ec.deploy()\r
-\r
-ec.wait_finished([simu1, simu2])\r
-\r
-stdout = ec.trace(agent1, "stdout")\r
-print " Agent says:"\r
-print stdout\r
-\r
-ec.shutdown()\r
-\r
+#!/usr/bin/env python
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2015 INRIA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License version 2 as
+#    published by the Free Software Foundation;
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Damien Saucez <damien.saucez@inria.fr>
+#         Alina Quereilhac <alina.quereilhac@inria.fr>
+#
+
+#
+# Note: To run this experiment you need to have a PlanetLab account.
+#
+# This experiment consists of a simulated wireless sensor network (ns-3)
+# with one fixed access point (AP), running an agent application, and several
+# mobile stations that run a transmitter application to send messages to
+# the AP.
+#
+# The experiment uses 2 networks like the one described above, running in 2
+# independent ns-3 instances in remote hosts, and transparently connected
+# through a UDP tunnel.
+
+#
+# command line:
+#
+# PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/ditributed.py
+#
+
+from __future__ import print_function
+
+import os
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.resource import ResourceState, ResourceManager
+
+from topology import *
+
+# tunning
+os.environ["NEPI_NTHREADS"] = "1"
+ResourceManager._reschedule_delay = "0s"
+
+# list of hosts for running the experiment on
+hostname1 = "onelab4.warsaw.rd.tp.pl"
+hostname2 = "planet2.servers.ua.pt"
+
+(username, pl_user, pl_password, ssh_key, node_count) = get_options()
+
+ec = ExperimentController(exp_id="distributed")
+
+host1, simu1 = add_host_simu(ec, hostname1, username, pl_user, pl_password, 
+        ssh_key)
+
+ap1, agent1 = build_ns3_topology(ec, simu1, node_count, network="10.1.0.0", 
+        prefixlen="24", agent_ip="10.1.0.1")
+
+host2, simu2 = add_host_simu(ec, hostname2, username, pl_user, pl_password, ssh_key)
+ap2, agent2 = build_ns3_topology(ec, simu2, node_count, network="10.2.0.0", prefixlen="24", agent_ip="10.1.0.1")
+
+fddev1 = add_fdnet_device(ec, ap1, "10.0.0.1", "30")
+fddev2 = add_fdnet_device(ec, ap2, "10.0.0.2", "30")
+
+connect_with_udp_tunnel(ec, fddev1, fddev2)
+
+ec.deploy()
+
+ec.wait_finished([simu1, simu2])
+
+stdout = ec.trace(agent1, "stdout")
+print(" Agent says:")
+print(stdout)
+
+ec.shutdown()
+