Commit 448f7130 authored by Jonas Kaufmann's avatar Jonas Kaufmann Committed by Antoine Kaufmann
Browse files

docs: reformat howto.rst to 80 characters line limit

parent 9c97aea6
...@@ -34,21 +34,49 @@ How To ...@@ -34,21 +34,49 @@ How To
Create and Run an Experiment Create and Run an Experiment
****************************** ******************************
Experiments are defined in a declarative fashion inside Python modules using classes. Basically, create a `.py` file and add a global variable ``experiments``, a list which contains multiple instances of the class :class:`simbricks.orchestration.experiments.Experiment`, each one describing a standalone experiment. This is very helpful if you wish to evaluate your work in different environments, for example, you may want to swap out some simulator or investigate multiple topologies with different scale. Experiments are defined in a declarative fashion inside Python modules using
classes. Basically, create a `.py` file and add a global variable
The class :class:`~simbricks.orchestration.experiments.Experiment` provides methods to add the simulators you wish to run. All available simulators can be found in the module :mod:`simbricks.orchestration.simulators`. Instantiating :class:`~simbricks.orchestration.simulators.HostSim` requires you to specify a :class:`~simbricks.orchestration.nodeconfig.NodeConfig`, which contains the configuration for your host, for example its networking settings, how much system memory it should have, and most importantly, which application to run by assigning an :class:`~simbricks.orchestration.nodeconfig.AppConfig`. You can find predefined classes for node and app configs in the module :mod:`simbricks.orchestration.nodeconfig`, feel free to add new ones or just create a new class locally in your experiment's module. ``experiments``, a list which contains multiple instances of the class
:class:`simbricks.orchestration.experiments.Experiment`, each one describing a
The last step to complete your virtual testbed is to specify which virtual components connect to each other. You do this by invoking the respective methods on the simulators you have instantiated. See the different simulator types' base classes in the module :mod:`~simbricks.orchestration.simulators` for more information. A simple and complete experiment module in which a client host pings a server can be found :ref:`below <simple_ping_experiment>`. standalone experiment. This is very helpful if you wish to evaluate your work in
different environments, for example, you may want to swap out some simulator or
If you plan to simulate a topology with multiple hosts, it may be helpful to take a look at the module :mod:`simbricks.orchestration.simulator_utils` in which we provide some helper functions to reduce the amount of code you have to write. investigate multiple topologies with different scale.
Finally, to run your experiment invoke ``/experiments/run.py`` and provide the path to your experiment module. In our docker containers, you can just use the following command from anywhere: The class :class:`~simbricks.orchestration.experiments.Experiment` provides
methods to add the simulators you wish to run. All available simulators can be
found in the module :mod:`simbricks.orchestration.simulators`. Instantiating
:class:`~simbricks.orchestration.simulators.HostSim` requires you to specify a
:class:`~simbricks.orchestration.nodeconfig.NodeConfig`, which contains the
configuration for your host, for example its networking settings, how much
system memory it should have, and most importantly, which application to run by
assigning an :class:`~simbricks.orchestration.nodeconfig.AppConfig`. You can
find predefined classes for node and app configs in the module
:mod:`simbricks.orchestration.nodeconfig`, feel free to add new ones or just
create a new class locally in your experiment's module.
The last step to complete your virtual testbed is to specify which virtual
components connect to each other. You do this by invoking the respective methods
on the simulators you have instantiated. See the different simulator types' base
classes in the module :mod:`~simbricks.orchestration.simulators` for more
information. A simple and complete experiment module in which a client host
pings a server can be found :ref:`below <simple_ping_experiment>`.
If you plan to simulate a topology with multiple hosts, it may be helpful to
take a look at the module :mod:`simbricks.orchestration.simulator_utils` in
which we provide some helper functions to reduce the amount of code you have to
write.
Finally, to run your experiment invoke ``/experiments/run.py`` and provide the
path to your experiment module. In our docker containers, you can just use the
following command from anywhere:
.. code-block:: bash .. code-block:: bash
$ simbricks-run --verbose --force <path_to_your_module.py> $ simbricks-run --verbose --force <path_to_your_module.py>
``--verbose`` prints all simulators' output to the terminal and ``--force`` forces execution even if there already exist result files for the same experiment. If ``simbricks-run`` is not available, you can always do ``--verbose`` prints all simulators' output to the terminal and ``--force``
forces execution even if there already exist result files for the same
experiment. If ``simbricks-run`` is not available, you can always do
.. code-block:: bash .. code-block:: bash
...@@ -56,14 +84,20 @@ Finally, to run your experiment invoke ``/experiments/run.py`` and provide the p ...@@ -56,14 +84,20 @@ Finally, to run your experiment invoke ``/experiments/run.py`` and provide the p
$ cd experiments $ cd experiments
$ python run.py --verbose --force <path_to_your_module.py> $ python run.py --verbose --force <path_to_your_module.py>
While running, you can interrupt the experiment using CTRL+C in your terminal. This will cleanly stop all simulators and collect their output in a JSON file in the directory ``experiments/out/<experiment_name>``. These are the necessary basics to create and run your first experiment. Have fun. While running, you can interrupt the experiment using CTRL+C in your terminal.
This will cleanly stop all simulators and collect their output in a JSON file in
the directory ``experiments/out/<experiment_name>``. These are the necessary
basics to create and run your first experiment. Have fun.
.. literalinclude:: /../experiments/pyexps/simple_ping.py .. literalinclude:: /../experiments/pyexps/simple_ping.py
:linenos: :linenos:
:lines: 25- :lines: 25-
:language: python :language: python
:name: simple_ping_experiment :name: simple_ping_experiment
:caption: A simple experiment with a client host pinging a server, both are connected through a network switch. The setup of the two hosts could be simplified by using :func:`~simbricks.orchestration.simulator_utils.create_basic_hosts`. :caption: A simple experiment with a client host pinging a server, both are
connected through a network switch. The setup of the two hosts could be
simplified by using
:func:`~simbricks.orchestration.simulator_utils.create_basic_hosts`.
.. _sec-howto-nodeconfig: .. _sec-howto-nodeconfig:
...@@ -79,11 +113,27 @@ Add a Custom Image ...@@ -79,11 +113,27 @@ Add a Custom Image
Integrate a New Simulator Integrate a New Simulator
****************************** ******************************
The first step when integrating a new simulator into SimBricks is to implement a SimBricks adapter for it. You can find the necessary information in the :ref:`Simulator Adapters <Simulator Adapters>` section. After that, we need to add a class for the simulator in the SimBricks orchestration framework such that it can be used when defining experiments. This class basically wraps a command for launching the simulator and needs to inherit from :class:`~simbricks.orchestration.simulators.Simulator` and implement relevant methods. There are several more specialized child classes in the module :mod:`simbricks.orchestration.simulators` for typical categories of simulators, which already offer the interfaces to collect parameters like which other simulators to connect to necessary for creating the launch command. Examples are :class:`~simbricks.orchestration.simulators.PCIDevSim`, :class:`~simbricks.orchestration.simulators.NICSim`, :class:`~simbricks.orchestration.simulators.NetSim`, and :class:`~simbricks.orchestration.simulators.HostSim`. You can find an example below of adding a class for the ``NS3`` network simulator. The first step when integrating a new simulator into SimBricks is to implement a
SimBricks adapter for it. You can find the necessary information in the
:ref:`Simulator Adapters <Simulator Adapters>` section. After that, we need to
add a class for the simulator in the SimBricks orchestration framework such that
it can be used when defining experiments. This class basically wraps a command
for launching the simulator and needs to inherit from
:class:`~simbricks.orchestration.simulators.Simulator` and implement relevant
methods. There are several more specialized child classes in the module
:mod:`simbricks.orchestration.simulators` for typical categories of simulators,
which already offer the interfaces to collect parameters like which other
simulators to connect to necessary for creating the launch command. Examples are
:class:`~simbricks.orchestration.simulators.PCIDevSim`,
:class:`~simbricks.orchestration.simulators.NICSim`,
:class:`~simbricks.orchestration.simulators.NetSim`, and
:class:`~simbricks.orchestration.simulators.HostSim`. You can find an example
below of adding a class for the ``NS3`` network simulator.
.. code-block:: python .. code-block:: python
:linenos: :linenos:
:caption: Class implementing the ``NS3`` network simulator in the SimBricks orchestration framework. :caption: Class implementing the ``NS3`` network simulator in the SimBricks
orchestration framework.
class NS3BridgeNet(NetSim): class NS3BridgeNet(NetSim):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment