Adding examples/ns3/multi_host
[nepi.git] / examples / ns3 / multi_host / case_c.py
diff --git a/examples/ns3/multi_host/case_c.py b/examples/ns3/multi_host/case_c.py
new file mode 100644 (file)
index 0000000..bd36cf7
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/env python\r
+#\r
+#    NEPI, a framework to manage network experiments\r
+#    Copyright (C) 2013 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
+import os\r
+from experiment_interconnected_ns3_planetlab import ExperimentInterconnectedNs3Planetlab\r
+from nepi.execution.ec import ExperimentController \r
+from nepi.execution.resource import ResourceManager\r
+\r
+# Experiment parameters\r
+experiment_id = "case_c"\r
+agent = None\r
+netblock = "192.168.3.0"\r
+prefix = "25"\r
+nb_nodes = 1\r
+\r
+node_info = {\r
+    "hostname":"onelab4.warsaw.rd.tp.pl", \r
+    "username":"inria_nepi", \r
+    "identity": "%s/.ssh/id_rsa_planetlab" % (os.environ['HOME'])\r
+    }\r
+\r
+\r
+# tunning\r
+os.environ["NEPI_NTHREADS"] = "1"\r
+ResourceManager._reschedule_delay = "0s"\r
+\r
+# == Experimentation setup ====================================================\r
+def main():\r
+    # Prepare the ExperimentController\r
+    ec = ExperimentController(exp_id = experiment_id)\r
+\r
+    # Create the simulated network\r
+    xp = ExperimentInterconnectedNs3Planetlab(ec, node_info, nb_nodes)\r
+    xp.build_topology(netblock = netblock, prefix = prefix, target = agent)\r
+\r
+    # Create Planetlab application\r
+    app = xp.add_planetlab_client(xp.ip_ap)\r
+\r
+    # Interconnect Planetlab and ns3\r
+    xp.interconnect("192.168.3.128", "25")\r
+\r
+    # Let's run the experiment\r
+    ec.deploy()\r
+    ec.wait_finished([app])\r
+\r
+    # and see the output\r
+    stdout = ec.trace(xp.apps[0], "stdout")\r
+    print "[", stdout, "]"\r
+\r
+    # et voila\r
+    ec.shutdown()\r
+\r
+main()\r