X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=examples%2Fns3%2Fmulti_host%2Fhybrid.py;h=630fec2da1b6ef7449b44e2d8f171daca110f23c;hb=039fbd9629d7570d4c175a5448d24badcd0f3aba;hp=0b36478955e245b345be466e46d75c2ec916c110;hpb=4ffa02a6eeaf8c5daacb10d8f52fc15782af84ab;p=nepi.git
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()
+
+