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 experiment uses 2 networks like the one described above, running in 2
\r
31 # independent ns-3 instances in remote hosts, and transparently connected
\r
32 # through a UDP tunnel.
\r
37 # PYTHONPATH=$PYTHONPATH:src python examples/ns3/multi_host/ditributed.py
\r
42 from nepi.execution.ec import ExperimentController
\r
43 from nepi.execution.resource import ResourceState, ResourceManager
\r
45 from topology import *
\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="distributed")
\r
59 host1, simu1 = add_host_simu(ec, hostname1, username, pl_user, pl_password,
\r
62 ap1, agent1 = build_ns3_topology(ec, simu1, node_count, network="10.1.0.0",
\r
63 prefixlen="24", agent_ip="10.1.0.1")
\r
65 host2, simu2 = add_host_simu(ec, hostname2, username, pl_user, pl_password, ssh_key)
\r
66 ap2, agent2 = build_ns3_topology(ec, simu2, node_count, network="10.2.0.0", prefixlen="24", agent_ip="10.1.0.1")
\r
68 fddev1 = add_fdnet_device(ec, ap1, "10.0.0.1", "30")
\r
69 fddev2 = add_fdnet_device(ec, ap2, "10.0.0.2", "30")
\r
71 connect_with_udp_tunnel(ec, fddev1, fddev2)
\r
75 ec.wait_finished([simu1, simu2])
\r
77 stdout = ec.trace(agent1, "stdout")
\r
78 print " Agent says:"
\r