--- /dev/null
+#!/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 imptort Experiment\r
+from nepi.execution.ec import ExperimentController\r
+from nepi.execution.resource import ResourceState, ResourceManager\r
+\r
+# Experiment parameters\r
+experiment_id = "case_a"\r
+agent = "10.0.1.1"\r
+netblock = "10.0.1.0"\r
+prefix = "24"\r
+# number of nodes to test\r
+parameters = [3]\r
+\r
+# list of hosts for running the experiment on \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
+# 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
+ # run experimentation as long as there is something to do\r
+ while len(parameters) > 0:\r
+ # Collection of application being processed\r
+ jobs = list()\r
+\r
+ # Collection of experiments launched\r
+ xps = list()\r
+\r
+ # Push a job on each node in the cluster\r
+ for node in node_info:\r
+ # Stop if nothing else to do\r
+ if len(parameters) == 0:\r
+ break\r
+\r
+ # Determine what network size to test\r
+ nb_nodes = parameters.pop(0)\r
+\r
+ # Create the simulated network\r
+ xp = Experiment(ec, node, nb_nodes, False)\r
+ xp.build_topology(netblock, prefix, agent)\r
+\r
+ # Remember the experiments just created\r
+ xps.append(xp)\r
+\r
+ # Remember the applications to be executed\r
+ jobs += xp.apps\r
+ \r
+ # Let's run the experiment\r
+ ec.deploy()\r
+ ec.wait_finished(jobs)\r
+\r
+ # Check if everything went well for each experiment\r
+ for xp in xps:\r
+ # and see the output\r
+ stdout = ec.trace(xp.apps[0], "stdout")\r
+ print "[", stdout, "]"\r
+ # check if one transmitter failed (if everything goes well, all trasmitters\r
+ # must have stopped properly) (ignore the agent)\r
+ for app in xp.apps[1:len(xp.apps)]:\r
+ if ec.state(app, hr=False) != ResourceState.STOPPED:\r
+ raise Exception("Crashed at size %d" % xp.nb_nodes)\r
+ # et voila \r
+ ec.shutdown()\r
+\r
+main()\r