bd36cf77f7f1c575d95a0df499573bf7b4ea6613
[nepi.git] / examples / ns3 / multi_host / case_c.py
1 #!/usr/bin/env python\r
2 #\r
3 #    NEPI, a framework to manage network experiments\r
4 #    Copyright (C) 2013 INRIA\r
5 #\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
9 #\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
14 #\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
17 #\r
18 # Author: Damien Saucez <damien.saucez@inria.fr>\r
19 #         Alina Quereilhac <alina.quereilhac@inria.fr>\r
20 \r
21 import os\r
22 from experiment_interconnected_ns3_planetlab import ExperimentInterconnectedNs3Planetlab\r
23 from nepi.execution.ec import ExperimentController \r
24 from nepi.execution.resource import ResourceManager\r
25 \r
26 # Experiment parameters\r
27 experiment_id = "case_c"\r
28 agent = None\r
29 netblock = "192.168.3.0"\r
30 prefix = "25"\r
31 nb_nodes = 1\r
32 \r
33 node_info = {\r
34     "hostname":"onelab4.warsaw.rd.tp.pl", \r
35     "username":"inria_nepi", \r
36     "identity": "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'])\r
37     }\r
38 \r
39 \r
40 # tunning\r
41 os.environ["NEPI_NTHREADS"] = "1"\r
42 ResourceManager._reschedule_delay = "0s"\r
43 \r
44 # == Experimentation setup ====================================================\r
45 def main():\r
46     # Prepare the ExperimentController\r
47     ec = ExperimentController(exp_id = experiment_id)\r
48 \r
49     # Create the simulated network\r
50     xp = ExperimentInterconnectedNs3Planetlab(ec, node_info, nb_nodes)\r
51     xp.build_topology(netblock = netblock, prefix = prefix, target = agent)\r
52 \r
53     # Create Planetlab application\r
54     app = xp.add_planetlab_client(xp.ip_ap)\r
55 \r
56     # Interconnect Planetlab and ns3\r
57     xp.interconnect("192.168.3.128", "25")\r
58 \r
59     # Let's run the experiment\r
60     ec.deploy()\r
61     ec.wait_finished([app])\r
62 \r
63     # and see the output\r
64     stdout = ec.trace(xp.apps[0], "stdout")\r
65     print "[", stdout, "]"\r
66 \r
67     # et voila\r
68     ec.shutdown()\r
69 \r
70 main()\r