From eafda84ee05e5f6ddabb2c96cfa4ac225951835b Mon Sep 17 00:00:00 2001 From: francozappa Date: Thu, 22 Jun 2017 11:12:56 +0800 Subject: [PATCH 01/13] Add contributing link to the doc --- CONTRIBUTING.md | 3 +++ README.md | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..4d5352d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contributing + +See [Contributing](https://minicps.readthedocs.io/en/latest/contributing.html) diff --git a/README.md b/README.md index ca23f61..3b0717f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [CS img]: https://travis-ci.org/scy-phy/minicps.svg [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/hslatman/awesome-industrial-control-system-security) -# MiniCPS # +# MiniCPS MiniCPS is a framework for Cyber-Physical Systems real-time simulation. It includes support for physical process and control devices simulation, and @@ -15,3 +15,7 @@ network emulation. It is build on top of MiniCPS is developed by the [SCy-Phy](http://scy-phy.github.io/index.html) group from SUTD (Singapore University of Design and Technology). + +## Contributing + +See [Contributing](https://minicps.readthedocs.io/en/latest/contributing.html) From b8d5ac284ce27a22fc7bd67823edfac54bb2593e Mon Sep 17 00:00:00 2001 From: francozappa Date: Thu, 22 Jun 2017 11:49:06 +0800 Subject: [PATCH 02/13] Draft contributing.rst --- docs/contributing.rst | 200 +++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 1 + docs/swat-tutorial.rst | 4 +- docs/userguide.rst | 75 ++-------------- 4 files changed, 211 insertions(+), 69 deletions(-) create mode 100644 docs/contributing.rst diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 0000000..ebc79b0 --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1,200 @@ +.. CONTRIBUTING {{{1 +.. _contributing: + +************* +Contributing +************* + +This doc provides information about how to contribute to the MiniCPS +projects. + +.. HOW TO START {{{2 + +============= +How to start +============= + + +General design principles +------------------------- + +MiniCPS follows an object-oriented design pattern. It is using ``python2.x`` +for compatibility reasons with ``mininet``. We are trying to lower the number +of external dependencies, and eventually will move to ``python3.x``. + +* design drivers: + + * separation of concerns (eg: public API vs private APi) + * modularity (eg: different protocols and state backends) + * testability (eg: unit tests and TDD) + * performance (eg: real-time simulation) + +* security drivers: + + * avoid unsafe programming languages + * user input is untrusted and has to be validated (eg: prepared statements) + * safe vs unsafe code separation + * automated static analysis + +* core components: + + * ``minicps`` module (should be in the ``PYTHONPATH``) + * ``examples`` use cases (can be anywhere in the filesystem) + + +Development sytle +----------------- + +MiniCPS is hosted on Github and encourages `canonical submission of +contributions +`_ +it uses +`semantic versioning `_, +``nose`` for `test-driven development +`_ and +``make`` as a launcher for various tasks. + +Required code +--------------- + +Clone the ``minicps`` repository: + +.. code-block:: console + + git clone https://github.com/scy-phy/minicps + +Add ``minicps`` to the python path, for example using a soft link: + +.. code-block:: console + + ln -s ~/minicps/minicps /usr/lib/python2.7/minicps + + +Install the requirements using: + +.. code-block:: console + + pip install -r ~/minicps/requirements.txt + +Run the tests with: + +.. code-block:: console + + cd ~/minicps + make tests + +Code conventions +---------------- + +The project it is based on PEP8 (code) and PEP257 (docstring). + +* naming scheme: + + * private: prepend ``_`` eg: ``_method_name`` or ``_attribute_name`` + * classes: ``ClassName`` or ``CLASSName``, ``method_name`` and ``instance_name`` + * others: ``function_name``, ``local_variable_name``, ``GLOBAL_VARIABLE_NAME`` + * filenames: ``foldername``, ``module.py``, ``another_module.py`` + and ``module_tests.py`` + * test: ``test_ClassName`` ``test_function_name`` + * make: ``target-name`` ``VARIABLE_NAME`` + * makers: ``TODO``, ``FIXME``, ``XXX``, ``NOTE`` + * doc: ``doc.rst``, ``another-doc.rst`` \and ``SPHINX_DOC_NAME SOMETHING(`` for + Sphinx's ``literalinclude`` + + +Module docstring: + +.. code-block:: python + + """ + ``modulename`` contains: + + - bla + + First paragraph. + + ... + + Last paragraph. + """ + +Function docstrings: + +.. code-block:: python + + def my_func(): + """Bla.""" + + pass + + def my_func(): + """Bla. + + :returns: wow + """ + + pass + +Class docstring to document (at least) public methods: + +.. code-block:: python + + class MyClass(object): + + """Bla.""" + + def __init__(self): + """Bla.""" + + pass + +.. }}} + + +.. PROTOCOLS {{{2 + +========= +Protocols +========= + +Compatibility with new (industrial) protocols depends on the availability of +a good open-source library implementing that protocol (eg: ``pymodbus`` for +Modbus protocols). + +If you want to add a new protocol please look at the ``minicps/protocols.py`` +module. ``Protocol`` is the base class, and the +``NewProtocolNameProtocol(Protocol)`` should be your new child class containing +the code to manage it. A good point to start it to take a look +at ``minicps/tests/protocols_tests.py`` to see how other protocols classes +are unit-tested. + +If you want to improve the compatibility of a supported protocol please take +a look at its implementation and unit-testing classes. For example, look at +``ModbusProtocol(Protocol)`` and ``TestModbusProtocol()`` if you want to improve +the Modbus protocol support. + +.. }}} + +.. STATES {{{2 + +====== +States +====== + +The same reasoning presented in the Protocols section applies here. + +.. }}} + +.. EXAMPLES {{{2 + +======== +Examples +======== + +Please feel free to send PRs about new use cases that are not already present +in the ``examples`` directory. + +.. }}} + +.. }}} + diff --git a/docs/index.rst b/docs/index.rst index faf097c..727ca18 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -14,6 +14,7 @@ Contents: userguide api swat-tutorial + contributing tests misc diff --git a/docs/swat-tutorial.rst b/docs/swat-tutorial.rst index 85ac4e0..c3c0999 100644 --- a/docs/swat-tutorial.rst +++ b/docs/swat-tutorial.rst @@ -5,10 +5,10 @@ SWaT tutorial ************* -This tutorial shows how to use MiniCPS to simulate a subprocess of a +This tutorial shows how to use MiniCPS to simulate a subprocess of a Water Treatment testbed. In particular, we demonstrate basic controls through simulated PLCs, the network traffic, and simple physical layer simulation. We -now provide: +now provide: * A list of the pre-requisites to run the tutorial * A brief system overview diff --git a/docs/userguide.rst b/docs/userguide.rst index 7e0fc1e..16eb4a4 100644 --- a/docs/userguide.rst +++ b/docs/userguide.rst @@ -42,55 +42,20 @@ requirements for MiniCPS (e.g., it can be used to display a pop-up window with sensor data visualization). The `Install MiniCPS`_ section provides instructions to install ``minicps`` -on a machine that is running the **latest official mininet VM (Ubuntu)**. Please -refer to your distribution documentation if you need to install Mininet on -other Linux distributions. - +for a user or a developer, and it assumes that you *already* have installed +``mininet``. .. INSTALL MINICPS {{{3 Install MiniCPS --------------- -Login the OS containing ``mininet`` installation then navigate to your home -directory: - -.. code-block:: console - - cd - -Make sure that the distro is up to date (if necessary, restart the system): - -.. code-block:: console - - sudo apt-get update - sudo apt-get upgrade - -Then clone ``minicps`` repository: - -.. code-block:: console - - git clone https://github.com/scy-phy/minicps - -and add ``minicps`` to the python path, for example using a soft link: - -.. code-block:: console - - ln -s ~/minicps/minicps /usr/lib/python2.7/minicps - -MiniCPS is compatible with *python 2.7.X*. Install dependencies using: +MiniCPS is can be installed using ``pip``: .. code-block:: console - sudo apt-get install python-matplotlib python-networkx python-pil.imagetk + sudo pip install minicps -For *Ethernet/IP* support install ``cpppo`` - -.. code-block:: console - - sudo pip install cpppo - -.. TODO: add modbus maybe reorganize the deps For *SDN controller development* there are many options, ``pox`` is a good starting point and Mininet's VM already includes it. If you @@ -109,7 +74,7 @@ execute the following: ~/minicps/bin/pox-init.py [-p POX_PATH -m MINICPS_PATH -vv] -Notice that: +Notice that: * You can increase the verbosity level using either ``v`` or ``-vv`` * ``POX_PATH`` defaults to ``~/pox`` and ``MINICPS_PATH`` defaults to @@ -118,41 +83,17 @@ Notice that: .. INSTALL OPTIONAL {{{3 .. _install-optional: -Install optional dependencies --------------------------------- - -For *testing* support install dependencies using: - -.. code-block:: console - - sudo apt-get install python-pip python-nose python-coverage - sudo pip install nose-cov - -To generate the *documentation* from the source we use the ``sphinx`` tool. -Please type: - -.. code-block:: console - - sudo apt-get install python-sphinx libjs-mathjax - sudo pip install sphinx-rtd-theme - - - -.. TESTING INSTALLATION {{{3 - -Testing installation ----------------------- -Now you should be able to run: +Test the installation with: .. code-block:: console cd ~/minicps make tests -.. Which should start the command line with ``mininet>`` prompt. To directly -.. continue with the tutorial, look at :ref:`swat-tutorial`. +If you want to contribute to the project please take a look at +:ref:`contributing`. .. CONFIGURE MINICPS {{{2 From 9b9c52fc1ab4b3b630b6f4c2f1bce7ddd1b2ebc1 Mon Sep 17 00:00:00 2001 From: francozappa Date: Thu, 22 Jun 2017 13:25:35 +0800 Subject: [PATCH 03/13] Update copyright --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 3a8766c..94c20b9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -58,7 +58,7 @@ # General information about the project. project = u'minicps' -copyright = u'2015, scy-phy' +copyright = u'2017, Daniele Antonioli' author = u'scy-phy' # The version info for the project you're documenting, acts as replacement for From c2d402fecfed609caf50b172a79b5a1cc422f392 Mon Sep 17 00:00:00 2001 From: francozappa Date: Thu, 22 Jun 2017 13:25:49 +0800 Subject: [PATCH 04/13] Better formatting --- docs/contributing.rst | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index ebc79b0..f51a802 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -20,23 +20,23 @@ General design principles MiniCPS follows an object-oriented design pattern. It is using ``python2.x`` for compatibility reasons with ``mininet``. We are trying to lower the number -of external dependencies, and eventually will move to ``python3.x``. +of external dependencies, and eventually move to ``python3.x``. -* design drivers: +* Design points: * separation of concerns (eg: public API vs private APi) * modularity (eg: different protocols and state backends) * testability (eg: unit tests and TDD) * performance (eg: real-time simulation) -* security drivers: +* Security points: * avoid unsafe programming languages * user input is untrusted and has to be validated (eg: prepared statements) * safe vs unsafe code separation * automated static analysis -* core components: +* Core components: * ``minicps`` module (should be in the ``PYTHONPATH``) * ``examples`` use cases (can be anywhere in the filesystem) @@ -88,17 +88,18 @@ Code conventions The project it is based on PEP8 (code) and PEP257 (docstring). -* naming scheme: +* Naming scheme: - * private: prepend ``_`` eg: ``_method_name`` or ``_attribute_name`` - * classes: ``ClassName`` or ``CLASSName``, ``method_name`` and ``instance_name`` - * others: ``function_name``, ``local_variable_name``, ``GLOBAL_VARIABLE_NAME`` - * filenames: ``foldername``, ``module.py``, ``another_module.py`` + * Private data: prepend ``_`` eg: ``_method_name`` or ``_attribute_name`` + * Classes: ``ClassName`` or ``CLASSName``, ``method_name`` and ``instance_name`` + * Others: ``function_name``, ``local_variable_name``, ``GLOBAL_VARIABLE_NAME`` + * Filenames: ``foldername``, ``module.py``, ``another_module.py`` and ``module_tests.py`` - * test: ``test_ClassName`` ``test_function_name`` - * make: ``target-name`` ``VARIABLE_NAME`` - * makers: ``TODO``, ``FIXME``, ``XXX``, ``NOTE`` - * doc: ``doc.rst``, ``another-doc.rst`` \and ``SPHINX_DOC_NAME SOMETHING(`` for + * Test: ``test_ClassName`` ``test_function_name`` + * Makefile: ``target-name`` ``VARIABLE_NAME`` + * Makers: ``TODO``, ``FIXME``, ``XXX``, ``NOTE`` ``VIM MARKER {{{ + ... }}}`` + * Docs: ``doc.rst``, ``another-doc.rst`` \and ``SPHINX_DOC_NAME SOMETHING(`` for Sphinx's ``literalinclude`` From a1458f454db76f39ebab30c47174546f424566e7 Mon Sep 17 00:00:00 2001 From: francozappa Date: Sat, 24 Jun 2017 10:10:28 +0800 Subject: [PATCH 05/13] Remove TODO --- tests/states_tests.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/states_tests.py b/tests/states_tests.py index 62bf04a..2d323a4 100644 --- a/tests/states_tests.py +++ b/tests/states_tests.py @@ -10,8 +10,6 @@ from nose.tools import eq_ from nose.plugins.skip import SkipTest -# TODO: change to /tmp when install SQLitesutdio in ubuntu - PATH = "/tmp/states_tests.sqlite" NAME = 'states_tests' STATE = { From 2d82b1799cd47bbccd32ce304e923cf1428b2a30 Mon Sep 17 00:00:00 2001 From: francozappa Date: Sat, 24 Jun 2017 10:16:51 +0800 Subject: [PATCH 06/13] Add testing and docs sections --- docs/contributing.rst | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index f51a802..7dd5760 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -151,7 +151,6 @@ Class docstring to document (at least) public methods: .. }}} - .. PROTOCOLS {{{2 ========= @@ -166,7 +165,7 @@ If you want to add a new protocol please look at the ``minicps/protocols.py`` module. ``Protocol`` is the base class, and the ``NewProtocolNameProtocol(Protocol)`` should be your new child class containing the code to manage it. A good point to start it to take a look -at ``minicps/tests/protocols_tests.py`` to see how other protocols classes +at ``tests/protocols_tests.py`` to see how other protocols classes are unit-tested. If you want to improve the compatibility of a supported protocol please take @@ -182,7 +181,20 @@ the Modbus protocol support. States ====== -The same reasoning presented in the Protocols section applies here. +The same reasoning presented in the Protocols section applies here. The +relevant source code is located in ``minicps/states.py`` and +``tests/states_tests.py``. + +.. }}} + +.. TESTING {{{2 + +======== +Testing +======== + +Unit testing is hard to setup properly! Please if you find any inconsistent unit test or +decomposable unit test or you want to add a new one. .. }}} @@ -197,5 +209,30 @@ in the ``examples`` directory. .. }}} +.. DOCS {{{2 + +======== +Docs +======== + +All the docs are stored in the ``docs`` folder. We are using ``sphinx`` to +render the docs and the ``rst`` markup language to write them. Some of the +docs are automatically generated from the code and others are written by +hands. + +To build you documentation locally use one of the target of the ``Makefile`` +present in the ``docs`` folder. For example, to build and navigate an html +version of our docs type: + +.. code-block:: console + + cd docs + make html + firefox _build/html/index.html + +Please send a PR if you find any typo, incorrect explanation, etc. + +.. }}} + .. }}} From f14e874a40beea3c1d84e0bdacee1059c6144832 Mon Sep 17 00:00:00 2001 From: francozappa Date: Tue, 27 Jun 2017 15:28:57 +0800 Subject: [PATCH 07/13] Separate requirements for users and devs --- docs/contributing.rst | 2 +- requirements-dev.txt | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 requirements-dev.txt diff --git a/docs/contributing.rst b/docs/contributing.rst index 7dd5760..20463c8 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -74,7 +74,7 @@ Install the requirements using: .. code-block:: console - pip install -r ~/minicps/requirements.txt + pip install -r ~/minicps/requirements-dev.txt Run the tests with: diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..1788721 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,9 @@ +networkx +coverage +nose +rednose +cryptography +pyasn1 +pymodbus +cpppo + From 149d63a0f8c8f45a768db65f76e85835682b702c Mon Sep 17 00:00:00 2001 From: francozappa Date: Tue, 27 Jun 2017 15:40:07 +0800 Subject: [PATCH 08/13] Update userguide --- docs/userguide.rst | 59 +++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/docs/userguide.rst b/docs/userguide.rst index 16eb4a4..4531de8 100644 --- a/docs/userguide.rst +++ b/docs/userguide.rst @@ -45,6 +45,7 @@ The `Install MiniCPS`_ section provides instructions to install ``minicps`` for a user or a developer, and it assumes that you *already* have installed ``mininet``. + .. INSTALL MINICPS {{{3 Install MiniCPS @@ -56,6 +57,23 @@ MiniCPS is can be installed using ``pip``: sudo pip install minicps +Test the installation downloading one of our examples from +https://github.com/scy-phy/minicps/tree/master/examples and try to run it. + +For example, given that you downloaded the ``examples`` directory, +then you can ``cd swat-s1`` folder and run: + +.. code-block:: console + + sudo python run.py + + +.. INSTALL OPTIONAL {{{3 +.. _install-optional: + +Install Optional Packages +------------------------- + For *SDN controller development* there are many options, ``pox`` is a good starting point and Mininet's VM already includes it. If you @@ -80,16 +98,7 @@ Notice that: * ``POX_PATH`` defaults to ``~/pox`` and ``MINICPS_PATH`` defaults to ``~/minicps``, indeed ``~/minicps/bin/init`` should work for you. -.. INSTALL OPTIONAL {{{3 -.. _install-optional: - - -Test the installation with: - -.. code-block:: console - cd ~/minicps - make tests If you want to contribute to the project please take a look at @@ -119,8 +128,7 @@ using the ``-Y`` option: .. code-block:: console - ssh -Y mininet@minnetvm - + ssh -Y mininet@mininetvm .. IPv6 {{{3 @@ -156,32 +164,3 @@ Instruction taken from `here `_ -.. OFFILNE DOCUMENTATION {{{3 - -Offline Documentation ---------------------- - -First install packages listed in `Install optional dependencies`_. - -Then open ``docs/Makefile`` and check that ``SPHINXBUILD`` reference to -``sphinx-build`` command. (e.g., Arch Linux users can use ``sphinx-build2``) - -Then to build the doc in ``html`` format type: - -.. code-block:: console - - cd docs - make html - -Then to navigate a static version through a browser (e.g., ``firefox``) type: - -.. code-block:: console - - firefox _build/html/index.html - - -.. LOGGING AND TESTING {{{2 - -.. Logging and Testing -.. ==================== -.. TODO From 2333cb3c6e4bfc0349d81edba1d969e5462e553f Mon Sep 17 00:00:00 2001 From: francozappa Date: Tue, 27 Jun 2017 15:41:56 +0800 Subject: [PATCH 09/13] coverage is not required --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d4745f7..d7aa635 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -coverage nose rednose cryptography From 75fdbffb3dc65fdeb5b5e2f8e7d94a413bc8b167 Mon Sep 17 00:00:00 2001 From: francozappa Date: Wed, 28 Jun 2017 11:27:12 +0800 Subject: [PATCH 10/13] Remove nose import of with_setup --- minicps/utils.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/minicps/utils.py b/minicps/utils.py index 82a446f..5606943 100644 --- a/minicps/utils.py +++ b/minicps/utils.py @@ -16,8 +16,6 @@ import os from mininet.util import dumpNodeConnections -from nose import with_setup - # logging {{{1 # https://docs.python.org/2/howto/logging.html @@ -118,14 +116,6 @@ def teardown_func(test_name): pass -def with_named_setup(setup=None, teardown=None): - def wrap(f): - return with_setup( - lambda: setup(f.__name__) if (setup is not None) else None, - lambda: teardown(f.__name__) if (teardown is not None) else None)(f) - return wrap - - # TODO: test it def _arp_cache_rtts(net, h1, h2): """Learning check on the first two ping ICMP packets RTT. From 0ac3ab3278e81aebe4717e0f599f752b4fda06d3 Mon Sep 17 00:00:00 2001 From: francozappa Date: Wed, 28 Jun 2017 11:42:18 +0800 Subject: [PATCH 11/13] Remove examples dep from nose --- examples/swat-s1/tests.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/swat-s1/tests.py b/examples/swat-s1/tests.py index fbe73dc..93d8f0f 100644 --- a/examples/swat-s1/tests.py +++ b/examples/swat-s1/tests.py @@ -5,8 +5,6 @@ # from mininet.cli import CLI from mininet.net import Mininet -from nose.plugins.skip import SkipTest - from utils import STATE, RWT_INIT_LEVEL from utils import TANK_SECTION from topo import SwatTopo @@ -17,7 +15,6 @@ # import sys -@SkipTest def test_init(): pass From 7d3e5cdb1f6811dd1b475d3c9ce2058ee502c040 Mon Sep 17 00:00:00 2001 From: francozappa Date: Wed, 28 Jun 2017 12:08:53 +0800 Subject: [PATCH 12/13] Update to version 1.1.3 --- Makefile | 4 +++- RELEASES.md | 9 +++++++++ setup.py | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7611c5e..8f728dc 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ # MiniCPS makefile # VARIABLES {{{1 + +LATEST_VERSION = 1.1.3 MININET = sudo mn PYTHON = sudo python @@ -145,6 +147,6 @@ pypi-wheel: ./setup.py sdist bdist_wheel pypi-upload: - $(UPLOADER) upload dist/* + $(UPLOADER) upload dist/minicps-$(LATEST_VERSION)* # }}} diff --git a/RELEASES.md b/RELEASES.md index 6303d51..6958af6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,5 +1,14 @@ # Releases and Changelog +## Version 1.1.3 (2017-05-14) + +### Misc + +* Add `CONTRIBTING.md` and related docs + * Clarify difference between user and devs installations + +* Fix dependencies issues + ## Version 1.1.2 (2017-05-14) ### Misc diff --git a/setup.py b/setup.py index ec9b577..3d14dd7 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ # NOTE: https://packaging.python.org/ setup( name='minicps', - version='1.1.2', + version='1.1.3', description='MiniCPS: a framework for Cyber-Physical Systems \ real-time simulation, built on top of mininet.', # NOTE: long_description displayed on PyPi From 80c6fc8d3134a3eaa3c2cc219a3bbe743dec1abb Mon Sep 17 00:00:00 2001 From: francozappa Date: Wed, 28 Jun 2017 15:58:32 +0800 Subject: [PATCH 13/13] Minor fixes --- docs/contributing.rst | 7 ++++--- docs/userguide.rst | 12 ++++++++++++ examples/swat-s1/run.py | 6 ++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index 20463c8..f921048 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -163,8 +163,9 @@ Modbus protocols). If you want to add a new protocol please look at the ``minicps/protocols.py`` module. ``Protocol`` is the base class, and the -``NewProtocolNameProtocol(Protocol)`` should be your new child class containing -the code to manage it. A good point to start it to take a look +``[NewProtocolName]Protocol(Protocol)`` should be your new child class +(inheriting from the ``Protocol`` class) containing +the code to manage the new protocol. A good point to start it to take a look at ``tests/protocols_tests.py`` to see how other protocols classes are unit-tested. @@ -194,7 +195,7 @@ Testing ======== Unit testing is hard to setup properly! Please if you find any inconsistent unit test or -decomposable unit test or you want to add a new one. +decomposable unit test or you want to add a new one then send a PR. .. }}} diff --git a/docs/userguide.rst b/docs/userguide.rst index 4531de8..9a4c8b8 100644 --- a/docs/userguide.rst +++ b/docs/userguide.rst @@ -67,6 +67,18 @@ then you can ``cd swat-s1`` folder and run: sudo python run.py +And you should see the following: + +.. code-block:: console + + *** Ping: testing ping reachability + attacker -> plc1 plc2 plc3 + plc1 -> attacker plc2 plc3 + plc2 -> attacker plc1 plc3 + plc3 -> attacker plc1 plc2 + *** Results: 0% dropped (12/12 received) + mininet> + .. INSTALL OPTIONAL {{{3 .. _install-optional: diff --git a/examples/swat-s1/run.py b/examples/swat-s1/run.py index 759c7f8..1c38810 100644 --- a/examples/swat-s1/run.py +++ b/examples/swat-s1/run.py @@ -20,7 +20,9 @@ def __init__(self, name, net): self.name = name self.net = net - self.net.start() + net.start() + + net.pingAll() # start devices plc1, plc2, plc3, s1 = self.net.get( @@ -35,7 +37,7 @@ def __init__(self, name, net): CLI(self.net) - self.net.stop() + net.stop() if __name__ == "__main__":