1 #!/usr/bin/env python
\r
3 # NEPI, a framework to manage network experiments
\r
4 # Copyright (C) 2015 INRIA
\r
6 # This program is free software: you can redistribute it and/or modify
\r
7 # it under the terms of the GNU General Public License version 2 as
\r
8 # published by the Free Software Foundation;
\r
10 # This program is distributed in the hope that it will be useful,
\r
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 # GNU General Public License for more details.
\r
15 # You should have received a copy of the GNU General Public License
\r
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
18 # Author: Damien Saucez <damien.saucez@inria.fr>
\r
19 # Alina Quereilhac <alina.quereilhac@inria.fr>
\r
23 # Note: To run this experiment you need to have a PlanetLab account.
\r
25 # This experiment consists of a simulated wireless sensor network (ns-3)
\r
26 # with one fixed access point (AP), running an agent application, and several
\r
27 # mobile stations that run a transmitter application to send messages to
\r
30 # The same experiment described above is run in parallel with different
\r
31 # number of mobile stations in 2 PlanetLab hosts.
\r
37 # PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/parallel.py
\r
42 from topology import *
\r
44 from nepi.execution.ec import ExperimentController
\r
45 from nepi.execution.resource import ResourceState, ResourceManager
\r
48 os.environ["NEPI_NTHREADS"] = "1"
\r
49 ResourceManager._reschedule_delay = "0s"
\r
51 # list of hosts for running the experiment on
\r
52 hostname1 = "onelab4.warsaw.rd.tp.pl"
\r
53 hostname2 = "planet2.servers.ua.pt"
\r
55 (username, pl_user, pl_password, ssh_key, node_count) = get_options()
\r
57 ec = ExperimentController(exp_id="parallel")
\r
58 counts = [node_count, 10]
\r
59 hosts = [hostname1, hostname2]
\r
64 for hostname in hosts:
\r
65 host, simu = add_host_simu(ec, hostname, username, pl_user, pl_password,
\r
67 simulations.append(simu)
\r
69 node_count = counts.pop()
\r
70 ap, agent = build_ns3_topology(ec, simu, node_count, network="10.1.0.0",
\r
71 prefixlen="24", agent_ip="10.1.0.1")
\r
72 agents.append(agent)
\r
76 ec.wait_finished(simulations)
\r
78 for agent in agents:
\r
79 stdout = ec.trace(agent, "stdout")
\r
80 print " Agent says:"
\r